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