Skip to content

Commit

Permalink
WEBUI-1386: Fix Saved Search restoration/execution with hierarchical …
Browse files Browse the repository at this point in the history
…vocabularies
  • Loading branch information
alokhyland committed Mar 6, 2024
1 parent 855f32c commit 38900d6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions elements/search/nuxeo-search-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,20 @@ Polymer({
paramMutator: {
type: Function,
value() {
return function(params) {
return function(params, modifyPayload = false) {
const result = {};
if (params) {
// filter null values
Object.keys(params).forEach((param) => {
const value = params[param];
if (value !== null && param !== 'dc:title') {
result[param] = typeof value === 'boolean' ? value.toString() : value;
if (modifyPayload && Array.isArray(value)) {
result[param] = value.map((item) =>
item && item['entity-type'] ? item.uid || `${item.properties.parent}/${item.id}` : item,
);
} else {
result[param] = typeof value === 'boolean' ? value.toString() : value;
}
}
});
// allow search to be visible on JSF UI
Expand Down Expand Up @@ -767,7 +773,7 @@ Polymer({
if (this._isSavedSearch()) {
this.isSavedSearch = true;
this.selectedSearch = this._searches[this.selectedSearchIdx - 1];
this.params = this._mutateParams(this.selectedSearch.params);
this.params = this._mutateParams(this.selectedSearch.params, true);
this._navigateToResults();
} else {
this._clear();
Expand Down Expand Up @@ -926,8 +932,8 @@ Polymer({
});
},

_mutateParams(params) {
return this.paramMutator ? this.paramMutator(params) : params;
_mutateParams(params, modifyPayload) {
return this.paramMutator ? this.paramMutator(params, modifyPayload) : params;
},

_computeSavedSearchesParams() {
Expand Down

0 comments on commit 38900d6

Please sign in to comment.