[FIX] web: fix domain selector double click
Before this commit, we needed to double click on "add a rule/group" to execute the action if focused an input. This commit fixes this issue, we can now click once to execute the action of the buttons. task id: 3346327 closes odoo/odoo#125756 X-original-commit: 0db23b5a7e29f8714a63375c5d86f5d1b2220bda Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
This commit is contained in:
@@ -101,7 +101,11 @@ export class DomainSelector extends Component {
|
||||
|
||||
this.tree.isSupported = true;
|
||||
|
||||
const options = { defaultConnector: p.defaultConnector, distributeNot: !p.isDebugMode };
|
||||
const options = {
|
||||
defaultConnector: p.defaultConnector,
|
||||
distributeNot: !p.isDebugMode,
|
||||
previousTree: this.tree.root,
|
||||
};
|
||||
this.tree.root = buildDomainSelectorTree(domain, pathsInfo, options);
|
||||
this.defaultLeaf = buildDomainSelectorTree(
|
||||
defaultLeafDomain,
|
||||
|
||||
@@ -16,10 +16,10 @@ export class DomainValueExpr {
|
||||
class DomainNode {
|
||||
static nextId = 0;
|
||||
|
||||
constructor(type, negate) {
|
||||
this.id = ++DomainNode.nextId;
|
||||
constructor(type, options = {}) {
|
||||
this.id = options.id ?? ++DomainNode.nextId;
|
||||
this.type = type;
|
||||
this.negate = negate;
|
||||
this.negate = options.negate ?? false;
|
||||
}
|
||||
|
||||
toDomain() {
|
||||
@@ -41,8 +41,8 @@ const TITLES = {
|
||||
};
|
||||
|
||||
export class BranchDomainNode extends DomainNode {
|
||||
constructor(connector, children = [], negate = false) {
|
||||
super("branch", negate);
|
||||
constructor(connector, children, options = {}) {
|
||||
super("branch", options);
|
||||
this.connector = connector;
|
||||
this.children = children;
|
||||
}
|
||||
@@ -80,8 +80,8 @@ export class BranchDomainNode extends DomainNode {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
export class LeafDomainNode extends DomainNode {
|
||||
constructor(pathInfo, operatorInfo, value, negate = false) {
|
||||
super("leaf", negate);
|
||||
constructor(pathInfo, operatorInfo, value, options = {}) {
|
||||
super("leaf", options);
|
||||
this.pathInfo = pathInfo;
|
||||
this.operatorInfo = operatorInfo;
|
||||
this.value = value;
|
||||
@@ -109,7 +109,9 @@ export class LeafDomainNode extends DomainNode {
|
||||
}
|
||||
|
||||
clone() {
|
||||
return new LeafDomainNode(this.pathInfo, this.operatorInfo, this.value, this.negate);
|
||||
return new LeafDomainNode(this.pathInfo, this.operatorInfo, this.value, {
|
||||
negate: this.negate,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,19 +175,26 @@ export function getLeafOperatorInfo(tree, fieldDef) {
|
||||
/**
|
||||
* @param {import("@web/core/domain_tree").Tree} tree
|
||||
* @param {Object} pathsInfo
|
||||
* @param {LeafDomainNode|BranchDomainNode} [previousTree]
|
||||
* @returns {LeafDomainNode|BranchDomainNode}
|
||||
*/
|
||||
export function toDomainSelectorTree(tree, pathsInfo) {
|
||||
export function toDomainSelectorTree(tree, pathsInfo, previousTree = null) {
|
||||
if (tree.type === "condition") {
|
||||
const path = tree.path;
|
||||
const negate = tree.negate;
|
||||
const pathInfo = pathsInfo[path];
|
||||
const operatorInfo = getLeafOperatorInfo(tree, pathInfo.fieldDef);
|
||||
const value = getValue(tree.valueAST);
|
||||
return new LeafDomainNode(pathInfo, operatorInfo, value, negate);
|
||||
const id = previousTree instanceof LeafDomainNode ? previousTree.id : null;
|
||||
return new LeafDomainNode(pathInfo, operatorInfo, value, { negate, id });
|
||||
}
|
||||
const connector = tree.value === "&" ? "AND" : "OR";
|
||||
const negate = tree.negate;
|
||||
const children = tree.children.map((child) => toDomainSelectorTree(child, pathsInfo));
|
||||
return new BranchDomainNode(connector, children, negate);
|
||||
const children = tree.children.map((child, index) => {
|
||||
const subTree =
|
||||
previousTree instanceof BranchDomainNode ? previousTree.children[index] : null;
|
||||
return toDomainSelectorTree(child, pathsInfo, subTree);
|
||||
});
|
||||
const id = previousTree instanceof BranchDomainNode ? previousTree.id : null;
|
||||
return new BranchDomainNode(connector, children, { negate, id });
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export function buildDomain(domainSelectorTree) {
|
||||
*/
|
||||
export function buildDomainSelectorTree(domain, pathsInfo, options = {}) {
|
||||
const tree = toTree(domain, options);
|
||||
return toDomainSelectorTree(tree, pathsInfo);
|
||||
return toDomainSelectorTree(tree, pathsInfo, options.previousTree);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user