From 68d4406cc7c99987f8d52870e75fa7744b78c92d Mon Sep 17 00:00:00 2001 From: Francesco Boccacci Date: Fri, 29 Mar 2024 16:29:17 +0100 Subject: [PATCH] :bug: handle editing toolbox state emit state of toolbox to disable/enable close editing panel (#106) --- components/Editing.vue | 19 +++++++++++++------ components/Toolbox.vue | 9 ++++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/components/Editing.vue b/components/Editing.vue index c35daab5..727786b8 100644 --- a/components/Editing.vue +++ b/components/Editing.vue @@ -96,6 +96,7 @@ @savetoolbox = "saveToolBox" @setactivetool = "startActiveTool" @stopactivetool = "stopActiveTool" + @on-editing = "updateLayersInEditing" /> @@ -116,7 +117,7 @@ data() { return { - saving: false, // whether to show loading bar while committing to server (click on save disk icon) + saving: false, // whether to show loading bar while committing to server (click on save disk icon) layersInEditing: 0, //@since 3.8.0 Number of layers in editing }; }, @@ -131,6 +132,14 @@ }, methods: { + /** + * Method that handle editing state of toolbox layer + * @since 3.8.0 + * @param bool + */ + updateLayersInEditing(bool) { + this.layersInEditing += bool ? 1 : -1; + }, undo() { this.$options.service.undo(); @@ -161,11 +170,11 @@ async startToolBox(toolboxId) { const toolbox = this._getToolBoxById(toolboxId); if (ApplicationState.online && toolbox.canEdit()) { - //check if a dependency layer (in relation) has some changes not commietd + //check if a dependency layer (in relation) has some changes not committed const dirtyId = toolbox.getDependencies() .find(id => this._getToolBoxById(id).isDirty()); if (dirtyId) { - //if there is a layer with not saved/committed changes ask before get start toolbox + //if there is a layer with not saved/committed changes ask before get start toolbox, //otherwise changes made on relation layers are not sync with current database state //example Joins 1:1 fields try { await this.$options.service.commitDirtyToolBoxes(dirtyId); } @@ -173,7 +182,6 @@ } toolbox .start() - .then(() => this.layersInEditing++) } }, @@ -185,11 +193,10 @@ if (toolbox.state.editing.history.commit) { this.$options.service .commit() - .always(() => toolbox.stop().then(() => this.layersInEditing--)); + .always(() => toolbox.stop()); } else { toolbox .stop() - .then(() => this.layersInEditing--) } }, diff --git a/components/Toolbox.vue b/components/Toolbox.vue index 2dc73e80..4a9e4190 100644 --- a/components/Toolbox.vue +++ b/components/Toolbox.vue @@ -346,10 +346,17 @@ watch: { - async'state.activetool'(activetool) { + async 'state.activetool'(activetool) { await this.$nextTick(); this.currenttoolhelpmessage = activetool && activetool.getHelpMessage(); }, + /** + * Method to watch toolbox in editing state + * @param bool + */ + 'state.editing.on'(bool) { + this.$emit('on-editing', bool); + } },