diff --git a/static/plugin_dbui/src/directstore.js b/static/plugin_dbui/src/directstore.js index 145891a9951446df2dee9ab0e1a611c22d55d255..ebfc0468fc00272d1201eb8469a2b1e74c058172 100644 --- a/static/plugin_dbui/src/directstore.js +++ b/static/plugin_dbui/src/directstore.js @@ -40,15 +40,6 @@ Ext.define('App.data.DirectStore', { var proxy; - /* - // keep a copy of the initial where condition - if (cfg.baseParams.hasOwnProperty('where')) { - cfg.initialWhere = []; - for (i = 0; i < cfg.baseParams.where.length; i += 1) { - cfg.initialWhere.push(cfg.baseParams.where[i]); - } - } - */ // the proxy if (!config.proxy) { proxy = { @@ -58,6 +49,14 @@ Ext.define('App.data.DirectStore', { config.proxy = proxy; } + // copy of the initial where condition + if (this.extraParams && this.extraParams.where) { + this.initialWhere = []; + for (i = 0; i < this.extraParams.where.length; i += 1) { + this.initialWhere.push(this.extraParams.where[i]); + } + } + // initialise the base class this.callParent(arguments); @@ -76,16 +75,19 @@ Ext.define('App.data.DirectStore', { }, /** - * Handler to update the total number of records after a write action + * Handler to update the total number of records after a write action. + * * @param {Ext.data.Store} store - * @param {String} action - * Understood action are *create* and *destroy*. + * @param {Ext.data.Operation} operation + * Understood action are *create* and *destroy* + * @param {Object} eOpts + * */ - onWrite: function (store, action) { + onWrite: function (store, operation, eOpts) { "use strict"; - switch (action) { + switch (operation.action) { case 'create': store.totalLength += 1; break; @@ -106,16 +108,16 @@ Ext.define('App.data.DirectStore', { var i; - if (this.baseParams.hasOwnProperty('where')) { + if (this.extraParams.where) { if (this.initialWhere) { - this.baseParams.where = []; + this.extraParams.where = []; for (i = 0; i < this.initialWhere.length; i += 1) { - this.baseParams.where.push(this.initialWhere[i]); + this.extraParams.where.push(this.initialWhere[i]); } } else { - delete this.baseParams.where; + delete this.extraParams.where; } } } diff --git a/static/plugin_dbui/src/gridfilter.js b/static/plugin_dbui/src/gridfilter.js index 5707dd3b074fa7e60db068bbc0d4c2ec38f825b6..dc759c604a8879a1969ee5e61d3343521b6d730a 100644 --- a/static/plugin_dbui/src/gridfilter.js +++ b/static/plugin_dbui/src/gridfilter.js @@ -223,7 +223,13 @@ Ext.define('App.grid.GridFilter', { } // push new condition in the where clause of the store - this.store.baseParams.where = conditions; + if (conditions.length) { + this.store.extraParams.where = conditions; + + // go back to the initial where setting when conditions are empty + } else { + this.store.restoreWhere(); + } }, // private method to load the store applying filter conditions