diff --git a/src/entities/attribute.js b/src/entities/attribute.js index 0800d6252..0e36921db 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.js index 2cf844420..c588e51f5 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.js index 89965e8f3..7153b2e9a 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.js index 34a12b222..f505df915 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(); } }