Open josegar74 opened 1 year ago
@fxprunayre
I have done some tests, changing this code:
Test 1:
if (angular.equals(params, gnSearchLocation.getParams())) {
triggerSearchFn(false);
} else {
triggerSearchFn(false);
//gnSearchLocation.setSearch(params);
}
When clicking the Reset
button, this seems working cleaning the search fields in the form and issuing a new search, but the URL hash keeps old values.
Doing a search, looks ok.
Test 2:
if (angular.equals(params, gnSearchLocation.getParams())) {
triggerSearchFn(false);
} else {
triggerSearchFn(false);
gnSearchLocation.setSearch(params);
}
When clicking the Reset
button, this seems working cleaning the search fields in the form and issuing a new search, updates the URL hash value. And only issues 1 search to the backend (A bit surprising as initially I was expecting 2).
But doing a search, issues 2 searches to the backend.
It's a bit unclear why it seems sometimes the search triggers a function that prepares and executes the query to ElasticSearch:
And in some other cases, it seems doing that using the $location
directive. What is the criteria for this?
I would reset lastSearchUrl
gnSearchLocation.lastSearchUrl = null;
What do you think ?
@fxprunayre I've tried and it seems working.
I don't fully understand the logic to handle this, but apparently the change works.
Describe the bug Search reset button should clean up the search fields and trigger a search to show all the results.
In some cases, the button is clicked and nothing happens. Clicking it a second time, works fine.
The issue happens in
3.12.x
andmain
branches.To Reproduce Steps to reproduce the behavior:
Case 1:
Case 2:
Expected behavior Clicking the Reset button once, cleanups the search fields and executes an empty search to return all the results.
Additional context
The code involved it's https://github.com/geonetwork/core-geonetwork/blob/2731e560fd9e3a8cea16047082cf557d3c0978c5/web-ui/src/main/resources/catalog/components/search/searchmanager/SearchFormDirective.js#L321-L325
When it doesn't work, executes:
https://github.com/geonetwork/core-geonetwork/blob/2731e560fd9e3a8cea16047082cf557d3c0978c5/web-ui/src/main/resources/catalog/components/search/searchmanager/SearchFormDirective.js#L324
the next time, that works, enters in:
https://github.com/geonetwork/core-geonetwork/blob/2731e560fd9e3a8cea16047082cf557d3c0978c5/web-ui/src/main/resources/catalog/components/search/searchmanager/SearchFormDirective.js#L322
But if you go directly to the search page, do a search and click reset (that seems working), executes also:
https://github.com/geonetwork/core-geonetwork/blob/2731e560fd9e3a8cea16047082cf557d3c0978c5/web-ui/src/main/resources/catalog/components/search/searchmanager/SearchFormDirective.js#L324
A bit unclear what is causing this wrong behaviour.