[IMP] web: removed autocomplete filters and groupbys

purpose of this commit is:
- to remove filter and groupby option which are added at the time of fuzzy
search, it was useless as we have separate groupby and filter menu
also it generates the big dropdown menu so it is more confusing.
- align caret icon with the label.

After this commit:
- when user do the fuzzy search then filter and groupby option will not be shown
in the dropdown

task-2036351

closes odoo/odoo#35092

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>


Co-authored-by: Mohammed Shekha <msh@odoo.com>
This commit is contained in:
Priyanka Kakadiya
2019-08-30 05:06:47 +00:00
co-authored by Mohammed Shekha
parent ae8770e704
commit 135079044c
4 changed files with 17 additions and 48 deletions
@@ -292,9 +292,7 @@ var ControlPanelRenderer = Renderer.extend({
context: this.context,
facets: this.state.facets,
fields: this.state.fields,
filters: this.state.filters,
filterFields: this.state.filterFields,
groupBys: this.state.groupBys,
});
return this.searchBar.appendTo(this.$('.o_searchview')).then(function () {
if (oldSearchBar) {
@@ -28,9 +28,7 @@ var SearchBar = Widget.extend({
this.facets = params.facets;
this.fields = params.fields;
this.filters = params.filters;
this.filterFields = params.filterFields;
this.groupBys = params.groupBys;
this.autoCompleteSources = [];
this.searchFacets = [];
@@ -167,12 +165,6 @@ var SearchBar = Widget.extend({
self.autoCompleteSources.push(new (Obj) (self, filter, field, self.context));
}
});
_.each(this.filters, function (filter) {
self.autoCompleteSources.push(new (registry.get('filter'))(self, filter));
});
_.each(this.groupBys, function (filter) {
self.autoCompleteSources.push(new (registry.get('groupby'))(self, filter));
});
},
//--------------------------------------------------------------------------
@@ -82,7 +82,6 @@
}
&.o-expand, &.o-expanded { // caret
@include o-position-absolute($left: 6px);
padding: 3px;
}
&.o-expand:before {
@include o-caret-right;
@@ -1265,56 +1265,36 @@ QUnit.module('Search View', {
QUnit.module('Autocompletion');
QUnit.test('selection via autocompletion and deletion modifies appropriately submenus', async function (assert) {
assert.expect(6);
QUnit.test('select an autocomplete field', async function (assert) {
assert.expect(3);
var searchRead = 0;
var actionManager = await createActionManager({
actions: this.actions,
archs: this.archs,
data: this.data,
mockRPC: function (route, args) {
if (route === '/web/dataset/search_read') {
if (searchRead === 1) {
assert.deepEqual(args.domain, [["foo", "ilike", "a"]]);
}
searchRead++;
}
return this._super.apply(this, arguments);
},
});
const unpatchDate = patchDate(2019,6,31,13,43,0);
await actionManager.doAction(9);
await actionManager.doAction(11);
await testUtils.fields.triggerKey('press', $('.o_searchview_input'), 97);
await testUtils.fields.triggerKey('up', $('.o_searchview_input'), 'enter');
await testUtils.fields.triggerKey('press', $('.o_searchview_input'), 103);
await testUtils.fields.triggerKey('up', $('.o_searchview_input'), 'enter');
assert.strictEqual(actionManager.$('.o_searchview_autocomplete li').length, 2,
"there should be 2 result for 'a' in search bar autocomplete");
await testUtils.fields.triggerKey('up', $('.o_searchview_input'), 'enter');
assert.strictEqual($('.o_searchview_input_container .o_facet_values').eq(0).text().trim(),
"Date Field Filter: July 2019",
"There should be a filter facet with label 'Date Field Filter: July 2019'");
assert.strictEqual($('.o_searchview_input_container .o_facet_values').eq(1).text().trim(),
"Date Field Groupby: Day",
"There should be a filter facet with label 'Date Field Groupby: Day'");
await testUtils.dom.click($('button .fa-filter'));
await testUtils.dom.click($('.o_filters_menu .o_menu_item').eq(0));
assert.strictEqual($('.o_filters_menu .o_item_option a.selected').text().trim(), "July2019",
"The item 'July 2019' should be selected in the filters menu");
await testUtils.dom.click($('button .fa-bars'));
await testUtils.dom.click($('.o_group_by_menu .o_menu_item').eq(0));
assert.strictEqual($('.o_group_by_menu .o_item_option a.selected').text().trim(), "Day",
"The item 'Day' should be selected in the groupby menu");
await testUtils.dom.click($('div .o_searchview_facet .o_facet_remove').eq(0));
await testUtils.dom.click($('div .o_searchview_facet .o_facet_remove').eq(0));
await testUtils.dom.click($('button .fa-filter'));
await testUtils.dom.click($('.o_filters_menu .o_menu_item').eq(0));
assert.containsNone($('.o_filters_menu .o_item_option a.selected'),
"The item 'This Month' should have unselected in the filters menu");
await testUtils.dom.click($('button .fa-bars'));
await testUtils.dom.click($('.o_group_by_menu .o_menu_item').eq(0));
assert.containsNone($('.o_group_by_menu .o_item_option a.selected'),
"The item 'Day' should have been unselected in the groupby menu");
"a", "There should be a field facet with label 'a'");
actionManager.destroy();
unpatchDate();
});
QUnit.test('select an autocomplete field with `context` key', async function (assert) {