diff options
| author | Jakub HrubĂ˝ <jakub@jhruby.cz> | 2019-06-03 12:50:06 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-06-18 10:13:39 +0000 |
| commit | 36abc4641cd0a223c537ddf9018008f73f07724a (patch) | |
| tree | e9284a3878d4d61e0ca9a1b2b6dac314af05bf85 /addons | |
| parent | 0c302e30a031ac22ad7e5470c5ed51af2c2b71e2 (diff) | |
[FIX] web: keep the search options visibility state
The search buttons visibility is saved in the local storage. Rev.
6448420 changed the API of the LocalStorage servive (by JSON
parsing the values), and didn't adapt the calls done for the
search buttons.
Closes #33833
closes odoo/odoo#34206
Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/web/static/src/js/views/search/search_view.js | 4 | ||||
| -rw-r--r-- | addons/web/static/tests/views/search_view_tests.js | 42 |
2 files changed, 44 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/search/search_view.js b/addons/web/static/src/js/views/search/search_view.js index 69a45649793..ec18b89c943 100644 --- a/addons/web/static/src/js/views/search/search_view.js +++ b/addons/web/static/src/js/views/search/search_view.js @@ -304,7 +304,7 @@ var SearchView = Widget.extend({ 'click .o_searchview_more': function (e) { $(e.target).toggleClass('fa-search-plus fa-search-minus'); var visibleSearchMenu = this.call('local_storage', 'getItem', 'visible_search_menu'); - this.call('local_storage', 'setItem', 'visible_search_menu', visibleSearchMenu !== 'true'); + this.call('local_storage', 'setItem', 'visible_search_menu', visibleSearchMenu === false); this.toggle_buttons(); }, 'keydown .o_searchview_input, .o_searchview_facet': function (e) { @@ -395,7 +395,7 @@ var SearchView = Widget.extend({ this.timeRanges = options.action && options.action.context ? options.action.context.time_ranges : undefined; var visibleSearchMenu = this.call('local_storage', 'getItem', 'visible_search_menu'); - this.visible_filters = (visibleSearchMenu !== 'false'); + this.visible_filters = (visibleSearchMenu !== false); this.input_subviews = []; // for user input in searchbar this.search_defaults = this.options.search_defaults || {}; this.headless = this.options.hidden && _.isEmpty(this.search_defaults); diff --git a/addons/web/static/tests/views/search_view_tests.js b/addons/web/static/tests/views/search_view_tests.js index 6281236e74b..a2698a5ede3 100644 --- a/addons/web/static/tests/views/search_view_tests.js +++ b/addons/web/static/tests/views/search_view_tests.js @@ -1,7 +1,9 @@ odoo.define('web.search_view_tests', function (require) { "use strict"; +var AbstractStorageService = require('web.AbstractStorageService'); var FormView = require('web.FormView'); +var RamStorage = require('web.RamStorage'); var testUtils = require('web.test_utils'); var testUtilsDom = require('web.test_utils_dom'); var createActionManager = testUtils.createActionManager; @@ -1087,5 +1089,45 @@ QUnit.module('Search View', { form.destroy(); }); + QUnit.module('Misc'); + + QUnit.test('search buttons visibility is stored in/retrieved from local storage', async function (assert) { + assert.expect(9); + + var RamStorageService = AbstractStorageService.extend({ + storage: new RamStorage(), + }); + + var actionManager = createActionManager({ + actions: this.actions, + archs: this.archs, + data: this.data, + services: { + local_storage: RamStorageService, + }, + }); + + testUtils.intercept(actionManager, 'call_service', function (ev) { + if (ev.data.service === 'local_storage' && ev.data.args[0] === 'visible_search_menu') { + assert.step(`${ev.data.method} ${ev.data.args.length > 1 ? ev.data.args[1] : ''}`); + } + }, true); + + await actionManager.doAction(1); + + assert.isVisible($('.o_search_options .o_dropdown_toggler_btn:first')); + + await testUtils.dom.click($('.o_searchview_more')); + + assert.isNotVisible($('.o_search_options .o_dropdown_toggler_btn:first')); + assert.verifySteps(['getItem ', 'getItem ', 'setItem false']); + + await actionManager.doAction(2); + + assert.isNotVisible($('.o_search_options .o_dropdown_toggler_btn:first')); + assert.verifySteps(['getItem ', 'getItem ', 'setItem false', 'getItem ']); + + actionManager.destroy(); + }); }); }); |
