2025-07-20 17:35:52 +03:00
|
|
|
import appContext from "../../../components/app_context";
|
2025-07-20 13:24:22 +03:00
|
|
|
import attributes from "../../../services/attributes";
|
2025-07-20 17:35:52 +03:00
|
|
|
import note_create from "../../../services/note_create";
|
2025-07-20 13:24:22 +03:00
|
|
|
|
|
|
|
|
export default class BoardApi {
|
|
|
|
|
|
2025-07-20 17:35:52 +03:00
|
|
|
constructor(
|
|
|
|
|
private _columns: string[],
|
|
|
|
|
private _parentNoteId: string) {}
|
|
|
|
|
|
|
|
|
|
get columns() {
|
|
|
|
|
return this._columns;
|
2025-07-20 13:24:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async changeColumn(noteId: string, newColumn: string) {
|
|
|
|
|
await attributes.setLabel(noteId, "status", newColumn);
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-20 17:35:52 +03:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-20 13:24:22 +03:00
|
|
|
}
|