diff --git a/addons/web/static/src/core/domain_selector/domain_selector.scss b/addons/web/static/src/core/domain_selector/domain_selector.scss index 47b10f30c22..904df7bd82e 100644 --- a/addons/web/static/src/core/domain_selector/domain_selector.scss +++ b/addons/web/static/src/core/domain_selector/domain_selector.scss @@ -147,22 +147,6 @@ height: 100%; } } - - .o_domain_leaf_value_tags { - display: flex; - - > * { - flex: 0 0 auto; - } - > input { - flex: 1 1 auto; - width: 0; - min-width: 50px; - } - .o_domain_leaf_value_remove_tag_button { - cursor: pointer; - } - } } } diff --git a/addons/web/static/src/core/domain_selector/domain_selector_fields.js b/addons/web/static/src/core/domain_selector/domain_selector_fields.js index 9447f36189d..b1be98b5dda 100644 --- a/addons/web/static/src/core/domain_selector/domain_selector_fields.js +++ b/addons/web/static/src/core/domain_selector/domain_selector_fields.js @@ -1,6 +1,6 @@ /** @odoo-module **/ -import { Component, useRef } from "@odoo/owl"; +import { Component } from "@odoo/owl"; import { selectOperators } from "@web/core/domain_selector/domain_selector_operators"; import { deserializeDate, @@ -14,6 +14,7 @@ import { toPyValue } from "@web/core/py_js/py_utils"; import { registry } from "@web/core/registry"; import { DateTimeInput } from "../datetime/datetime_input"; import { DomainValueExpr } from "./domain_selector_nodes"; +import { TagsList } from "@web/core/tags_list/tags_list"; const { DateTime } = luxon; @@ -47,32 +48,25 @@ class Select extends Component { } class TagInput extends Component { + static components = { TagsList }; static props = ["value", "update"]; static template = "web.DomainSelector.TagInput"; - - setup() { - this.inputRef = useRef("input"); + get value() { + return Array.isArray(this.props.value) ? this.props.value : [this.props.value]; } - - getTagValue(tag) { - return tag instanceof DomainValueExpr ? tag.expr : tag; + get tags() { + return this.value.map((val, index) => ({ + text: val instanceof DomainValueExpr ? val.expr : String(val), + colorIndex: typeof val === "string" ? 0 : 2, + onDelete: () => { + this.props.update([...this.value.slice(0, index), ...this.value.slice(index + 1)]); + }, + })); } - - removeTag(tagIndex) { - return this.props.update([ - ...this.props.value.slice(0, tagIndex), - ...this.props.value.slice(tagIndex + 1), - ]); - } - - addTag(value) { - return this.props.update([...this.props.value, value]); - } - - onBtnClick() { - const value = this.inputRef.el.value; - this.inputRef.el.value = ""; - return this.addTag(value); + onChange(ev) { + const newVal = ev.currentTarget.value; + ev.currentTarget.value = ""; + this.props.update([...this.value, newVal]); } } @@ -331,7 +325,7 @@ const PROPERTIES_RELATIONAL = { // ---------------------------------------------------------------------------- const JSON_FIELD = { - operators: ["equal", "not_equal", "ilike", "not_ilike","set", "not_set"], + operators: ["equal", "not_equal", "ilike", "not_ilike", "set", "not_set"], editors: { default: makeEditor(Input), }, diff --git a/addons/web/static/src/core/domain_selector/domain_selector_fields.xml b/addons/web/static/src/core/domain_selector/domain_selector_fields.xml index 908cecb1bf8..86790f2a311 100644 --- a/addons/web/static/src/core/domain_selector/domain_selector_fields.xml +++ b/addons/web/static/src/core/domain_selector/domain_selector_fields.xml @@ -29,17 +29,9 @@ -
- - - - - - -
-
- -