mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
refactor(views/board): store both branch and note
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import FBranch from "../../../entities/fbranch";
|
||||
import FNote from "../../../entities/fnote";
|
||||
|
||||
type ColumnMap = Map<string, {
|
||||
branch: FBranch;
|
||||
note: FNote;
|
||||
}[]>;
|
||||
|
||||
export async function getBoardData(parentNote: FNote, groupByColumn: string) {
|
||||
const byColumn: Map<string, FBranch[]> = new Map();
|
||||
const byColumn: ColumnMap = new Map();
|
||||
|
||||
await recursiveGroupBy(parentNote.getChildBranches(), byColumn, groupByColumn);
|
||||
|
||||
@@ -11,7 +16,7 @@ export async function getBoardData(parentNote: FNote, groupByColumn: string) {
|
||||
};
|
||||
}
|
||||
|
||||
async function recursiveGroupBy(branches: FBranch[], byColumn: Map<string, FBranch[]>, groupByColumn: string) {
|
||||
async function recursiveGroupBy(branches: FBranch[], byColumn: ColumnMap, groupByColumn: string) {
|
||||
for (const branch of branches) {
|
||||
const note = await branch.getNote();
|
||||
if (!note) {
|
||||
@@ -26,6 +31,9 @@ async function recursiveGroupBy(branches: FBranch[], byColumn: Map<string, FBran
|
||||
if (!byColumn.has(group)) {
|
||||
byColumn.set(group, []);
|
||||
}
|
||||
byColumn.get(group)!.push(branch);
|
||||
byColumn.get(group)!.push({
|
||||
branch,
|
||||
note
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +123,8 @@ export default class BoardView extends ViewMode<StateInfo> {
|
||||
const data = await getBoardData(this.parentNote, "status");
|
||||
|
||||
for (const column of data.byColumn.keys()) {
|
||||
const columnBranches = data.byColumn.get(column);
|
||||
if (!columnBranches) {
|
||||
const columnItems = data.byColumn.get(column);
|
||||
if (!columnItems) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ export default class BoardView extends ViewMode<StateInfo> {
|
||||
// Setup drop zone for the column
|
||||
this.setupColumnDropZone($columnEl, column);
|
||||
|
||||
for (const branch of columnBranches) {
|
||||
const note = await branch.getNote();
|
||||
for (const item of columnItems) {
|
||||
const note = item.note;
|
||||
if (!note) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user