From 2860156adfaef142846b10d73bc9da171667f60f Mon Sep 17 00:00:00 2001 From: Mathieu Duckerts-Antoine Date: Fri, 12 May 2023 11:53:29 +0000 Subject: [PATCH] [FIX] web: domain selector: always show connectors When a domain with a single condition is displayed in a domain selector, the implicit connector "&" or "|" is not displayed. This makes the operation 'Add node' less obvious in that case since it is not known how the new condition will be combined with the others. Here we always display the connector to solve that problem. As a by-product, we get another problem solved: a domain of the form ["!", ("foo", "=", "abc")] was incorrectly displayed. X-original-commit: bd57f20980734641ce405bd34d8b17dc780adb17 Part-of: odoo/odoo#123352 --- .../core/domain_selector/domain_selector.xml | 6 +----- .../tests/core/domain_selector_tests.js | 20 ++++++++++--------- .../tests/search/search_bar_menu_tests.js | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/addons/web/static/src/core/domain_selector/domain_selector.xml b/addons/web/static/src/core/domain_selector/domain_selector.xml index 47a102854c4..e01b37e7793 100644 --- a/addons/web/static/src/core/domain_selector/domain_selector.xml +++ b/addons/web/static/src/core/domain_selector/domain_selector.xml @@ -13,10 +13,6 @@ - - Match records with the following rule: - - Match records with @@ -95,7 +91,7 @@
- + diff --git a/addons/web/static/tests/core/domain_selector_tests.js b/addons/web/static/tests/core/domain_selector_tests.js index 58640f89d8d..d94b615b425 100644 --- a/addons/web/static/tests/core/domain_selector_tests.js +++ b/addons/web/static/tests/core/domain_selector_tests.js @@ -82,7 +82,7 @@ QUnit.module("Components", (hooks) => { }, datetime: { string: "Date Time", type: "datetime", searchable: true }, int: { string: "Integer", type: "integer", searchable: true }, - json_field: { string: "Json Field", type: "json", searchable: true}, + json_field: { string: "Json Field", type: "json", searchable: true }, }, records: [ { id: 1, foo: "yop", bar: true, product_id: 37 }, @@ -622,9 +622,11 @@ QUnit.module("Components", (hooks) => { }); QUnit.test("json field with operator change from 'equal' to 'ilike'", async (assert) => { - await makeDomainSelector({ domain: `[['json_field', '=', "hey"]]` }); - assert.strictEqual(target.querySelector(".o_model_field_selector_chain_part").innerText, `Json Field`); + assert.strictEqual( + target.querySelector(".o_model_field_selector_chain_part").innerText, + `Json Field` + ); assert.strictEqual(target.querySelector(".o_domain_leaf_operator_select").value, "equal"); // option "=" assert.strictEqual(target.querySelector(".o_domain_leaf_value_input").value, `hey`); @@ -923,15 +925,15 @@ QUnit.module("Components", (hooks) => { const toTest = [ { domain: `["!", ("foo", "=", "abc")]`, - result: `Match records with the following rule:\nFoo\n!= "abc"`, + result: `Match records with all of the following rules:\nFoo\n!= "abc"`, }, { domain: `["!", "!", ("foo", "=", "abc")]`, - result: `Match records with the following rule:\nFoo\n= "abc"`, + result: `Match records with all of the following rules:\nFoo\n= "abc"`, }, { domain: `["!", "!", "!", ("foo", "=", "abc")]`, - result: `Match records with the following rule:\nFoo\n!= "abc"`, + result: `Match records with all of the following rules:\nFoo\n!= "abc"`, }, { domain: `["!", "&", ("foo", "=", "abc"), ("foo", "=", "def")]`, @@ -1040,15 +1042,15 @@ QUnit.module("Components", (hooks) => { const toTest = [ { domain: `["!", ("foo", "=", "abc")]`, - result: `Match records with the following rule:\nFoo\n!= "abc"`, + result: `Match records with all of the following rules:\nFoo\n!= "abc"`, }, { domain: `["!", "!", ("foo", "=", "abc")]`, - result: `Match records with the following rule:\nFoo\n= "abc"`, + result: `Match records with all of the following rules:\nFoo\n= "abc"`, }, { domain: `["!", "!", "!", ("foo", "=", "abc")]`, - result: `Match records with the following rule:\nFoo\n!= "abc"`, + result: `Match records with all of the following rules:\nFoo\n!= "abc"`, }, { domain: `["!", "&", ("foo", "=", "abc"), ("foo", "=", "def")]`, diff --git a/addons/web/static/tests/search/search_bar_menu_tests.js b/addons/web/static/tests/search/search_bar_menu_tests.js index 60bd89e6fdd..ed7ff67a6fe 100644 --- a/addons/web/static/tests/search/search_bar_menu_tests.js +++ b/addons/web/static/tests/search/search_bar_menu_tests.js @@ -1586,7 +1586,7 @@ QUnit.module("Search", (hooks) => { target.querySelector(".o_domain_leaf .o_model_field_selector_chain_part").innerText, "ID" ); - assert.containsNone(target, "button.o_domain_tree_connector_caret"); + assert.containsOnce(target, "button.o_domain_tree_connector_caret"); await click(target, ".o_domain_add_node_button .fa-plus"); assert.containsOnce(target, "button.o_domain_tree_connector_caret");