partkeepr

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

commit b4e16fa20b6e204c78d0dc588821192e3de44557
parent 1cf520f6433dd4d14785a7791a6efe6ab67cc47c
Author: Felicitus <felicitus@felicitus.org>
Date:   Tue, 10 Jan 2012 16:33:59 +0100

Added a second isValid() call since it is not sure that the store is loaded before we start editing or vice versa.

Diffstat:
Msrc/frontend/js/Components/Part/Editor/PartEditor.js | 30++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/frontend/js/Components/Part/Editor/PartEditor.js b/src/frontend/js/Components/Part/Editor/PartEditor.js @@ -26,6 +26,24 @@ Ext.define('PartKeepr.PartEditor', { labelWidth: 150 }); + this.storageLocationComboBox = Ext.create("PartKeepr.StorageLocationComboBox", + { + fieldLabel: i18n("Storage Location"), + name: 'storageLocation', + allowBlank: false, + labelWidth: 150 + }); + + this.storageLocationComboBox.store.on("load", function () { + // Re-trigger validation because of asynchronous loading of the storage location field, + // which would be marked invalid because validation happens immediately, but after loading + // the storage locations, the field is valid, but not re-validated. + + // This workaround is done twice; once after the store is loaded and once when we start editing, + // because we don't know which event will come first + this.getForm().isValid(); + }, this); + // Defines the basic editor fields var basicEditorFields = [ this.nameField, @@ -55,12 +73,9 @@ Ext.define('PartKeepr.PartEditor', { xtype: 'CategoryComboBox', fieldLabel: i18n("Category"), name: 'category' - },{ - xtype: 'StorageLocationComboBox', - fieldLabel: i18n("Storage Location"), - name: 'storageLocation', - allowBlank: false - },{ + }, + this.storageLocationComboBox, + { xtype: 'FootprintComboBox', fieldLabel: i18n("Footprint"), name: 'footprint' @@ -202,6 +217,9 @@ Ext.define('PartKeepr.PartEditor', { // Re-trigger validation because of asynchronous loading of the storage location field, // which would be marked invalid because validation happens immediately, but after loading // the storage locations, the field is valid, but not re-validated. + + // This workaround is done twice; once after the store is loaded and once when we start editing, + // because we don't know which event will come first this.getForm().isValid(); }, _onItemSaved: function () {