From 9d46c7253b1e879d9424514e7a3deceb0a205ae0 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 18 Jul 2020 00:20:24 +0200 Subject: [PATCH] fixes in saving --- src/public/app/widgets/attribute_editor.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/public/app/widgets/attribute_editor.js b/src/public/app/widgets/attribute_editor.js index 018967198..80c0054be 100644 --- a/src/public/app/widgets/attribute_editor.js +++ b/src/public/app/widgets/attribute_editor.js @@ -53,7 +53,7 @@ const TPL = `
-
+
@@ -200,6 +200,8 @@ export default class AttributeEditorWidget extends TabAwareWidget { this.attributeDetailWidget.hide(); }); + this.$editor.on('blur', () => this.save()); + this.$addNewAttributeButton = this.$widget.find('.add-new-attribute-button'); this.$addNewAttributeButton.on('click', e => this.addNewAttribute(e)); @@ -257,7 +259,7 @@ export default class AttributeEditorWidget extends TabAwareWidget { isInheritable: false }); - await this.renderOwnedAttributes(attrs); + await this.renderOwnedAttributes(attrs, false); this.$editor.scrollTop(this.$editor[0].scrollHeight); @@ -398,10 +400,10 @@ export default class AttributeEditorWidget extends TabAwareWidget { } async refreshWithNote(note) { - await this.renderOwnedAttributes(note.getOwnedAttributes()); + await this.renderOwnedAttributes(note.getOwnedAttributes(), true); } - async renderOwnedAttributes(ownedAttributes, ) { + async renderOwnedAttributes(ownedAttributes, saved) { const $attributesContainer = $("
"); for (const attribute of ownedAttributes) { @@ -410,9 +412,11 @@ export default class AttributeEditorWidget extends TabAwareWidget { this.textEditor.setData($attributesContainer.html()); - this.lastSavedContent = this.textEditor.getData(); + if (saved) { + this.lastSavedContent = this.textEditor.getData(); - this.$saveAttributesButton.fadeOut(0); + this.$saveAttributesButton.fadeOut(0); + } } async focusOnAttributesEvent({tabId}) { @@ -422,6 +426,6 @@ export default class AttributeEditorWidget extends TabAwareWidget { } updateAttributeList(attributes) { - this.renderOwnedAttributes(attributes); + this.renderOwnedAttributes(attributes, false); } }