Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
promoted attributes widget is now auto-updating, fixes #700
zadam2c609e8136f1
diff --git a/src/entities/attribute.js b/src/entities/attribute.jsindex 0800d62529..0e36921db3 100644--- a/src/entities/attribute.js+++ b/src/entities/attribute.js@@ -105,7 +105,7 @@ class Attribute extends Entity {// cannot be static!updatePojo(pojo) {- delete pojo.__note;+ delete pojo.__note; // FIXME: probably note necessary anymore}createClone(type, name, value) {diff --git a/src/public/app/dialogs/attributes.js b/src/public/app/dialogs/attributes.jsindex 2cf8444203..c588e51f54 100644--- a/src/public/app/dialogs/attributes.js+++ b/src/public/app/dialogs/attributes.js@@ -152,10 +152,10 @@ function AttributesModel() {attr.value = treeService.getNoteIdFromNotePath(attr.selectedPath);}else if (attr.type === 'label-definition') {- attr.value = attr.labelDefinition;+ attr.value = JSON.stringify(attr.labelDefinition);}else if (attr.type === 'relation-definition') {- attr.value = attr.relationDefinition;+ attr.value = JSON.stringify(attr.relationDefinition);}delete attr.labelValue;diff --git a/src/public/app/services/load_results.js b/src/public/app/services/load_results.jsindex 89965e8f35..7153b2e9ae 100644--- a/src/public/app/services/load_results.js+++ b/src/public/app/services/load_results.js@@ -54,8 +54,9 @@ export default class LoadResults {this.attributes.push({attributeId, sourceId});}- getAttributes() {+ getAttributes(sourceId = 'none') {return this.attributes+ .filter(row => row.sourceId !== sourceId).map(row => this.treeCache.attributes[row.attributeId]).filter(attr => !!attr);}diff --git a/src/public/app/widgets/promoted_attributes.js b/src/public/app/widgets/promoted_attributes.jsindex 34a12b2224..f505df9151 100644--- a/src/public/app/widgets/promoted_attributes.js+++ b/src/public/app/widgets/promoted_attributes.js@@ -229,7 +229,7 @@ export default class PromotedAttributesWidget extends TabAwareWidget {.prop("title", "Remove this attribute").on('click', async () => {if (valueAttr.attributeId) {- await server.remove("notes/" + this.noteId + "/attributes/" + valueAttr.attributeId);+ await server.remove("notes/" + this.noteId + "/attributes/" + valueAttr.attributeId, this.componentId);}$tr.remove();@@ -263,13 +263,18 @@ export default class PromotedAttributesWidget extends TabAwareWidget {type: $attr.prop("attribute-type"),name: $attr.prop("attribute-name"),value: value- });+ }, this.componentId);$attr.prop("attribute-id", result.attributeId);}- entitiesReloadedEvent({loadResults}) {- if (loadResults.getAttributes().find(attr => attr.noteId === this.noteId)) {+ entitiesReloadedEvent({loadResults}) {console.log("loadResults", loadResults);+ // relation/label definitions are very often inherited by tree or template,+ // it's difficult to detect inheritance so we will+ if (loadResults.getAttributes(this.componentId).find(attr =>+ attr.noteId === this.noteId+ || ['label-definition', 'relation-definition'].includes(attr.type))) {+this.refresh();}}