partkeepr

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

commit 3d115792b354ece200f5209739890b0de588a300
parent 604f979e35c1bbb77f0c09f4283b3c1a867fba74
Author: Felicitus <felicitus@felicitus.org>
Date:   Sat, 14 Nov 2015 17:22:36 +0100

Defer the startSearch/resetSearch calls if the store is loading. This fixes an issue where the user tries to search for something and the grid is loading already, his search result might appear immediately and then being overwritten be the previous load operation due to the asyncronous nature of the ExtJS stores.

Diffstat:
Msrc/PartKeepr/FrontendBundle/Resources/public/js/form/field/SearchField.js | 26++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/form/field/SearchField.js b/src/PartKeepr/FrontendBundle/Resources/public/js/form/field/SearchField.js @@ -21,13 +21,19 @@ Ext.define('PartKeepr.form.field.SearchField', { } }, + /** + * @var {Boolean} Specifies if the search field has an active search + */ hasSearch: false, /** - * Defines the parameter name which is being passed to the store's proxy. + * @cfg {String} Specifies the target property to search */ targetField: 'query', + /** + * @var {Ext.util.Filter} The filter set by the search field + */ filter: null, listeners: { @@ -37,9 +43,6 @@ Ext.define('PartKeepr.form.field.SearchField', { } }, - /** - * Initializes the component. Binds the enter key to startSearch. - */ initComponent: function () { this.callParent(arguments); @@ -75,6 +78,11 @@ Ext.define('PartKeepr.form.field.SearchField', { var me = this, store = me.store; + if (store.isLoading()) { + Ext.defer(this.resetSearch, 200, this); + return; + } + me.setValue(''); if (me.hasSearch) { @@ -102,6 +110,11 @@ Ext.define('PartKeepr.form.field.SearchField', { return; } + if (store.isLoading()) { + Ext.defer(this.startSearch, 200, this); + return; + } + this.filter.setValue("%" + value + "%"); store.addFilter(this.filter); store.currentPage = 1; @@ -110,6 +123,11 @@ Ext.define('PartKeepr.form.field.SearchField', { me.hasSearch = true; this.getTrigger("clear").show(); }, + /** + * Sets the store to use + * + * @param {Ext.data.Store} store The store to set + */ setStore: function (store) { this.store = store;