summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2019-01-23 08:32:29 +0000
committerGéry Debongnie <ged@odoo.com>2019-01-30 10:45:11 +0000
commitad9f6aee93cc1674c4e02c1810d8a4fcb7804c6c (patch)
tree94c12aefcb9622b3e3c5bc47efc040e60abc432d /addons/web/static/src
parent1a774f9e0e9dbc67cf9661d6aa07f5ce5640d779 (diff)
[FIX] web: reload view when pressing enter in search bar
Before the control panel refactoring, whenever a user pressed ENTER in the search bar (with no text), the current view was reloaded. This untested behaviour was changed (not on purpose) with that refactoring: instead of reloading, the search view add a useless filter in the list of facets. We restore the previous behaviour in this commit. closes odoo/odoo#30503
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/control_panel/control_panel_controller.js9
-rw-r--r--addons/web/static/src/js/views/control_panel/search/search_bar.js5
-rw-r--r--addons/web/static/src/js/widgets/auto_complete.js5
3 files changed, 18 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/control_panel/control_panel_controller.js b/addons/web/static/src/js/views/control_panel/control_panel_controller.js
index 3d6e62f4bf9..10413e725ab 100644
--- a/addons/web/static/src/js/views/control_panel/control_panel_controller.js
+++ b/addons/web/static/src/js/views/control_panel/control_panel_controller.js
@@ -16,6 +16,7 @@ var ControlPanelController = mvc.Controller.extend({
new_groupBy: '_onNewGroupBy',
activate_time_range: '_onActivateTimeRange',
autocompletion_filter: '_onAutoCompletionFilter',
+ reload: '_onReload',
},
/**
@@ -229,6 +230,14 @@ var ControlPanelController = mvc.Controller.extend({
this.model.createNewGroupBy(ev.data);
this._reportNewQueryAndRender();
},
+ /**
+ * @private
+ * @param {OdooEvent} ev
+ */
+ _onReload: function (ev) {
+ ev.stopPropagation();
+ this.trigger_up('search', this.model.getQuery());
+ },
});
return ControlPanelController;
diff --git a/addons/web/static/src/js/views/control_panel/search/search_bar.js b/addons/web/static/src/js/views/control_panel/search/search_bar.js
index f9fa15fe67d..7f0feda4516 100644
--- a/addons/web/static/src/js/views/control_panel/search/search_bar.js
+++ b/addons/web/static/src/js/views/control_panel/search/search_bar.js
@@ -216,6 +216,11 @@ var SearchBar = Widget.extend({
this.trigger_up('facet_removed');
}
break;
+ case $.ui.keyCode.ENTER:
+ if (this.$input.val() === '') {
+ this.trigger_up('reload');
+ }
+ break;
}
},
});
diff --git a/addons/web/static/src/js/widgets/auto_complete.js b/addons/web/static/src/js/widgets/auto_complete.js
index a25dc0150f5..33405aa4196 100644
--- a/addons/web/static/src/js/widgets/auto_complete.js
+++ b/addons/web/static/src/js/widgets/auto_complete.js
@@ -55,7 +55,10 @@ return Widget.extend({
}
});
this.$input.on('keypress', function (ev) {
- self.search_string = self.search_string + String.fromCharCode(ev.which);
+ if (ev.which > 31 && ev.which !== 127) {
+ // we filter control character out of the search string
+ self.search_string = self.search_string + String.fromCharCode(ev.which);
+ }
if (self.search_string.length) {
self.searching = true;
var search_string = self.search_string;