[REF] web: search: remove support of domain parts

Since the dashboard view has been removed, there was no more true usage
of setDomainParts. We thus remove the support of domain parts.

Part-of: odoo/odoo#118057
This commit is contained in:
Mathieu Duckerts-Antoine
2023-04-13 17:57:12 +02:00
parent d9b1d8f32f
commit 4b078525b5
@@ -260,7 +260,6 @@ export class SearchModel extends EventBus {
if (config.state) {
this._importState(config.state);
this.__legacyParseSearchPanelArchAnyway(searchViewDescription, searchViewFields);
this.domainParts = {};
this.display = this._getDisplay(config.display);
if (!this.searchPanelInfo.loaded) {
return this._reloadSections();
@@ -277,9 +276,6 @@ export class SearchModel extends EventBus {
this.nextGroupId = 1;
this.nextGroupNumber = 1;
// ... to rework (API for external domain, groupBy, facet)
this.domainParts = {}; // put in state?
const searchDefaults = {};
const searchPanelDefaults = {};
@@ -636,13 +632,6 @@ export class SearchModel extends EventBus {
const searchItem = this.searchItems[queryElem.searchItemId];
return searchItem.groupId !== groupId;
});
for (const partName in this.domainParts) {
const part = this.domainParts[partName];
if (part.groupId === groupId) {
this.setDomainParts({ [partName]: null });
}
}
this._checkComparisonStatus();
this._notify();
}
@@ -677,19 +666,6 @@ export class SearchModel extends EventBus {
return state;
}
getDomainPart(partName) {
const part = this.domainParts[partName] || null;
if (part) {
return deepCopy(part);
}
return part;
}
getDomainParts() {
const copy = deepCopy(this.domainParts);
return sortBy(Object.values(copy), (part) => part.groupId);
}
getFullComparison() {
let searchItem = null;
for (const queryElem of this.query.slice().reverse()) {
@@ -797,20 +773,6 @@ export class SearchModel extends EventBus {
this.trigger("update");
}
setDomainParts(parts) {
for (const key in parts) {
const val = parts[key];
if (!val) {
delete this.domainParts[key];
} else {
this.domainParts[key] = val;
val.groupId = this.nextGroupId++;
}
}
this._notify();
}
/**
* Set the active value id of a given category.
* @param {number} sectionId
@@ -1523,9 +1485,6 @@ export class SearchModel extends EventBus {
domains.push(groupDomain);
}
for (const { domain } of this.getDomainParts()) {
domains.push(domain);
}
// we need to manage (optional) facets, deactivateGroup, clearQuery,...
if (this.display.searchPanel && withSearchPanel) {
@@ -1609,16 +1568,6 @@ export class SearchModel extends EventBus {
facets.push(facet);
}
for (const { facetLabel, groupId } of this.getDomainParts()) {
const type = "filter";
facets.push({
groupId,
type,
values: [facetLabel],
icon: FACET_ICONS[type],
});
}
return facets;
}