mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 15:49:00 +02:00
feat(views/board): keep empty columns
This commit is contained in:
parent
e1a8f4f5db
commit
37c9260dca
@ -10,28 +10,31 @@ type ColumnMap = Map<string, {
|
|||||||
export async function getBoardData(parentNote: FNote, groupByColumn: string, persistedData: BoardData) {
|
export async function getBoardData(parentNote: FNote, groupByColumn: string, persistedData: BoardData) {
|
||||||
const byColumn: ColumnMap = new Map();
|
const byColumn: ColumnMap = new Map();
|
||||||
|
|
||||||
|
// Add back existing columns.
|
||||||
|
for (const column of persistedData.columns || []) {
|
||||||
|
byColumn.set(column.value, []);
|
||||||
|
}
|
||||||
|
|
||||||
await recursiveGroupBy(parentNote.getChildBranches(), byColumn, groupByColumn);
|
await recursiveGroupBy(parentNote.getChildBranches(), byColumn, groupByColumn);
|
||||||
|
|
||||||
let newPersistedData: BoardData | undefined;
|
let newPersistedData: BoardData | undefined;
|
||||||
if (persistedData) {
|
// Check if we have new columns.
|
||||||
// Check if we have new columns.
|
const existingColumns = persistedData.columns?.map(c => c.value) || [];
|
||||||
const existingColumns = persistedData.columns?.map(c => c.value) || [];
|
for (const column of existingColumns) {
|
||||||
for (const column of existingColumns) {
|
if (!byColumn.has(column)) {
|
||||||
if (!byColumn.has(column)) {
|
byColumn.set(column, []);
|
||||||
byColumn.set(column, []);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const newColumns = [...byColumn.keys()]
|
const newColumns = [...byColumn.keys()]
|
||||||
.filter(column => !existingColumns.includes(column))
|
.filter(column => !existingColumns.includes(column))
|
||||||
.map(column => ({ value: column }));
|
.map(column => ({ value: column }));
|
||||||
|
|
||||||
if (newColumns.length > 0) {
|
if (newColumns.length > 0) {
|
||||||
newPersistedData = {
|
newPersistedData = {
|
||||||
...persistedData,
|
...persistedData,
|
||||||
columns: [...(persistedData.columns || []), ...newColumns]
|
columns: [...(persistedData.columns || []), ...newColumns]
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -149,7 +149,10 @@ export default class BoardView extends ViewMode<BoardData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async renderBoard(el: HTMLElement) {
|
private async renderBoard(el: HTMLElement) {
|
||||||
const data = await getBoardData(this.parentNote, "status", this.persistentData);
|
const persistedData = await this.viewStorage.restore() ?? this.persistentData;
|
||||||
|
this.persistentData = persistedData;
|
||||||
|
|
||||||
|
const data = await getBoardData(this.parentNote, "status", persistedData);
|
||||||
|
|
||||||
if (data.newPersistedData) {
|
if (data.newPersistedData) {
|
||||||
this.persistentData = data.newPersistedData;
|
this.persistentData = data.newPersistedData;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user