[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
This commit is contained in:
Mathieu Duckerts-Antoine
2023-06-05 13:31:48 +02:00
parent 606bc349e9
commit 2860156adf
3 changed files with 13 additions and 15 deletions
@@ -13,10 +13,6 @@
</button>
</t>
</t>
<t t-elif="node.children.length === 1">
Match records with the following rule:
<t t-call="web._DomainSelector.branch.children" />
</t>
<t t-else="">
<span>Match records with </span>
<t t-call="web._DomainSelector.branch.connector" />
@@ -95,7 +91,7 @@
</t>
<t t-else="">
<div class="d-inline-flex o_domain_tree_connector_selector" aria-atomic="true">
<Dropdown togglerClass="'btn btn-link btn-sm btn-primary py-0 px-1 o_domain_tree_connector_caret'">
<Dropdown togglerClass="'btn btn-link btn-primary py-0 px-1 o_domain_tree_connector_caret'">
<t t-set-slot="toggler">
<t t-esc="node.title"/>
</t>
@@ -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")]`,
@@ -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");