From 0bd4861275cdb155de333aba9f53a34f46553ea4 Mon Sep 17 00:00:00 2001 From: Elena Poelman Date: Tue, 8 Nov 2022 16:34:44 +0100 Subject: [PATCH 1/2] disable 'insert statement' button if there is not besluit present --- .../regulatory-statements/sidebar-insert.hbs | 2 +- .../regulatory-statements/sidebar-insert.js | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/components/editor-plugins/regulatory-statements/sidebar-insert.hbs b/app/components/editor-plugins/regulatory-statements/sidebar-insert.hbs index 2944b7752..d4343dfc9 100644 --- a/app/components/editor-plugins/regulatory-statements/sidebar-insert.hbs +++ b/app/components/editor-plugins/regulatory-statements/sidebar-insert.hbs @@ -1,5 +1,5 @@ - + {{t "regulatoryStatementsPlugin.insertStatement"}} diff --git a/app/components/editor-plugins/regulatory-statements/sidebar-insert.js b/app/components/editor-plugins/regulatory-statements/sidebar-insert.js index d361ddbd7..cdc4ab520 100644 --- a/app/components/editor-plugins/regulatory-statements/sidebar-insert.js +++ b/app/components/editor-plugins/regulatory-statements/sidebar-insert.js @@ -10,15 +10,22 @@ export default class RegulatoryStatementsSidebarInsertComponent extends Componen this.modalEnabled = !this.modalEnabled; } - @action - insertRegulatoryStatement(statement) { - this.modalEnabled = false; - const besluit = this.args.controller.datastore + get besluit() { + return this.args.controller.datastore .match(null, 'a', `besluit:Besluit`) .asSubjectNodes() .next().value; - if (besluit) { - const besluitNode = [...besluit.nodes][0]; + } + + get isDisabled() { + return !this.besluit; + } + + @action + insertRegulatoryStatement(statement) { + this.modalEnabled = false; + if (this.besluit) { + const besluitNode = [...this.besluit.nodes][0]; const range = this.args.controller.rangeFactory.fromInNode( besluitNode, besluitNode.getMaxOffset() From 7f4139beb589497a9a117b941a97a7a52a519d64 Mon Sep 17 00:00:00 2001 From: Elena Poelman Date: Mon, 14 Nov 2022 10:03:39 +0100 Subject: [PATCH 2/2] change way in how we determine whether the 'insert statement' button should be disabled --- .../regulatory-statements/sidebar-insert.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/components/editor-plugins/regulatory-statements/sidebar-insert.js b/app/components/editor-plugins/regulatory-statements/sidebar-insert.js index cdc4ab520..8596f4821 100644 --- a/app/components/editor-plugins/regulatory-statements/sidebar-insert.js +++ b/app/components/editor-plugins/regulatory-statements/sidebar-insert.js @@ -3,22 +3,27 @@ import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; export default class RegulatoryStatementsSidebarInsertComponent extends Component { + @tracked isDisabled = false; @tracked modalEnabled = false; + @tracked besluit; - @action - toggleModal() { - this.modalEnabled = !this.modalEnabled; + constructor() { + super(...arguments); + this.args.controller.onEvent('contentChanged', this.update.bind(this)); + this.update(); } - get besluit() { - return this.args.controller.datastore + update() { + this.besluit = this.args.controller.datastore .match(null, 'a', `besluit:Besluit`) .asSubjectNodes() .next().value; + this.isDisabled = !this.besluit; } - get isDisabled() { - return !this.besluit; + @action + toggleModal() { + this.modalEnabled = !this.modalEnabled; } @action