From b550f0fee419fabd5f452f4c0423c0e68f12593a Mon Sep 17 00:00:00 2001 From: alokhyland Date: Tue, 27 Feb 2024 18:41:40 +0530 Subject: [PATCH] WEBUI-1386: Fix Saved Search restoration/execution with hierarchical vocabularies --- elements/search/nuxeo-search-form.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/elements/search/nuxeo-search-form.js b/elements/search/nuxeo-search-form.js index fcdb825b8a..f0b3058310 100644 --- a/elements/search/nuxeo-search-form.js +++ b/elements/search/nuxeo-search-form.js @@ -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 @@ -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(); @@ -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() {