mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 07:38:53 +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) {
|
||||
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);
|
||||
|
||||
let newPersistedData: BoardData | undefined;
|
||||
if (persistedData) {
|
||||
// Check if we have new columns.
|
||||
const existingColumns = persistedData.columns?.map(c => c.value) || [];
|
||||
for (const column of existingColumns) {
|
||||
if (!byColumn.has(column)) {
|
||||
byColumn.set(column, []);
|
||||
}
|
||||
// Check if we have new columns.
|
||||
const existingColumns = persistedData.columns?.map(c => c.value) || [];
|
||||
for (const column of existingColumns) {
|
||||
if (!byColumn.has(column)) {
|
||||
byColumn.set(column, []);
|
||||
}
|
||||
}
|
||||
|
||||
const newColumns = [...byColumn.keys()]
|
||||
.filter(column => !existingColumns.includes(column))
|
||||
.map(column => ({ value: column }));
|
||||
const newColumns = [...byColumn.keys()]
|
||||
.filter(column => !existingColumns.includes(column))
|
||||
.map(column => ({ value: column }));
|
||||
|
||||
if (newColumns.length > 0) {
|
||||
newPersistedData = {
|
||||
...persistedData,
|
||||
columns: [...(persistedData.columns || []), ...newColumns]
|
||||
};
|
||||
}
|
||||
if (newColumns.length > 0) {
|
||||
newPersistedData = {
|
||||
...persistedData,
|
||||
columns: [...(persistedData.columns || []), ...newColumns]
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -149,7 +149,10 @@ export default class BoardView extends ViewMode<BoardData> {
|
||||
}
|
||||
|
||||
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) {
|
||||
this.persistentData = data.newPersistedData;
|
||||
|
Loading…
x
Reference in New Issue
Block a user