Skip to content

Commit

Permalink
[MIG] web_advanced_search: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hanamanth.gollar authored and rven committed Mar 13, 2023
1 parent 1681eef commit 989a042
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 243 deletions.
6 changes: 2 additions & 4 deletions web_advanced_search/__manifest__.py
Expand Up @@ -6,7 +6,7 @@
{
"name": "Advanced search",
"summary": "Easier and more powerful searching tools",
"version": "15.0.1.1.1",
"version": "16.0.1.0.0",
"author": "Therp BV, Tecnativa, Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"maintainers": ["ivantodorovich"],
Expand All @@ -16,9 +16,7 @@
"assets": {
"web.assets_backend": [
"web_advanced_search/static/src/js/**/*.js",
],
"web.assets_qweb": [
"web_advanced_search/static/src/xml/**/*.xml",
],
]
},
}
85 changes: 66 additions & 19 deletions web_advanced_search/static/src/js/RecordPicker.esm.js
Expand Up @@ -2,12 +2,29 @@

import BasicModel from "web.BasicModel";
import {ComponentAdapter} from "web.OwlCompatibility";
import {FieldMany2One} from "web.relational_fields";
import {Dropdown} from "@web/core/dropdown/dropdown";
import FieldManagerMixin from "web.FieldManagerMixin";
import {FieldMany2One} from "web.relational_fields";
import {SelectCreateDialog} from "web.view_dialogs";
import {patch} from "@web/core/utils/patch";
import {session} from "@web/session";

const {Component} = owl;
const {xml} = owl.tags;
const {Component, xml} = owl;

patch(Dropdown.prototype, "dropdown", {
onWindowClicked(ev) {
// This patch is created to prevent the closing of the Filter menu
// when a selection is made in the RecordPicker
if (
$(ev.target.closest("ul.dropdown-menu")).attr("id") !== undefined &&
$(ev.target.closest("ul.dropdown-menu")).attr("id") ===
$("body > ul.dropdown-menu").attr("id")
) {
return;
}
this._super(ev);
},
});

export const FakeMany2oneFieldWidget = FieldMany2One.extend(FieldManagerMixin, {
/**
Expand Down Expand Up @@ -55,6 +72,7 @@ export const FakeMany2oneFieldWidget = FieldMany2One.extend(FieldManagerMixin, {
* Get record
*
* @param {BasicModel} model
* @returns {String}
*/
_get_record: function (model) {
return model.get(this.dataPointID);
Expand All @@ -67,16 +85,6 @@ export const FakeMany2oneFieldWidget = FieldMany2One.extend(FieldManagerMixin, {
this.dataPointID = id;
return this.reset(this._get_record(this.model), event);
},
/**
* Stop propagation of the autocompleteselect event.
* Otherwise, the filter's dropdown will be closed after a selection.
*
* @override to stop propagating autocompleteselect event
*/
start: function () {
this._super(...arguments);
this.$input.on("autocompleteselect", (event) => event.stopPropagation());
},
/**
* Stop propagation of the 'Search more..' dialog click event.
* Otherwise, the filter's dropdown will be closed after a selection.
Expand All @@ -102,17 +110,56 @@ export const FakeMany2oneFieldWidget = FieldMany2One.extend(FieldManagerMixin, {
);
return dialog.open();
},
_onFieldChanged: function (event) {
const self = this;
event.stopPropagation();
if (event.data.changes.dummy.display_name === undefined) {
return this._rpc({
model: this.field.relation,
method: "name_get",
args: [event.data.changes.dummy.id],
context: session.user_context,
}).then(function (result) {
event.data.changes.dummy.display_name = result[0][1];
return (
self
._applyChanges(
event.data.dataPointID,
event.data.changes,
event
)
// eslint-disable-next-line no-empty-function
.then(event.data.onSuccess || function () {})
// eslint-disable-next-line no-empty-function
.guardedCatch(event.data.onFailure || function () {})
);
});
}
return (
this._applyChanges(event.data.dataPointID, event.data.changes, event)
// eslint-disable-next-line no-empty-function
.then(event.data.onSuccess || function () {})
// eslint-disable-next-line no-empty-function
.guardedCatch(event.data.onFailure || function () {})
);
},
});

export class FakeMany2oneFieldWidgetAdapter extends ComponentAdapter {
setup() {
this.env = owl.Component.env;
constructor() {
super(...arguments);
this.env = Component.env;
}
async updateWidget() {
/* eslint-disable no-empty-function */

renderWidget() {
this.widget._render();
}
async renderWidget() {
/* eslint-disable no-empty-function */

get widgetArgs() {
if (this.props.widgetArgs) {
return this.props.widgetArgs;
}
return [this.props.attrs];
}
}

Expand Down
68 changes: 0 additions & 68 deletions web_advanced_search/static/src/js/legacy/AdvancedFilterItem.esm.js

This file was deleted.

93 changes: 0 additions & 93 deletions web_advanced_search/static/src/js/legacy/CustomFilterItem.esm.js

This file was deleted.

20 changes: 0 additions & 20 deletions web_advanced_search/static/src/js/legacy/FilterMenu.esm.js

This file was deleted.

21 changes: 10 additions & 11 deletions web_advanced_search/static/src/js/owl/AdvancedFilterItem.esm.js
@@ -1,16 +1,12 @@
/** @odoo-module **/

import {getHumanDomain} from "../utils.esm";

import config from "web.config";
import DomainSelectorDialog from "web.DomainSelectorDialog";
import Domain from "web.Domain";
import {ComponentAdapter} from "web.OwlCompatibility";

const {Component, hooks} = owl;
const {useRef} = hooks;

export default class AdvancedFilterItem extends Component {
import DomainSelectorDialog from "web.DomainSelectorDialog";
import config from "web.config";
import {getHumanDomain} from "../utils.esm";
import {standaloneAdapter} from "web.OwlCompatibility";
const {Component, useRef} = owl;
class AdvancedFilterItem extends Component {
setup() {
this.itemRef = useRef("dropdown-item");
}
Expand All @@ -29,7 +25,7 @@ export default class AdvancedFilterItem extends Component {
* @returns {DomainSelectorDialog} The opened dialog itself.
*/
onClick() {
const adapterParent = new ComponentAdapter(null, {Component});
const adapterParent = standaloneAdapter({Component});
const dialog = new DomainSelectorDialog(
adapterParent,
this.env.searchModel.resModel,
Expand All @@ -54,4 +50,7 @@ export default class AdvancedFilterItem extends Component {
}
}

AdvancedFilterItem.components = {AdvancedFilterItem};

AdvancedFilterItem.template = "web_advanced_search.AdvancedFilterItem";
export default AdvancedFilterItem;

0 comments on commit 989a042

Please sign in to comment.