Skip to content

Build your personal knowledge base with Trilium Notes

feat(board/relation): allow dragging between columns

Elian Doranf90e0767cb7e
diff --git a/apps/client/src/services/attributes.ts b/apps/client/src/services/attributes.ts
index 0b605f5bdc..13011b7a62 100644
--- a/apps/client/src/services/attributes.ts
+++ b/apps/client/src/services/attributes.ts
@@ -22,6 +22,15 @@ export async function setLabel(noteId: string, name: string, value: string = "",
});
}
+export async function setRelation(noteId: string, name: string, value: string = "", isInheritable = false) {
+ await server.put(`notes/${noteId}/set-attribute`, {
+ type: "relation",
+ name: name,
+ value: value,
+ isInheritable
+ });
+}
+
async function removeAttributeById(noteId: string, attributeId: string) {
await server.remove(`notes/${noteId}/attributes/${attributeId}`);
}
@@ -116,6 +125,7 @@ function isAffecting(attrRow: AttributeRow, affectedNote: FNote | null | undefin
export default {
addLabel,
setLabel,
+ setRelation,
setAttribute,
removeAttributeById,
removeOwnedLabelByName,
diff --git a/apps/client/src/widgets/collections/board/api.ts b/apps/client/src/widgets/collections/board/api.ts
index 14ad4d587a..6543bafd91 100644
--- a/apps/client/src/widgets/collections/board/api.ts
+++ b/apps/client/src/widgets/collections/board/api.ts
@@ -12,15 +12,25 @@ import { ColumnMap } from "./data";
export default class BoardApi {
+ private isRelationMode: boolean;
+ statusAttribute: string;
+
constructor(
private byColumn: ColumnMap | undefined,
public columns: string[],
private parentNote: FNote,
- readonly statusAttribute: string,
+ statusAttribute: string,
private viewConfig: BoardViewData,
private saveConfig: (newConfig: BoardViewData) => void,
private setBranchIdToEdit: (branchId: string | undefined) => void
- ) {};
+ ) {
+ this.isRelationMode = statusAttribute.startsWith("~");
+
+ if (statusAttribute.startsWith("~") || statusAttribute.startsWith("#")) {
+ statusAttribute = statusAttribute.substring(1);
+ }
+ this.statusAttribute = statusAttribute;
+ };
async createNewItem(column: string, title: string) {
try {
@@ -42,7 +52,11 @@ export default class BoardApi {
}
async changeColumn(noteId: string, newColumn: string) {
- await attributes.setLabel(noteId, this.statusAttribute, newColumn);
+ if (this.isRelationMode) {
+ await attributes.setRelation(noteId, this.statusAttribute, newColumn);
+ } else {
+ await attributes.setLabel(noteId, this.statusAttribute, newColumn);
+ }
}
async addNewColumn(columnName: string) {