- Every interface string of Project Management goes through the catalog: 539 new rows with fr, ja, and zh-CN. - Storage and model messages use a local message() marker and stay free of host imports. The interface translates them. - A board renders again when the language changes. Dates use the interface language. - Fix: the ribbon button waits for the feature switches at startup, and the settings code loads no feature module. - Add six smoke tests: board state, cards, menus, drag and drop, views, and language. - Add docs/guides/project-management.md and UI-060. Update the user, plugin, SDK, host, development, and interface docs and CLAUDE.md. - Name the fake board view of tree/renameUndo "Board fixture", because the native Project Management button is now in the ribbon.
78 lines
3.2 KiB
TypeScript
78 lines
3.2 KiB
TypeScript
import { defaultBoard, type BoardDocument, type BoardList } from "../storage/board.ts";
|
|
import type { Task } from "./model.ts";
|
|
import { message } from "../storage/message.ts";
|
|
|
|
export interface TaskColumn {
|
|
list?: BoardList;
|
|
tasks: Task[];
|
|
allowCreate?: boolean;
|
|
}
|
|
|
|
/** Merge equal list names without changing the cards' board placements. */
|
|
export function allTaskColumns(boards: BoardDocument[], tasks: Task[]): TaskColumn[] {
|
|
const active = boards.filter(board => !board.archived);
|
|
const columns = new Map<string, TaskColumn>();
|
|
const assigned = new Set<string>();
|
|
const append = (list: BoardList | undefined, members: Task[], allowCreate = false) => {
|
|
const key = list ? `list:${list.name.trim().toLowerCase()}` : "unlisted";
|
|
let column = columns.get(key);
|
|
if (!column) {
|
|
column = { list: list ? { id: allowCreate ? list.id : key, name: list.name, status: list.status, collapsed: false } : undefined, tasks: [], allowCreate };
|
|
columns.set(key, column);
|
|
}
|
|
const included = new Set(column.tasks.map(task => task.id));
|
|
for (const task of members) if (!included.has(task.id)) {
|
|
column.tasks.push(task);
|
|
included.add(task.id);
|
|
}
|
|
};
|
|
for (const board of active) {
|
|
const members = tasks.filter(task => Object.hasOwn(task.placements ?? {}, board.id));
|
|
for (const task of members) assigned.add(task.id);
|
|
for (const list of board.value.lists)
|
|
append(list, members.filter(task => task.placements![board.id].listId === list.id));
|
|
const unlisted = members.filter(task => !board.value.lists.some(list => list.id === task.placements![board.id].listId));
|
|
if (unlisted.length) append(undefined, unlisted);
|
|
}
|
|
const standalone = tasks.filter(task => !assigned.has(task.id));
|
|
if (standalone.length || !active.length) {
|
|
for (const list of defaultBoard("all-tasks").lists)
|
|
append(list, standalone.filter(task => task.status === list.status), true);
|
|
}
|
|
return [...columns.values()];
|
|
}
|
|
|
|
export interface TaskBoardGroup {
|
|
boardIds: string[];
|
|
name: string;
|
|
tasks: Task[];
|
|
}
|
|
|
|
/** Keep shared cards once and name every board represented in this column. */
|
|
export function allTaskGroups(boards: BoardDocument[], column: TaskColumn): TaskBoardGroup[] {
|
|
const active = boards.filter(board => !board.archived);
|
|
const groups = new Map<string, TaskBoardGroup>();
|
|
for (const task of column.tasks) {
|
|
const owners = active.filter(board => {
|
|
const placement = task.placements?.[board.id];
|
|
if (!placement) return false;
|
|
const list = board.value.lists.find(list => list.id === placement.listId);
|
|
return column.list
|
|
? list?.name.trim().toLowerCase() === column.list.name.trim().toLowerCase()
|
|
: !list;
|
|
});
|
|
const boardIds = owners.map(board => board.id);
|
|
const key = JSON.stringify(boardIds);
|
|
let group = groups.get(key);
|
|
if (!group) {
|
|
group = { boardIds, name: owners.length ? owners.map(board => board.name).join(" · ") : message("No active board"), tasks: [] };
|
|
groups.set(key, group);
|
|
}
|
|
group.tasks.push(task);
|
|
}
|
|
return [...groups.values()].sort((a, b) => {
|
|
const order = (group: TaskBoardGroup) => group.boardIds.length ? active.findIndex(board => board.id === group.boardIds[0]) : active.length;
|
|
return order(a) - order(b);
|
|
});
|
|
}
|