From be9f0e2efbccda9877aba7aa5604898838c156a1 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 5 Jul 2024 15:41:51 +0200 Subject: [PATCH] [MIG] web_widget_domain_editor_dialog: Migration to 17.0 TT49927 --- .../__manifest__.py | 2 +- .../static/src/js/domain_field.esm.js | 22 ++++++++--------- .../src/js/widget_domain_editor_dialog.esm.js | 24 ++++++++----------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/web_widget_domain_editor_dialog/__manifest__.py b/web_widget_domain_editor_dialog/__manifest__.py index 7dfdd8a4c..17e3d4e5e 100644 --- a/web_widget_domain_editor_dialog/__manifest__.py +++ b/web_widget_domain_editor_dialog/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Web Widget Domain Editor Dialog", "summary": "Recovers the Domain Editor Dialog functionality", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "category": "Web", "author": "Tecnativa," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", diff --git a/web_widget_domain_editor_dialog/static/src/js/domain_field.esm.js b/web_widget_domain_editor_dialog/static/src/js/domain_field.esm.js index 4d7544977..16f7b15d2 100644 --- a/web_widget_domain_editor_dialog/static/src/js/domain_field.esm.js +++ b/web_widget_domain_editor_dialog/static/src/js/domain_field.esm.js @@ -2,14 +2,15 @@ /* Copyright 2019 Tecnativa - David Vidal * Copyright 2024 Tecnativa - Carlos Roca * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ -import {DomainField} from "@web/views/fields/domain/domain_field"; -import {DomainEditorDialog} from "./widget_domain_editor_dialog.esm"; +import {_t} from "@web/core/l10n/translation"; import {patch} from "@web/core/utils/patch"; +import {DomainEditorDialog} from "./widget_domain_editor_dialog.esm"; +import {DomainField} from "@web/views/fields/domain/domain_field"; -patch(DomainField.prototype, "web_widget_domain_editor_dialog.DomainField", { +patch(DomainField.prototype, { onButtonClick(ev) { - ev.preventDefault(); const self = this; + ev.preventDefault(); if (this.props.readonly) { return this._super.apply(this, arguments); } @@ -17,20 +18,17 @@ patch(DomainField.prototype, "web_widget_domain_editor_dialog.DomainField", { this.props.value = "[]"; } this.addDialog(DomainEditorDialog, { - title: this.env._t("Select records..."), + title: _t("Select records..."), noCreate: true, multiSelect: true, - resModel: this.getResModel(this.props), + resModel: this.getResModel(), dynamicFilters: [ { - description: this.env._t("Selected domain"), - domain: - this.getDomain(this.props.value).toList( - this.getContext(this.props) - ) || [], + description: _t("Selected domain"), + domain: this.getEvaluatedDomain(), }, ], - context: this.getContext(this.props) || {}, + context: this.getContext(), onSelected: function (resIds) { self.update(this.get_domain(resIds)); }, diff --git a/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.esm.js b/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.esm.js index ab004de16..9609872b4 100644 --- a/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.esm.js +++ b/web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.esm.js @@ -2,8 +2,9 @@ /* Copyright 2019 Tecnativa - David Vidal * Copyright 2024 Tecnativa - Carlos Roca * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ -import {SelectCreateDialog} from "@web/views/view_dialogs/select_create_dialog"; +import {deepEqual} from "@web/core/utils/objects"; import {Domain} from "@web/core/domain"; +import {SelectCreateDialog} from "@web/views/view_dialogs/select_create_dialog"; export function findChildren(comp, predicate = (e) => e) { const queue = []; @@ -33,23 +34,18 @@ export class DomainEditorDialog extends SelectCreateDialog { } _getDomainOfGroups(groups, domain) { - const groups_unfolded = _.filter(groups, (g) => !g.isFolded); - var groups_domain = []; - for (var group of groups_unfolded) { - var group_list = group.list; + const groups_unfolded = groups.filter((g) => !g.isFolded); + const groups_domain = []; + for (const group of groups_unfolded) { + const group_list = group.list; if (group_list.groupBy.length) { groups_domain.push(this._getDomainOfGroups(group_list.groups, domain)); } else { - var group_domain = group_list.domain; - _.each(domain, (d) => { - group_domain = _.without( - group_domain, - _.filter(group_domain, (x) => { - return _.isEqual(x, d); - })[0] - ); + let group_domain = group_list.domain.slice(); + domain.forEach((d) => { + group_domain = group_domain.filter((x) => !deepEqual(x, d)); }); - group_domain = _.without(group_domain, "&"); + group_domain = group_domain.filter((x) => x !== "&"); groups_domain.push(group_domain); } }