partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 04eb513594a65d8076e1521ba8f18726213493a7
parent b4e16fa20b6e204c78d0dc588821192e3de44557
Author: Felicitus <felicitus@felicitus.org>
Date:   Tue, 10 Jan 2012 16:54:23 +0100

Disable the save button when sending a request. Fixes issue #64 but maybe not in every spot. Reopen if there is any editor which doesn't make use of this mechanism

Diffstat:
Msrc/frontend/js/Components/Editor/Editor.js | 13+++++++++++++
Msrc/frontend/js/Components/Part/Editor/PartEditor.js | 7-------
Msrc/frontend/js/Components/Part/Editor/PartEditorWindow.js | 18++++++++++++++++++
3 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/src/frontend/js/Components/Editor/Editor.js b/src/frontend/js/Components/Editor/Editor.js @@ -100,6 +100,14 @@ Ext.define('PartKeepr.Editor', { } }, onItemSave: function () { + // Disable the save button to indicate progress + if (this.enableButtons) { + this.saveButton.disable(); + + // Sanity: If the save process fails, re-enable the button after 30 seconds + Ext.defer(function () { this.saveButton.enable(); }, 30000, this); + } + this.getForm().updateRecord(this.record); this.record.save({ callback: this._onSave, @@ -107,6 +115,11 @@ Ext.define('PartKeepr.Editor', { }); }, _onSave: function (record, response) { + if (this.enableButtons) { + // Re-enable the save button + this.saveButton.enable(); + } + if (response.success === true) { this.record = record; this.fireEvent("itemSaved", this.record); diff --git a/src/frontend/js/Components/Part/Editor/PartEditor.js b/src/frontend/js/Components/Part/Editor/PartEditor.js @@ -238,13 +238,6 @@ Ext.define('PartKeepr.PartEditor', { this.partParameterGrid.bindStore(this.record.parameters()); this.partAttachmentGrid.bindStore(this.record.attachments()); }, - onItemSave: function () { - if (!this.getForm().isValid()) { - return; - } - - this.callParent(); - }, _setTitle: function (title) { var tmpTitle; diff --git a/src/frontend/js/Components/Part/Editor/PartEditorWindow.js b/src/frontend/js/Components/Part/Editor/PartEditorWindow.js @@ -49,6 +49,7 @@ Ext.define('PartKeepr.PartEditorWindow', { this.editor.on("editorClose", function (context) { this.close();}, this, { delay: 200 }); this.editor.on("titleChange", function (val) { this.setTitle(val); }, this); + this.editor.on("itemSaved", this.onItemSaved, this); this.saveButton = Ext.create("Ext.button.Button", { text: this.saveText, @@ -88,7 +89,24 @@ Ext.define('PartKeepr.PartEditorWindow', { onCancelEdit: function () { this.editor.onCancelEdit(); }, + /** + * Called when the save button was clicked + */ onItemSave: function () { + if (!this.editor.getForm().isValid()) { return; } + + // Disable the save button to indicate progress + this.saveButton.disable(); + + // Sanity: If the save process fails, re-enable the button after 30 seconds + Ext.defer(function () { this.saveButton.enable(); }, 30000, this); + this.editor.onItemSave(); + }, + /** + * Called when the item was saved + */ + onItemSaved: function () { + this.saveButton.enable(); } });