From 5b68d6475bf42990a2ed1ecd59fadb4c261191b2 Mon Sep 17 00:00:00 2001 From: John Holt Date: Wed, 6 Sep 2023 12:47:52 +0100 Subject: [PATCH] Use loading state to avoid double click --- client/src/js/app/store/store.js | 3 ++- .../modules/types/mx/shipment/views/container-mixin.js | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/js/app/store/store.js b/client/src/js/app/store/store.js index 6d851acab..6f29dc340 100644 --- a/client/src/js/app/store/store.js +++ b/client/src/js/app/store/store.js @@ -367,7 +367,8 @@ const store = new Vuex.Store({ oidcId: state => state.auth.oidcId, apiUrl: state => state.apiUrl, appUrl: state => state.appUrl, - getAppOptions: state => state.appOptions + getAppOptions: state => state.appOptions, + isLoading: state => state.isLoading, } }) diff --git a/client/src/js/modules/types/mx/shipment/views/container-mixin.js b/client/src/js/modules/types/mx/shipment/views/container-mixin.js index 6dda7d40f..f622ac683 100644 --- a/client/src/js/modules/types/mx/shipment/views/container-mixin.js +++ b/client/src/js/modules/types/mx/shipment/views/container-mixin.js @@ -318,13 +318,16 @@ export default { // Save the sample to the server via backbone model // Location should be the sample LOCATION async onSaveSample(location) { - try { + if (this.$store.getters.isLoading) { // avoid double click + return + } + try { this.$store.commit('loading', true) const result = await this.$refs.containerForm.validate() if (result) { - const samplesRef = this.$refs.samples - samplesRef.$refs[`sample-row-${location}`][0].closeSampleEditing() await this.saveSample(location) + const samplesRef = this.$refs.samples + samplesRef.$refs[`sample-row-${location}`][0].closeSampleEditing() this.$refs.containerForm.reset() } else {