From bb1ccf2e93476e7b48b98862f7a92eb34fed48af Mon Sep 17 00:00:00 2001 From: Adam Heinz Date: Tue, 3 Sep 2024 15:28:01 -0400 Subject: [PATCH] [MIG] web_edit_user_filter: Migration to 16.0 --- .../odoo/addons/web_edit_user_filter | 1 + setup/web_edit_user_filter/setup.py | 6 + web_edit_user_filter/README.rst | 14 +- web_edit_user_filter/__manifest__.py | 7 +- .../static/description/index.html | 11 +- web_edit_user_filter/static/src/js/backend.js | 344 ------------------ .../static/src/js/customFavorite.esm.js | 52 +++ .../static/src/js/searchBar.esm.js | 200 ++++++++++ .../static/src/js/searchModel.esm.js | 31 ++ .../static/src/scss/backend.scss | 6 +- .../static/src/xml/backend.xml | 35 +- .../static/src/xml/search_extended.xml | 10 +- 12 files changed, 339 insertions(+), 378 deletions(-) create mode 120000 setup/web_edit_user_filter/odoo/addons/web_edit_user_filter create mode 100644 setup/web_edit_user_filter/setup.py delete mode 100644 web_edit_user_filter/static/src/js/backend.js create mode 100644 web_edit_user_filter/static/src/js/customFavorite.esm.js create mode 100644 web_edit_user_filter/static/src/js/searchBar.esm.js create mode 100644 web_edit_user_filter/static/src/js/searchModel.esm.js diff --git a/setup/web_edit_user_filter/odoo/addons/web_edit_user_filter b/setup/web_edit_user_filter/odoo/addons/web_edit_user_filter new file mode 120000 index 000000000000..9fe44e09f502 --- /dev/null +++ b/setup/web_edit_user_filter/odoo/addons/web_edit_user_filter @@ -0,0 +1 @@ +../../../../web_edit_user_filter \ No newline at end of file diff --git a/setup/web_edit_user_filter/setup.py b/setup/web_edit_user_filter/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/web_edit_user_filter/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_edit_user_filter/README.rst b/web_edit_user_filter/README.rst index 9e84219a102c..2af9a608ad2b 100644 --- a/web_edit_user_filter/README.rst +++ b/web_edit_user_filter/README.rst @@ -17,13 +17,13 @@ Edit User Filters :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github - :target: https://github.com/OCA/web/tree/15.0/web_edit_user_filter + :target: https://github.com/OCA/web/tree/16.0/web_edit_user_filter :alt: OCA/web .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_edit_user_filter + :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_edit_user_filter :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=15.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -49,7 +49,7 @@ Edit a favourite filter: #. Select a filter and click on the star icon of the filter name #. click on the pencil icon to start editing the filter. -.. image:: https://raw.githubusercontent.com/OCA/web/15.0/web_edit_user_filter/static/description/select_facet.png +.. image:: https://raw.githubusercontent.com/OCA/web/16.0/web_edit_user_filter/static/description/select_facet.png :alt: Select Facet Edit a facet: @@ -58,7 +58,7 @@ Edit a facet: #. a menu is now shown which allows you to remove values from the facet; #. to cancel removal you can click outside the popover. -.. image:: https://raw.githubusercontent.com/OCA/web/15.0/web_edit_user_filter/static/description/edit_facet.png +.. image:: https://raw.githubusercontent.com/OCA/web/16.0/web_edit_user_filter/static/description/edit_facet.png :alt: Edit Facet Known issues / Roadmap @@ -73,7 +73,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -105,6 +105,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/web `_ project on GitHub. +This module is part of the `OCA/web `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_edit_user_filter/__manifest__.py b/web_edit_user_filter/__manifest__.py index 3853d2215140..587cae1d8c68 100644 --- a/web_edit_user_filter/__manifest__.py +++ b/web_edit_user_filter/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Edit User Filters", "category": "Extra Tools", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "author": "Onestein,Level Prime Srl,Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", "development_status": "Production/Stable", @@ -15,9 +15,8 @@ "web.assets_backend": [ "web_edit_user_filter/static/src/js/*.js", "web_edit_user_filter/static/src/scss/*.scss", - ], - "web.assets_qweb": [ - "web_edit_user_filter/static/src/xml/*.xml", + "web_edit_user_filter/static/src/xml/backend.xml", + "web_edit_user_filter/static/src/xml/search_extended.xml", ], }, } diff --git a/web_edit_user_filter/static/description/index.html b/web_edit_user_filter/static/description/index.html index 4a9f652b7b4a..0c1e95be7a64 100644 --- a/web_edit_user_filter/static/description/index.html +++ b/web_edit_user_filter/static/description/index.html @@ -1,4 +1,3 @@ - @@ -370,7 +369,7 @@

Edit User Filters

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:2077b9fefede8cc5692d8431d7897372a681ef7b70300359578f42e92873519d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Production/Stable License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

Production/Stable License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

In standard Odoo you can edit user filters via the debug module. The problem is that normal users often don’t have access to this menu therefore can’t adjust filters once they’re saved. This module makes this feature available for normal users with a user friendly interface. @@ -399,14 +398,14 @@

Usage

  • Select a filter and click on the star icon of the filter name
  • click on the pencil icon to start editing the filter.
  • -Select Facet +Select Facet

    Edit a facet:

    1. Click on the facet;
    2. a menu is now shown which allows you to remove values from the facet;
    3. to cancel removal you can click outside the popover.
    -Edit Facet +Edit Facet

    Known issues / Roadmap

    @@ -420,7 +419,7 @@

    Bug Tracker

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -448,7 +447,7 @@

    Maintainers

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/web project on GitHub.

    +

    This module is part of the OCA/web project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/web_edit_user_filter/static/src/js/backend.js b/web_edit_user_filter/static/src/js/backend.js deleted file mode 100644 index a2eafd7d37cf..000000000000 --- a/web_edit_user_filter/static/src/js/backend.js +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright 2019 Onestein - * Copyright 2021 Level Prime Srl - Roberto Fichera - * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - */ - -odoo.define("web_edit_user_filter/static/src/js/backend.js", function (require) { - "use strict"; - - var core = require("web.core"); - var qweb = core.qweb; - var _t = core._t; - const {patch} = require("web.utils"); - const components = { - SearchBar: require("web.SearchBar"), - CustomFavoriteItem: require("web.CustomFavoriteItem"), - ControlPanelModelExtension: require("web/static/src/js/control_panel/control_panel_model_extension.js"), - }; - - patch( - components.ControlPanelModelExtension.prototype, - "web_edit_user_filter/static/src/js/backend.js", - { - _favoriteToIrFilter(favorite) { - var irFilter = this._super(...arguments); - if ("facet" in favorite) { - irFilter.facet = favorite.facet; - } - return irFilter; - }, - - /** - * Returns a filter of type 'favorite' starting from an ir_filter comming from db. - * @private - * @param {Object} irFilter - * @returns {Object} - */ - _irFilterToFavorite(irFilter) { - var favorite = this._super(...arguments); - if (irFilter.facet) { - favorite.facet = irFilter.facet; - } - return favorite; - }, - } - ); - - patch( - components.CustomFavoriteItem.prototype, - "web_edit_user_filter/static/src/js/backend.js", - { - // --------------------------------------------------------------------- - // Private - // --------------------------------------------------------------------- - - /** - * FIXME DRY addons/web/static/src/search/favorite_menu/custom_favorite_item.js - * @override - * @private - */ - saveFavorite() { - if (!this.state.description.length) { - this.env.services.notification.notify({ - message: this.env._t( - "A name for your favorite filter is required." - ), - type: "danger", - }); - return this.descriptionRef.el.focus(); - } - const favorites = this.model.get( - "filters", - (f) => f.type === "favorite" - ); - if (favorites.some((f) => f.description === this.state.description)) { - this.env.services.notification.notify({ - message: this.env._t("Filter with same name already exists."), - type: "danger", - }); - return this.descriptionRef.el.focus(); - } - // HACK This is the only difference - var facets = this.model.get("facets"); - this.model.dispatch("createNewFavorite", { - type: "favorite", - description: this.state.description, - isDefault: this.state.isDefault, - isShared: this.state.isShared, - facet: JSON.stringify(facets), - }); - // Reset state - Object.assign(this.state, { - description: this.env.action.name || "", - isDefault: false, - isShared: false, - open: false, - }); - }, - } - ); - - patch( - components.SearchBar.prototype, - "web_edit_user_filter/static/src/js/backend.js", - { - mounted() { - var self = this; - this._super(...arguments); - $(".o_searchview").on("click", ".o_searchview_facet", function () { - $(this).popover("dispose"); - if ($(this).hasClass("o_facet_remove")) { - return; - } - var facet_type = $(this).attr("data-type"); - var facetId = $(this).attr("data-gp"); - self._process_filters($(this), facet_type, facetId); - }); - - return this; - }, - - _process_filters($el, facet_type, facetId) { - var self = this; - var selectedFacet = self.model.get("filters").filter(function (facet) { - return ( - facet.type === facet_type && - facet.groupId == facetId && - facet.isActive === true - ); - }); - if (!selectedFacet.length) { - return; - } - if (facet_type === "favorite") { - var FavFacets = []; - var currentFacet = self.model.get( - "filters", - (f) => f.type === "favorite" && f.groupId == facetId - ); - if (currentFacet[0].groupBys.length) { - _.each(currentFacet[0].groupBys, function (description) { - FavFacets.push( - self.model.get( - "filters", - (f) => - f.type === "groupBy" && - f.fieldName === description - )[0] - ); - }); - } - } - var $facet = $($el); - var $content = $( - qweb.render("web_edit_user_filter.Popover", { - values: selectedFacet, - }) - ); - $content.find(".list-group-item").on("click", function () { - var PopOverContainer = $(".o_searchview"); - var type = $(this).data("type"); - var facetIdEl = $(this).data("id"); - if (type === "filter") { - var FacetSelected = self.model.get( - "filters", - (f) => f.id === facetIdEl && f.type === "filter" - ); - if (FacetSelected[0].hasOptions) { - var OptionSelected = FacetSelected[0].options.filter( - function (option) { - return option.isActive === true; - } - ); - _.each(OptionSelected, function (option) { - self.model.dispatch( - "toggleFilterWithOptions", - facetIdEl, - option.id - ); - }); - } else { - self.model.dispatch("toggleFilter", facetIdEl); - } - } else if (type === "groupBy") { - self.model.dispatch("toggleFilter", facetIdEl); - } else if (type === "favorite") { - event.stopImmediatePropagation(); - var facet = self.model.get( - "filters", - (f) => f.type === type && f.groupId === facetIdEl - ); - if (facet.length) { - self._unpackFilter(facet[0]); - } else { - self.env.services.notification.notify({ - message: self.env._t( - "In order to edit newly added 'Favorite filters, you need to refresh the page first. \n Kindly refresh the page and try again." - ), - type: "warning", - }); - } - } - $(this).remove(); - $(PopOverContainer).find(".popover").popover("hide"); - }); - var $container = $(".o_searchview"); - $facet.popover({ - title: _t( - 'Edit Filters ×' - ), - template: qweb.render("web_edit_user_filter.PopoverTemplate"), - content: $content, - container: $container, - html: true, - trigger: "manual", - placement: "bottom", - animation: false, - }); - var PopOverContainer = $(".o_searchview"); - $(PopOverContainer).find(".popover").popover("hide"); - $facet.popover("show"); - }, - - _unpackFilter(filter) { - var self = this; - self.model.dispatch("toggleFilter", filter.id); - var facets = JSON.parse(filter.facet); - var convFacets = []; - _.each(facets, function (facet) { - if (facet.type === "filter") { - _.each(facet.values, function (fc) { - var fetchedFilter = self.model.get( - "filters", - (f) => f.description === fc && f.type === "filter" - ); - if (fetchedFilter.length) { - convFacets.push( - self.model.get( - "filters", - (f) => - f.description === fc && f.type === "filter" - ) - ); - } else { - var tentativeFilter = self.model.get( - "filters", - (f) => - f.description === facet.title && - f.type === "filter" - ); - if (tentativeFilter.length) { - _.each(tentativeFilter, function (f) { - if (f.hasOptions) { - var trueOption = ""; - _.each(f.options, function (option) { - var str = fc - .split(": ") - .pop() - .split(" ")[0]; - if (str === option.description) { - trueOption = option.id; - } - }); - if (trueOption !== "") { - self.model.dispatch( - "toggleFilterWithOptions", - f.id, - trueOption - ); - } - } - }); - } else { - const preFilter = { - description: facet.title, - domain: filter.domain, - type: "filter", - }; - self.model.dispatch("createNewFilters", [ - preFilter, - ]); - } - } - }); - } else if (facet.type === "groupBy") { - _.each(facet.values, function (fc) { - var fetchedGroup = self.model.get( - "filters", - (f) => f.description === fc && f.type === "groupBy" - ); - if (fetchedGroup.length) { - convFacets.push( - self.model.get( - "filters", - (f) => - f.description === fc && f.type === "groupBy" - ) - ); - } else { - var tentativeFilter = self.model.get( - "filters", - (f) => - f.description === facet.title && - f.type === "groupBy" - ); - if (tentativeFilter.length) { - _.each(tentativeFilter, function (f) { - if (f.hasOptions) { - var trueOption = ""; - _.each(f.options, function (option) { - var str = fc - .split(": ") - .pop() - .split(" ")[0]; - if (str === option.description) { - trueOption = option.id; - } - }); - if (trueOption !== "") { - self.model.dispatch( - "toggleFilterWithOptions", - f.id, - trueOption - ); - } - } - }); - } - } - }); - } - }); - if (convFacets.length) { - _.each(convFacets, function (facet) { - self.model.dispatch("toggleFilter", facet[0].id); - }); - } - }, - } - ); - $(document).on("click", ".popover .close", function () { - $(this).parents(".popover").popover("hide"); - }); -}); diff --git a/web_edit_user_filter/static/src/js/customFavorite.esm.js b/web_edit_user_filter/static/src/js/customFavorite.esm.js new file mode 100644 index 000000000000..94164b12e587 --- /dev/null +++ b/web_edit_user_filter/static/src/js/customFavorite.esm.js @@ -0,0 +1,52 @@ +/** @odoo-module **/ + +import {CustomFavoriteItem} from "@web/search/favorite_menu/custom_favorite_item"; +import {patch} from "@web/core/utils/patch"; + +patch(CustomFavoriteItem.prototype, "web_edit_user_filter.CustomFavoriteItem", { + /** + * @param {Event} ev + */ + saveFavorite(ev) { + if (!this.state.description) { + this.notificationService.add( + this.env._t("A name for your favorite filter is required."), + {type: "danger"} + ); + ev.stopPropagation(); + return this.descriptionRef.el.focus(); + } + var searchItems = this.env.searchModel.getSearchItems( + (s) => s.type === "favorite" + ); + const favorites = searchItems.filter((f) => f.description === this.state.description) + if (favorites.length) { + this.notificationService.add( + this.env._t("A filter with same name already exists."), + { + type: "danger", + } + ); + ev.stopPropagation(); + return this.descriptionRef.el.focus(); + } + const {description, isDefault, isShared} = this.state; + var facets = this.env.searchModel.facets; + const facet = JSON.stringify(facets); + this.env.searchModel.createNewFavorite({ + description, + isDefault, + isShared, + facet, + }); + + Object.assign(this.state, { + description: this.env.config.getDisplayName(), + isDefault: false, + isShared: false, + open: false, + }); + }, +}); + +export default CustomFavoriteItem; diff --git a/web_edit_user_filter/static/src/js/searchBar.esm.js b/web_edit_user_filter/static/src/js/searchBar.esm.js new file mode 100644 index 000000000000..59be0270f1f3 --- /dev/null +++ b/web_edit_user_filter/static/src/js/searchBar.esm.js @@ -0,0 +1,200 @@ +/** @odoo-module **/ + +import {SearchBar} from "@web/search/search_bar/search_bar"; +import {patch} from "@web/core/utils/patch"; +import {qweb} from "web.core"; +import {_t} from "@web/core/l10n/translation"; +import {useService} from "@web/core/utils/hooks"; + + +patch(SearchBar.prototype, "web_edit_user_filter.SearchBar", { + setup() { + this.notificationService = useService("notification"); + var self = this; + this._super(...arguments); + $("body").on("click", ".o_searchview_facet", function (ev) { + $(ev.currentTarget).popover("dispose"); + if ($(ev.currentTarget).hasClass("o_facet_remove")) { + return; + } + var facet_type = $(this).attr("data-type"); + var facetId = $(this).attr("data-gp"); + self._process_filters($(this), facet_type, facetId); + }); + }, + + _process_filters($el, facet_type, facetId) { + var searchItems = this.env.searchModel.getSearchItems( + (facet) => facet.type === facet_type + ); + + var selectedFacet = searchItems.filter( + (f) => f.groupId == facetId && f.isActive === true + ); + + if (!selectedFacet.length) { + return; + } + if (facet_type === "favorite") { + var FavFacets = []; + var currentFacet = searchItems.filter( + (f) => f.type === facet_type && f.groupId == facetId + ); + if (currentFacet[0].groupBys.length) { + _.each(currentFacet[0].groupBys, function (description) { + FavFacets.push( + searchItems.filter( + (f) => f.type === "groupBy" && f.fieldName === description + )[0] + ); + }); + } + } + var $facet = $($el); + var $content = $( + qweb.render("web_edit_user_filter.Popover", { + values: selectedFacet, + }) + ); + $content.find(".list-group-item").on("click", (ev) => { + var self = this; + var PopOverContainer = $(".o_searchview"); + var type = $(ev.currentTarget).data("type"); + var facetIdEl = $(ev.currentTarget).data("id"); + if (type === "filter") { + var searchItems = this.env.searchModel.getSearchItems( + (facet) => facet.type === type + ); + + var FacetSelected = searchItems.filter((f) => f.id == facetIdEl); + + if (FacetSelected[0].hasOptions) { + var OptionSelected = FacetSelected[0].options.filter(function ( + option + ) { + return option.isActive === true; + }); + _.each(OptionSelected, function (option) { + this.env.searchModel.toggleDateFilter(facetIdEl, option.id); + }); + } else { + this.env.searchModel.toggleSearchItem(facetIdEl); + } + } else if (type === "groupBy" || type === "field") { + this.env.searchModel.toggleSearchItem(facetIdEl); + } else if (type === "favorite") { + ev.stopImmediatePropagation(); + var facet = this.env.searchModel.getSearchItems( + (f) => f.type === type && f.id === facetIdEl + ); + self._unpackFilter(facet[0]); + } + $(this).remove(); + $(PopOverContainer).find(".popover").popover("hide"); + }); + var $container = $(".o_searchview"); + $facet.popover({ + title: _t( + 'Edit Filters ×' + ), + template: qweb.render("web_edit_user_filter.PopoverTemplate"), + content: $content, + container: $container, + html: true, + trigger: "manual", + placement: "bottom", + animation: false, + }); + var PopOverContainer = $(".o_searchview"); + $(PopOverContainer).find(".popover").popover("hide"); + $facet.popover("show"); + }, + + _unpackFilter(filter) { + this.env.searchModel.toggleSearchItem(filter.id); + var facets = JSON.parse(filter.facet); + var convFacets = []; + _.each(facets, (facet) => { + if (facet.type === "filter") { + _.each(facet.values, (fc) => { + var fetchedFilter = this.env.searchModel.getSearchItems( + (f) => f.type === "filter" && f.description == fc + ); + if (fetchedFilter.length) { + convFacets.push( + fetchedFilter + ); + } else { + var tentativeFilter = this.env.searchModel.getSearchItems( + (f) => f.description === facet.title && f.type === "filter" + ); + if (tentativeFilter.length) { + _.each(tentativeFilter, (f) => { + if (f.hasOptions) { + var trueOption = ""; + _.each(f.options, function (option) { + var str = fc.split(": ").pop().split(" ")[0]; + if (str === option.description) { + trueOption = option.id; + } + }); + if (trueOption !== "") { + this.env.searchModel.toggleDateFilter(f.id, trueOption); + } + } + }); + } else { + const preFilter = { + description: facet.title, + domain: filter.domain, + type: "filter", + }; + this.env.searchModel.createNewFilters([preFilter]); + } + } + }); + } else if (facet.type === "groupBy") { + _.each(facet.values, (fc) => { + var fetchedGroup = this.env.searchModel.getSearchItems( + (f) => f.description === fc && f.type === "groupBy" + ); + if (fetchedGroup.length) { + convFacets.push( + fetchedGroup + ); + } else { + var tentativeFilter = this.env.searchModel.getSearchItems( + (f) => f.description === facet.title && f.type === "groupBy" + ); + if (tentativeFilter.length) { + _.each(tentativeFilter, (f) => { + if (f.hasOptions) { + var trueOption = ""; + _.each(f.options, (option) => { + var str = fc.split(": ").pop().split(" ")[0]; + if (str === option.description) { + trueOption = option.id; + } + }); + if (trueOption !== "") { + this.env.searchModel.toggleDateFilter(f.id, trueOption); + } + } + }); + } + } + }); + } + }); + if (convFacets.length) { + _.each(convFacets, (facet) => { + this.env.searchModel.toggleSearchItem(facet[0].id); + }); + } + }, +}); +$(document).on("click", ".popover .close", function () { + $(this).parents(".popover").popover("hide"); +}); + +export default SearchBar; diff --git a/web_edit_user_filter/static/src/js/searchModel.esm.js b/web_edit_user_filter/static/src/js/searchModel.esm.js new file mode 100644 index 000000000000..cdcb7e717261 --- /dev/null +++ b/web_edit_user_filter/static/src/js/searchModel.esm.js @@ -0,0 +1,31 @@ +/** @odoo-module **/ + +import {SearchModel} from "@web/search/search_model"; +import {patch} from "@web/core/utils/patch"; + +patch(SearchModel.prototype, "web_edit_user_filter.SearchModel", { + _getIrFilterDescription(params) { + var {preFavorite, irFilter} = this._super(...arguments); + if ("facet" in params) { + preFavorite.facet = params.facet; + irFilter.facet = params.facet; + } + return {preFavorite, irFilter}; + }, + + /** + * Returns a filter of type 'favorite' starting from an ir_filter comming from db. + * @private + * @param {Object} irFilter + * @returns {Object} + */ + _irFilterToFavorite(irFilter) { + var favorite = this._super(...arguments); + if (irFilter.facet) { + favorite.facet = irFilter.facet; + } + return favorite; + }, +}); + +export default SearchModel; diff --git a/web_edit_user_filter/static/src/scss/backend.scss b/web_edit_user_filter/static/src/scss/backend.scss index eb0c8cd1c845..84616934be1e 100644 --- a/web_edit_user_filter/static/src/scss/backend.scss +++ b/web_edit_user_filter/static/src/scss/backend.scss @@ -2,14 +2,14 @@ * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ .o_favorites_menu { - .o-edit-user-filter { + .o_edit_user_filter { @include o-position-absolute(50%, 30px); margin-top: -6px; cursor: pointer; } } -.o-edit-user-filter-popover { +.o_edit_user_filter_popover { a { cursor: pointer; padding: 0.3rem 0.75rem; @@ -22,6 +22,6 @@ } } -.o-edit-user-filter-editable { +.o_edit_user_filter_editable { cursor: pointer; } diff --git a/web_edit_user_filter/static/src/xml/backend.xml b/web_edit_user_filter/static/src/xml/backend.xml index b987a3aa4da1..1f97eb5282c2 100644 --- a/web_edit_user_filter/static/src/xml/backend.xml +++ b/web_edit_user_filter/static/src/xml/backend.xml @@ -1,19 +1,36 @@ - + diff --git a/web_edit_user_filter/static/src/xml/search_extended.xml b/web_edit_user_filter/static/src/xml/search_extended.xml index 49c7cf556483..d109bc5d25be 100644 --- a/web_edit_user_filter/static/src/xml/search_extended.xml +++ b/web_edit_user_filter/static/src/xml/search_extended.xml @@ -1,14 +1,14 @@ - - facet.type - facet.groupId + + facet.type + facet.groupId