chore(views/board): delete values when deleting column

This commit is contained in:
Elian Doran 2025-07-20 19:51:03 +03:00
parent 9e936cb57b
commit 2b5029cc38
No known key found for this signature in database
4 changed files with 22 additions and 12 deletions

View File

@ -91,10 +91,10 @@ function parseActions(note: FNote) {
.filter((action) => !!action); .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", { await server.post("bulk-action/execute", {
noteIds: [ parentNoteId ], noteIds: targetNoteIds,
includeDescendants: true, includeDescendants,
actions actions
}); });

View File

@ -1975,6 +1975,6 @@
"insert-above": "Insert above", "insert-above": "Insert above",
"insert-below": "Insert below", "insert-below": "Insert below",
"delete-column": "Delete column", "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."
} }
} }

View File

@ -1,6 +1,7 @@
import appContext from "../../../components/app_context"; import appContext from "../../../components/app_context";
import FNote from "../../../entities/fnote"; import FNote from "../../../entities/fnote";
import attributes from "../../../services/attributes"; import attributes from "../../../services/attributes";
import bulk_action, { executeBulkActions } from "../../../services/bulk_action";
import note_create from "../../../services/note_create"; import note_create from "../../../services/note_create";
import ViewModeStorage from "../view_mode_storage"; import ViewModeStorage from "../view_mode_storage";
import { BoardData } from "./config"; import { BoardData } from "./config";
@ -69,6 +70,15 @@ export default class BoardApi {
} }
async removeColumn(column: string) { 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.persistedData.columns = (this.persistedData.columns ?? []).filter(col => col.value !== column);
this.viewStorage.store(this.persistedData); this.viewStorage.store(this.persistedData);
} }

View File

@ -2,30 +2,30 @@ import { executeBulkActions } from "../../../services/bulk_action.js";
export async function renameColumn(parentNoteId: string, type: "label" | "relation", originalName: string, newName: string) { export async function renameColumn(parentNoteId: string, type: "label" | "relation", originalName: string, newName: string) {
if (type === "label") { if (type === "label") {
return executeBulkActions(parentNoteId, [{ return executeBulkActions([parentNoteId], [{
name: "renameLabel", name: "renameLabel",
oldLabelName: originalName, oldLabelName: originalName,
newLabelName: newName newLabelName: newName
}]); }], true);
} else { } else {
return executeBulkActions(parentNoteId, [{ return executeBulkActions([parentNoteId], [{
name: "renameRelation", name: "renameRelation",
oldRelationName: originalName, oldRelationName: originalName,
newRelationName: newName newRelationName: newName
}]); }], true);
} }
} }
export async function deleteColumn(parentNoteId: string, type: "label" | "relation", columnName: string) { export async function deleteColumn(parentNoteId: string, type: "label" | "relation", columnName: string) {
if (type === "label") { if (type === "label") {
return executeBulkActions(parentNoteId, [{ return executeBulkActions([parentNoteId], [{
name: "deleteLabel", name: "deleteLabel",
labelName: columnName labelName: columnName
}]); }], true);
} else { } else {
return executeBulkActions(parentNoteId, [{ return executeBulkActions([parentNoteId], [{
name: "deleteRelation", name: "deleteRelation",
relationName: columnName relationName: columnName
}]); }], true);
} }
} }