Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
50
web_search_with_and/static/src/js/search_bar.esm.js
Executable file
50
web_search_with_and/static/src/js/search_bar.esm.js
Executable file
@@ -0,0 +1,50 @@
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
import {SearchBar} from "@web/search/search_bar/search_bar";
|
||||
|
||||
patch(SearchBar.prototype, {
|
||||
selectItem(item) {
|
||||
if (item.isAddCustomFilterButton) {
|
||||
return this.env.searchModel.spawnCustomFilterDialog();
|
||||
}
|
||||
|
||||
const searchItem = this.getSearchItem(item.searchItemId);
|
||||
if (
|
||||
(searchItem.type === "field" && searchItem.fieldType === "properties") ||
|
||||
(searchItem.type === "field_property" && item.unselectable)
|
||||
) {
|
||||
this.toggleItem(item, !item.isExpanded);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item.unselectable) {
|
||||
const {searchItemId, label, operator, value} = item;
|
||||
const autoCompleteValues = {
|
||||
label,
|
||||
operator,
|
||||
value,
|
||||
isShiftKey: this.isShiftKey,
|
||||
};
|
||||
if (value && value[0] === '"' && value[value.length - 1] === '"') {
|
||||
autoCompleteValues.value = value.slice(1, -1);
|
||||
autoCompleteValues.label = label.slice(1, -1);
|
||||
autoCompleteValues.operator = "=";
|
||||
autoCompleteValues.enforceEqual = true;
|
||||
}
|
||||
this.env.searchModel.addAutoCompletionValues(
|
||||
searchItemId,
|
||||
autoCompleteValues
|
||||
);
|
||||
}
|
||||
|
||||
if (item.loadMore) {
|
||||
item.loadMore();
|
||||
} else {
|
||||
this.resetState();
|
||||
}
|
||||
},
|
||||
|
||||
onSearchKeydown(ev) {
|
||||
this.isShiftKey = ev.shiftKey || false;
|
||||
super.onSearchKeydown(ev);
|
||||
},
|
||||
});
|
||||
82
web_search_with_and/static/src/js/search_model.esm.js
Executable file
82
web_search_with_and/static/src/js/search_model.esm.js
Executable file
@@ -0,0 +1,82 @@
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
import {rankInterval} from "@web/search/utils/dates";
|
||||
import {SearchModel} from "@web/search/search_model";
|
||||
|
||||
patch(SearchModel.prototype, {
|
||||
_getGroups() {
|
||||
const preGroups = [];
|
||||
for (const queryElem of this.query) {
|
||||
const {searchItemId} = queryElem;
|
||||
let {groupId} = this.searchItems[searchItemId];
|
||||
if ("autocompleteValue" in queryElem) {
|
||||
if (queryElem.autocompleteValue.isShiftKey) {
|
||||
groupId = Math.random();
|
||||
}
|
||||
}
|
||||
let preGroup = preGroups.find((group) => group.id === groupId);
|
||||
if (!preGroup) {
|
||||
preGroup = {id: groupId, queryElements: []};
|
||||
preGroups.push(preGroup);
|
||||
}
|
||||
queryElem.groupId = groupId;
|
||||
preGroup.queryElements.push(queryElem);
|
||||
}
|
||||
const groups = [];
|
||||
for (const preGroup of preGroups) {
|
||||
const {queryElements, id} = preGroup;
|
||||
const activeItems = [];
|
||||
for (const queryElem of queryElements) {
|
||||
const {searchItemId} = queryElem;
|
||||
let activeItem = activeItems.find(
|
||||
({searchItemId: id}) => id === searchItemId
|
||||
);
|
||||
if ("generatorId" in queryElem) {
|
||||
if (!activeItem) {
|
||||
activeItem = {searchItemId, generatorIds: []};
|
||||
activeItems.push(activeItem);
|
||||
}
|
||||
activeItem.generatorIds.push(queryElem.generatorId);
|
||||
} else if ("intervalId" in queryElem) {
|
||||
if (!activeItem) {
|
||||
activeItem = {searchItemId, intervalIds: []};
|
||||
activeItems.push(activeItem);
|
||||
}
|
||||
activeItem.intervalIds.push(queryElem.intervalId);
|
||||
} else if ("autocompleteValue" in queryElem) {
|
||||
if (!activeItem) {
|
||||
activeItem = {searchItemId, autocompletValues: []};
|
||||
activeItems.push(activeItem);
|
||||
}
|
||||
activeItem.autocompletValues.push(queryElem.autocompleteValue);
|
||||
} else if (!activeItem) {
|
||||
activeItem = {searchItemId};
|
||||
activeItems.push(activeItem);
|
||||
}
|
||||
}
|
||||
for (const activeItem of activeItems) {
|
||||
if ("intervalIds" in activeItem) {
|
||||
activeItem.intervalIds.sort(
|
||||
(g1, g2) => rankInterval(g1) - rankInterval(g2)
|
||||
);
|
||||
}
|
||||
}
|
||||
groups.push({id, activeItems});
|
||||
}
|
||||
|
||||
return groups;
|
||||
},
|
||||
deactivateGroup(groupId) {
|
||||
this.query = this.query.filter((queryElem) => {
|
||||
return queryElem.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();
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user