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
fix saving & refreshing attributes across compoments
zadamae909d107941
diff --git a/src/public/app/widgets/attribute_editor.js b/src/public/app/widgets/attribute_editor.jsindex 8f97a986cb..0418480baf 100644--- a/src/public/app/widgets/attribute_editor.js+++ b/src/public/app/widgets/attribute_editor.js@@ -432,4 +432,10 @@ export default class AttributeEditorWidget extends TabAwareWidget {updateAttributeList(attributes) {this.renderOwnedAttributes(attributes, false);}++ entitiesReloadedEvent({loadResults}) {+ if (loadResults.getAttributes(this.componentId).find(attr => attr.isAffecting(this.note))) {+ this.refresh();+ }+ }}diff --git a/src/public/app/widgets/attribute_list.js b/src/public/app/widgets/attribute_list.jsindex bb5d4c3a98..b8a0037714 100644--- a/src/public/app/widgets/attribute_list.js+++ b/src/public/app/widgets/attribute_list.js@@ -162,9 +162,10 @@ export default class AttributeListWidget extends TabAwareWidget {}async refreshWithNote(note) {- const hasPromotedAttrs = this.promotedAttributesWidget.getPromotedAttributes().length > 0;+ const hasPromotedAttrs = this.promotedAttributesWidget.getPromotedDefinitionAttributes().length > 0;if (hasPromotedAttrs) {+ this.$promotedExpander.show();this.$allAttrWrapper.toggle(options.is('promotedAttributesExpanded'));this.$ownedAndInheritedWrapper.hide();this.$inheritedAttributesWrapper.hide();diff --git a/src/public/app/widgets/collapsible_widgets/calendar.js b/src/public/app/widgets/collapsible_widgets/calendar.jsindex 63913f7e49..da7746026a 100644--- a/src/public/app/widgets/collapsible_widgets/calendar.js+++ b/src/public/app/widgets/collapsible_widgets/calendar.js@@ -10,9 +10,7 @@ const TPL = `<div class="calendar-header"><button class="calendar-btn bx bx-left-arrow-alt" data-calendar-toggle="previous"></button>- <div class="calendar-header-label" data-calendar-label="month">- March 2017- </div>+ <div class="calendar-header-label" data-calendar-label="month"></div><button class="calendar-btn bx bx-right-arrow-alt" data-calendar-toggle="next"></button></div>@@ -161,4 +159,4 @@ export default class CalendarWidget extends CollapsibleWidget {'December'][monthIndex];}-}\ No newline at end of file+}diff --git a/src/public/app/widgets/promoted_attributes.js b/src/public/app/widgets/promoted_attributes.jsindex b89730342e..9fc8414bd3 100644--- a/src/public/app/widgets/promoted_attributes.js+++ b/src/public/app/widgets/promoted_attributes.js@@ -43,26 +43,26 @@ export default class PromotedAttributesWidget extends TabAwareWidget {async refreshWithNote(note) {this.$container.empty();- const promotedAttributes = this.getPromotedAttributes();- const attributes = note.getAttributes();+ const promotedDefAttrs = this.getPromotedDefinitionAttributes();+ const ownedAttributes = note.getOwnedAttributes();- const cells = [];-- if (promotedAttributes.length === 0) {+ if (promotedDefAttrs.length === 0) {this.toggleInt(false);return;}- for (const definitionAttr of promotedAttributes) {- const definitionType = definitionAttr.name.startsWith('label:') ? 'label' : 'relation';- const valueName = definitionAttr.name.substr(definitionType.length + 1);+ const cells = [];++ for (const definitionAttr of promotedDefAttrs) {+ const valueType = definitionAttr.name.startsWith('label:') ? 'label' : 'relation';+ const valueName = definitionAttr.name.substr(valueType.length + 1);- let valueAttrs = attributes.filter(el => el.name === valueName && el.type === definitionType);+ let valueAttrs = ownedAttributes.filter(el => el.name === valueName && el.type === valueType);if (valueAttrs.length === 0) {valueAttrs.push({attributeId: "",- type: definitionType,+ type: valueType,name: valueName,value: ""});@@ -85,7 +85,7 @@ export default class PromotedAttributesWidget extends TabAwareWidget {this.toggleInt(true);}- getPromotedAttributes() {+ getPromotedDefinitionAttributes() {if (this.note.hasLabel('hidePromotedAttributes')) {return [];}diff --git a/src/public/stylesheets/calendar.css b/src/public/stylesheets/calendar.cssindex f3e3dadb54..8190a12783 100755--- a/src/public/stylesheets/calendar.css+++ b/src/public/stylesheets/calendar.css@@ -61,6 +61,7 @@.calendar-widget .calendar-date {align-items: center;+ color: var(--main-text-color);background-color: var(--main-background-color);display: flex;flex-direction: column;@@ -90,4 +91,4 @@.calendar-widget .calendar-date:not(.calendar-date-active) {cursor: pointer;-}\ No newline at end of file+}diff --git a/src/routes/api/attributes.js b/src/routes/api/attributes.jsindex a7246d08ab..64ebc53de9 100644--- a/src/routes/api/attributes.js+++ b/src/routes/api/attributes.js@@ -89,7 +89,7 @@ function updateNoteAttributes(req) {const note = repository.getNote(noteId);- let existingAttrs = note.getAttributes();+ let existingAttrs = note.getOwnedAttributes();let position = 0;diff --git a/src/services/note_cache/note_cache_loader.js b/src/services/note_cache/note_cache_loader.jsindex 8fc4e74d48..1d0f17342c 100644--- a/src/services/note_cache/note_cache_loader.js+++ b/src/services/note_cache/note_cache_loader.js@@ -121,7 +121,10 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED}delete noteCache.attributes[attributeId];- delete noteCache.attributeIndex[`${attr.type}-${attr.name}`];++ if (attr) {+ delete noteCache.attributeIndex[`${attr.type}-${attr.name}`];+ }}else if (attributeId in noteCache.attributes) {const attr = noteCache.attributes[attributeId];