From f21c80d9606c98bf322e036d9b3539a1b7549d0b Mon Sep 17 00:00:00 2001 From: McMatts Date: Thu, 26 Apr 2018 12:01:58 +0100 Subject: [PATCH] Revert section title change on cancel operation --- gui/app/components/section/base-editor-inline.js | 12 +++++++++--- .../components/section/base-editor-inline.hbs | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gui/app/components/section/base-editor-inline.js b/gui/app/components/section/base-editor-inline.js index 2971172c..a7459701 100644 --- a/gui/app/components/section/base-editor-inline.js +++ b/gui/app/components/section/base-editor-inline.js @@ -27,10 +27,16 @@ export default Component.extend(TooltipMixin, ModalMixin, { return `page-editor-${page.id}`; }), previewText: 'Preview', + pageTitle: '', + + didReceiveAttrs() { + this._super(...arguments); + this.set('pageTitle', this.get('page.title')); + }, didRender() { this._super(...arguments); - + let msContainer = document.getElementById('section-editor-' + this.get('containerId')); let mousetrap = this.get('mousetrap'); if (is.null(mousetrap)) { @@ -69,7 +75,7 @@ export default Component.extend(TooltipMixin, ModalMixin, { actions: { onAction() { - if (this.get('busy') || is.empty(this.get('page.title'))) { + if (this.get('busy') || is.empty(this.get('pageTitle'))) { return; } @@ -78,7 +84,7 @@ export default Component.extend(TooltipMixin, ModalMixin, { } let cb = this.get('onAction'); - cb(this.get('page.title')); + cb(this.get('pageTitle')); }, onCancel() { diff --git a/gui/app/templates/components/section/base-editor-inline.hbs b/gui/app/templates/components/section/base-editor-inline.hbs index be607498..fc329496 100644 --- a/gui/app/templates/components/section/base-editor-inline.hbs +++ b/gui/app/templates/components/section/base-editor-inline.hbs @@ -3,14 +3,14 @@
{{#if blockMode}}
- {{focus-input id="page-id-{{pageId}}" value=page.title class=(if hasNameError 'form-control mousetrap form-control-lg edit-title is-invalid' 'form-control form-control-lg edit-title mousetrap') placeholder="Enter name"}} + {{focus-input id="page-id-{{pageId}}" value=pageTitle class=(if hasNameError 'form-control mousetrap form-control-lg edit-title is-invalid' 'form-control form-control-lg edit-title mousetrap') placeholder="Enter name"}}
{{textarea id="page-excerpt-{{pageId}}" value=page.excerpt rows="2" class=(if hasDescError 'form-control mousetrap form-control-lg edit-title is-invalid' 'form-control form-control-lg edit-title mousetrap') placeholder="Enter description"}}
{{else}}
- {{focus-input type="text" id=pageId value=page.title class=(if hasNameError 'form-control mousetrap form-control-lg edit-title is-invalid' 'form-control form-control-lg edit-title mousetrap') placeholder="Enter name"}} + {{focus-input type="text" id=pageId value=pageTitle class=(if hasNameError 'form-control mousetrap form-control-lg edit-title is-invalid' 'form-control form-control-lg edit-title mousetrap') placeholder="Enter name"}}
{{/if}}