Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(views/board): delete values when deleting column
Elian Doran2b5029cc38fa
diff --git a/apps/client/src/services/bulk_action.ts b/apps/client/src/services/bulk_action.tsindex 57b880c36e..d894ee17e5 100644--- a/apps/client/src/services/bulk_action.ts+++ b/apps/client/src/services/bulk_action.ts@@ -91,10 +91,10 @@ function parseActions(note: FNote) {.filter((action) => !!action);}-export async function executeBulkActions(parentNoteId: string, actions: BulkAction[]) {+export async function executeBulkActions(targetNoteIds: string[], actions: BulkAction[], includeDescendants = false) {await server.post("bulk-action/execute", {- noteIds: [ parentNoteId ],- includeDescendants: true,+ noteIds: targetNoteIds,+ includeDescendants,actions});diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 7bb080778e..1ef41d3f09 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1975,6 +1975,6 @@"insert-above": "Insert above","insert-below": "Insert below","delete-column": "Delete column",- "delete-column-confirmation": "Are you sure you want to delete this column? All notes in this column will be deleted as well."+ "delete-column-confirmation": "Are you sure you want to delete this column? The corresponding attribute will be deleted in the notes under this column as well."}}diff --git a/apps/client/src/widgets/view_widgets/board_view/api.ts b/apps/client/src/widgets/view_widgets/board_view/api.tsindex aa2e508020..7a706f2e6c 100644--- a/apps/client/src/widgets/view_widgets/board_view/api.ts+++ b/apps/client/src/widgets/view_widgets/board_view/api.ts@@ -1,6 +1,7 @@import appContext from "../../../components/app_context";import FNote from "../../../entities/fnote";import attributes from "../../../services/attributes";+import bulk_action, { executeBulkActions } from "../../../services/bulk_action";import note_create from "../../../services/note_create";import ViewModeStorage from "../view_mode_storage";import { BoardData } from "./config";@@ -69,6 +70,15 @@ export default class BoardApi {}async removeColumn(column: string) {+ // Remove the value from the notes.+ const noteIds = this.byColumn.get(column)?.map(item => item.note.noteId) || [];+ await executeBulkActions(noteIds, [+ {+ name: "deleteLabel",+ labelName: "status"+ }+ ]);+this.persistedData.columns = (this.persistedData.columns ?? []).filter(col => col.value !== column);this.viewStorage.store(this.persistedData);}diff --git a/apps/client/src/widgets/view_widgets/table_view/bulk_actions.ts b/apps/client/src/widgets/view_widgets/table_view/bulk_actions.tsindex b0f590c169..010bd1c488 100644--- a/apps/client/src/widgets/view_widgets/table_view/bulk_actions.ts+++ b/apps/client/src/widgets/view_widgets/table_view/bulk_actions.ts@@ -2,30 +2,30 @@ import { executeBulkActions } from "../../../services/bulk_action.js";export async function renameColumn(parentNoteId: string, type: "label" | "relation", originalName: string, newName: string) {if (type === "label") {- return executeBulkActions(parentNoteId, [{+ return executeBulkActions([parentNoteId], [{name: "renameLabel",oldLabelName: originalName,newLabelName: newName- }]);+ }], true);} else {- return executeBulkActions(parentNoteId, [{+ return executeBulkActions([parentNoteId], [{name: "renameRelation",oldRelationName: originalName,newRelationName: newName- }]);+ }], true);}}export async function deleteColumn(parentNoteId: string, type: "label" | "relation", columnName: string) {if (type === "label") {- return executeBulkActions(parentNoteId, [{+ return executeBulkActions([parentNoteId], [{name: "deleteLabel",labelName: columnName- }]);+ }], true);} else {- return executeBulkActions(parentNoteId, [{+ return executeBulkActions([parentNoteId], [{name: "deleteRelation",relationName: columnName- }]);+ }], true);}}