Files
Trilium/apps/client/src/widgets/view_widgets/board_view/api.ts

46 lines
1.2 KiB
TypeScript
Raw Normal View History

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