diff --git a/public/js/pimcore/asset/asset.js b/public/js/pimcore/asset/asset.js index a3f202320c..597224ce10 100644 --- a/public/js/pimcore/asset/asset.js +++ b/public/js/pimcore/asset/asset.js @@ -365,6 +365,7 @@ pimcore.asset.asset = Class.create(pimcore.element.abstract, { } this.tab.mask(); + this.saving = true; const preSaveAsset = new CustomEvent(pimcore.events.preSaveAsset, { detail: { @@ -377,6 +378,7 @@ pimcore.asset.asset = Class.create(pimcore.element.abstract, { const isAllowed = document.dispatchEvent(preSaveAsset); if (!isAllowed) { this.tab.unmask(); + this.saving = false; return false; } @@ -432,6 +434,9 @@ pimcore.asset.asset = Class.create(pimcore.element.abstract, { failure: function () { this.tab.unmask(); }.bind(this), + callback: function (){ + this.saving = false; + }.bind(this), params: params }); }, diff --git a/public/js/pimcore/document/document.js b/public/js/pimcore/document/document.js index a84adac034..62ca67e35b 100644 --- a/public/js/pimcore/document/document.js +++ b/public/js/pimcore/document/document.js @@ -87,6 +87,11 @@ pimcore.document.document = Class.create(pimcore.element.abstract, { return; } + if (this.saveInProgress()){ + pimcore.helpers.showNotification(t("warning"), t("Another saving process is in progress, please wait and retry again"), "info"); + return; + } + if(typeof task !== 'string') { task = ''; } @@ -112,9 +117,12 @@ pimcore.document.document = Class.create(pimcore.element.abstract, { cancelable: true }); + this.saving = true; + const isAllowed = document.dispatchEvent(preSaveDocument); if (!isAllowed) { this.tab.unmask(); + this.saving = false; return false; } @@ -188,6 +196,9 @@ pimcore.document.document = Class.create(pimcore.element.abstract, { failure: function () { this.tab.unmask(); }.bind(this), + callback: function (){ + this.saving = false; + }.bind(this), }); } else { this.tab.unmask(); diff --git a/public/js/pimcore/element/abstract.js b/public/js/pimcore/element/abstract.js index 23ea7274c9..fd41e943ae 100644 --- a/public/js/pimcore/element/abstract.js +++ b/public/js/pimcore/element/abstract.js @@ -18,6 +18,7 @@ pimcore.registerNS("pimcore.element.abstract"); pimcore.element.abstract = Class.create({ dirty: false, + saving: false, /** * if allowDirtyClose is true, a tab can be closed whether @@ -244,6 +245,10 @@ pimcore.element.abstract = Class.create({ } }, + saveInProgress: function(){ + return this.saving; + }, + setAddToHistory: function (addToHistory) { this.addToHistory = addToHistory; }, diff --git a/public/js/pimcore/object/object.js b/public/js/pimcore/object/object.js index 8a9f92d7fb..54ce4b96af 100644 --- a/public/js/pimcore/object/object.js +++ b/public/js/pimcore/object/object.js @@ -765,7 +765,6 @@ pimcore.object.object = Class.create(pimcore.object.abstract, { }, save: function (task, only, callback, successCallback) { - var omitMandatoryCheck = false; // unpublish and save version is possible without checking mandatory fields @@ -776,6 +775,10 @@ pimcore.object.object = Class.create(pimcore.object.abstract, { if (this.tab.disabled || (this.tab.isMasked() && task != 'autoSave')) { return; } + if (this.saveInProgress()){ + pimcore.helpers.showNotification(t("warning"), t("Another saving process is in progress, please wait and retry again"), "info"); + return; + } if(task != 'autoSave'){ this.tab.mask(); @@ -797,9 +800,11 @@ pimcore.object.object = Class.create(pimcore.object.abstract, { const isAllowed = document.dispatchEvent(preSaveObject); if (!isAllowed) { this.tab.unmask(); + this.saving = false; return false; } + this.saving = true; Ext.Ajax.request({ url: Routing.generate('pimcore_admin_dataobject_dataobject_save', {task: task}), method: "PUT", @@ -882,6 +887,9 @@ pimcore.object.object = Class.create(pimcore.object.abstract, { }.bind(this), failure: function (response) { this.tab.unmask(); + }.bind(this), + callback: function (){ + this.saving = false; }.bind(this) });