feat(views/board): insert above/below

This commit is contained in:
Elian Doran
2025-07-20 17:35:52 +03:00
parent 1763d80d5f
commit 26ee0ff48f
4 changed files with 51 additions and 3 deletions

View File

@@ -1,12 +1,45 @@
import appContext from "../../../components/app_context";
import attributes from "../../../services/attributes";
import note_create from "../../../services/note_create";
export default class BoardApi {
constructor(public columns: string[]) {
constructor(
private _columns: string[],
private _parentNoteId: string) {}
get columns() {
return this._columns;
}
async changeColumn(noteId: string, newColumn: string) {
await attributes.setLabel(noteId, "status", newColumn);
}
openNote(noteId: string) {
appContext.triggerCommand("openInPopup", { noteIdOrPath: noteId });
}
async insertRowAtPosition(
column: string,
relativeToBranchId: string,
direction: "before" | "after",
open: boolean = true) {
const { note } = await note_create.createNote(this._parentNoteId, {
activate: false,
targetBranchId: relativeToBranchId,
target: direction
});
if (!note) {
throw new Error("Failed to create note");
}
const { noteId } = note;
await this.changeColumn(noteId, column);
if (open) {
this.openNote(noteId);
}
}
}