chore(react/collections/table): add back insert above/below

This commit is contained in:
Elian Doran
2025-09-11 21:11:44 +03:00
parent 68b8ba691f
commit 05973672e4
5 changed files with 36 additions and 151 deletions

View File

@@ -1,4 +1,5 @@
import { BoardViewData } from ".";
import appContext from "../../../components/app_context";
import FNote from "../../../entities/fnote";
import attributes from "../../../services/attributes";
import { executeBulkActions } from "../../../services/bulk_action";
@@ -29,9 +30,9 @@ export default class BoardApi {
title: "New item"
});
if (newNote) {
if (newNote && newBranch) {
await this.changeColumn(newNote.noteId, column);
this.setBranchIdToEdit(newBranch?.branchId);
this.startEditing(newBranch?.branchId);
}
} catch (error) {
console.error("Failed to create new item:", error);
@@ -56,6 +57,36 @@ export default class BoardApi {
this.saveConfig(this.viewConfig);
}
async insertRowAtPosition(
column: string,
relativeToBranchId: string,
direction: "before" | "after") {
const { note, branch } = await note_create.createNote(this.parentNote.noteId, {
activate: false,
targetBranchId: relativeToBranchId,
target: direction,
title: "New item"
});
if (!note || !branch) {
throw new Error("Failed to create note");
}
const { noteId } = note;
await this.changeColumn(noteId, column);
this.startEditing(branch.branchId);
return note;
}
openNote(noteId: string) {
appContext.triggerCommand("openInPopup", { noteIdOrPath: noteId });
}
startEditing(branchId: string) {
this.setBranchIdToEdit(branchId);
}
dismissEditingTitle() {
this.setBranchIdToEdit(undefined);
}