[IMP] web: quicksearch on selection and boolean field
Currently, the selection field and boolean field values are displays
below the string 'search for: '
like, Search status for: input value
New
Running
Cancelled
so, this commit improves the quick search dropdown by displaying the
selection field and boolean field value and strings in the same line
like, Search Status: New
Search Status: Running
Search Status: Cancelled
TaskID-2462138
closes odoo/odoo#67575
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -204,7 +204,7 @@ odoo.define('web.SearchBar', function (require) {
|
||||
}
|
||||
});
|
||||
if (options.length) {
|
||||
sources.push(source, ...options);
|
||||
sources.push(...options);
|
||||
}
|
||||
// Any other type.
|
||||
} else if (this._validateSource(query, source)) {
|
||||
|
||||
@@ -591,7 +591,7 @@
|
||||
<li t-foreach="state.sources" t-as="src" t-key="src.id"
|
||||
t-att-id="src.id"
|
||||
class="o_menu_item"
|
||||
t-att-class="{ o_indent: src.parent, o_selection_focus: src_index === state.focusedItem }"
|
||||
t-att-class="{ o_indent: src.parent and !src.parent.selection, o_selection_focus: src_index === state.focusedItem }"
|
||||
t-on-click="_selectSource(src)"
|
||||
t-on-mousemove="_onSourceMousemove(src_index)"
|
||||
>
|
||||
@@ -603,7 +603,9 @@
|
||||
<i t-attf-class="fa fa-caret-{{ src.expanded ? 'down' : 'right' }}"/>
|
||||
</a>
|
||||
<a href="#" t-on-click.prevent="">
|
||||
<t t-if="src.label" t-esc="src.label"/>
|
||||
<t t-if="src.parent.selection">
|
||||
Search <em t-esc="src.parent.description"/>: <strong t-esc="src.label"/></t>
|
||||
<t t-elif="src.label" t-esc="src.label"/>
|
||||
<t t-elif="['date', 'datetime'].includes(src.type)">
|
||||
<t>Search <em t-esc="src.description"/> at: <strong t-esc="state.inputValue"/></t>
|
||||
</t>
|
||||
|
||||
@@ -19,6 +19,7 @@ odoo.define('web.search_bar_tests', function (require) {
|
||||
birth_datetime: { string: "Birth DateTime", type: 'datetime' },
|
||||
foo: { string: "Foo", type: 'char' },
|
||||
bool: { string: "Bool", type: 'boolean' },
|
||||
status: { string: 'Status', type: 'selection', selection: [['draft', "New"], ['cancel', "Cancelled"]] },
|
||||
},
|
||||
records: [
|
||||
{ id: 1, display_name: "First record", foo: "yop", bar: 2, bool: true, birthday: '1983-07-15', birth_datetime: '1983-07-15 01:00:00' },
|
||||
@@ -572,7 +573,7 @@ odoo.define('web.search_bar_tests', function (require) {
|
||||
});
|
||||
|
||||
QUnit.test('autocompletion with a boolean field', async function (assert) {
|
||||
assert.expect(9);
|
||||
assert.expect(11);
|
||||
|
||||
this.archs['partner,false,search'] = '<search><field name="bool"/></search>';
|
||||
|
||||
@@ -592,22 +593,23 @@ odoo.define('web.search_bar_tests', function (require) {
|
||||
|
||||
await cpHelpers.editSearch(actionManager, "y");
|
||||
|
||||
assert.containsN(actionManager, '.o_searchview_autocomplete li', 2);
|
||||
assert.strictEqual(actionManager.$('.o_searchview_autocomplete li:last-child').text(), "Yes");
|
||||
assert.containsOnce(actionManager, '.o_searchview_autocomplete li');
|
||||
assert.strictEqual(actionManager.el.querySelector('.o_searchview_autocomplete li').innerText, "Search Bool: Yes");
|
||||
assert.doesNotHaveClass(actionManager.el.querySelector('.o_searchview_autocomplete li'), 'o_indent');
|
||||
|
||||
// select "Yes"
|
||||
await testUtils.dom.click(actionManager.el.querySelector('.o_searchview_autocomplete li:last-child'));
|
||||
await testUtils.dom.click(actionManager.el.querySelector('.o_searchview_autocomplete li'));
|
||||
|
||||
await cpHelpers.removeFacet(actionManager, 0);
|
||||
|
||||
await cpHelpers.editSearch(actionManager, "No");
|
||||
|
||||
assert.containsN(actionManager, '.o_searchview_autocomplete li', 2);
|
||||
assert.strictEqual(actionManager.$('.o_searchview_autocomplete li:last-child').text(), "No");
|
||||
assert.containsOnce(actionManager, '.o_searchview_autocomplete li');
|
||||
assert.strictEqual(actionManager.el.querySelector('.o_searchview_autocomplete li').innerText, "Search Bool: No");
|
||||
assert.doesNotHaveClass(actionManager.el.querySelector('.o_searchview_autocomplete li'), 'o_indent');
|
||||
|
||||
// select "No"
|
||||
await testUtils.dom.click(actionManager.el.querySelector('.o_searchview_autocomplete li:last-child'));
|
||||
|
||||
await testUtils.dom.click(actionManager.el.querySelector('.o_searchview_autocomplete li'));
|
||||
|
||||
assert.verifySteps([
|
||||
JSON.stringify([]), // initial search
|
||||
@@ -619,6 +621,30 @@ odoo.define('web.search_bar_tests', function (require) {
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('autocompletion with a selection field', async function (assert) {
|
||||
assert.expect(5);
|
||||
|
||||
this.archs['partner,false,search'] = '<search><field name="status"/></search>';
|
||||
|
||||
const actionManager = await createActionManager({
|
||||
actions: this.actions,
|
||||
archs: this.archs,
|
||||
data: this.data,
|
||||
});
|
||||
|
||||
await actionManager.doAction(1);
|
||||
|
||||
await cpHelpers.editSearch(actionManager, "n");
|
||||
|
||||
assert.containsN(actionManager, '.o_searchview_autocomplete li', 2);
|
||||
assert.strictEqual(actionManager.el.querySelector('.o_searchview_autocomplete li:first-child').innerText, "Search Status: New");
|
||||
assert.strictEqual(actionManager.el.querySelector('.o_searchview_autocomplete li:last-child').innerText, "Search Status: Cancelled");
|
||||
assert.doesNotHaveClass(actionManager.el.querySelector('.o_searchview_autocomplete li:first-child'), 'o_indent');
|
||||
assert.doesNotHaveClass(actionManager.el.querySelector('.o_searchview_autocomplete li:last-child'), 'o_indent');
|
||||
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
||||
QUnit.test("reference fields are supported in search view", async function (assert) {
|
||||
assert.expect(7);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user