summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/search_panel.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2019-09-10 13:30:38 +0000
committerAaron Bohy <aab@odoo.com>2019-09-16 07:29:43 +0000
commit127be68cca0693b37a7213204c497c968d4f56db (patch)
tree3e67810a223fac87b910d748f9009935d16f9a91 /addons/web/static/src/js/views/search_panel.js
parent2500db4213109465c8489d03e5e98d977a443df0 (diff)
[FIX] web: do not disable searchpanel on button clicked
Before this rev., the searchpanel was automatically disabled (not present) in actions obtained by following links or buttons (e.g. stat buttons). This rev. removes this constraint, but adds the possibiliy to disable it by setting key 'search_panel' to false in the context. Note that in this case, the active categories are never retrieved from the local storage (i.e. the last one set). If no default is given, 'All' is simply selected (no domain). Task 2069310
Diffstat (limited to 'addons/web/static/src/js/views/search_panel.js')
-rw-r--r--addons/web/static/src/js/views/search_panel.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/search_panel.js b/addons/web/static/src/js/views/search_panel.js
index 32bfda12594..d222a5642cf 100644
--- a/addons/web/static/src/js/views/search_panel.js
+++ b/addons/web/static/src/js/views/search_panel.js
@@ -77,6 +77,9 @@ var SearchPanel = Widget.extend({
* @param {Object} params
* @param {Object} [params.defaultValues={}] the value(s) to activate by
* default, for each filter and category
+ * @param {boolean} [params.defaultNoFilter=false] if true, select 'All' as
+ * value for each category that has no value specified in defaultValues
+ * (instead of looking in the localStorage for the last selected value)
* @param {Object} params.fields
* @param {string} params.model
* @param {Array[]} params.searchDomain domain coming from controlPanel
@@ -97,6 +100,12 @@ var SearchPanel = Widget.extend({
this.initialState = params.state;
this.scrollTop = this.initialState && this.initialState.scrollTop || null;
this.defaultValues = params.defaultValues || {};
+ if (params.defaultNoFilter) {
+ Object.keys(this.categories).forEach((categoryId) => {
+ var fieldName = this.categories[categoryId].fieldName;
+ this.defaultValues[fieldName] = this.defaultValues[fieldName] || false;
+ });
+ }
this.fields = params.fields;
this.model = params.model;
this.className = params.classes.concat(['o_search_panel']).join(' ');
@@ -181,7 +190,7 @@ var SearchPanel = Widget.extend({
return {
sections: searchPanelSections,
classes: classes,
- }
+ };
},
/**
* Export the current state (categories and filters) of the searchpanel.
@@ -293,7 +302,6 @@ var SearchPanel = Widget.extend({
// set active value
var validValues = _.pluck(category.values, 'id').concat([false]);
var value = this._getCategoryDefaultValue(category, validValues);
- // if not set in localStorage either, select 'All'
category.activeValueId = _.contains(validValues, value) ? value : false;
// unfold ancestor values of active value to make it is visible