Skip to content

Commit

Permalink
define searchQueryId, override doQuery in standard-search-view, re #1…
Browse files Browse the repository at this point in the history
  • Loading branch information
whatisgalen committed Nov 15, 2024
1 parent 920a3fb commit 0bdb2d4
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ define([

this.selectedPopup = ko.observable('');
this.sharedStateObject.selectedPopup = this.selectedPopup;
this.searchQueryId = ko.observable(null);
this.sharedStateObject.searchQueryId = this.searchQueryId;
var firstEnabledFilter = _.find(this.sharedStateObject.searchFilterConfigs, function(filter) {
return filter.config.layoutType === 'tabbed';
}, this);
Expand Down Expand Up @@ -51,6 +53,47 @@ define([
this.searchFilterVms[componentName](this);
},

doQuery: function() {
const queryObj = JSON.parse(this.queryString());
if (self.updateRequest) { self.updateRequest.abort(); }
self.updateRequest = $.ajax({
type: "GET",
url: arches.urls.search_results,
data: queryObj,
context: this,
success: function(response) {
_.each(this.sharedStateObject.searchResults, function(value, key, results) {
if (key !== 'timestamp') {
delete this.sharedStateObject.searchResults[key];
}
}, this);
_.each(response, function(value, key, response) {
if (key !== 'timestamp') {
this.sharedStateObject.searchResults[key] = value;
}
}, this);
this.sharedStateObject.searchResults.timestamp(response.timestamp);
this.searchQueryId(this.sharedStateObject.searchResults.searchqueryid);
this.sharedStateObject.userIsReviewer(response.reviewer);
this.sharedStateObject.userid(response.userid);
this.sharedStateObject.total(response.total_results);
this.sharedStateObject.hits(response.results.hits.hits.length);
this.sharedStateObject.alert(false);
},
error: function(response, status, error) {
const alert = new AlertViewModel('ep-alert-red', arches.translations.requestFailed.title, response.responseJSON?.message);
if(self.updateRequest.statusText !== 'abort'){
this.alert(alert);
}
this.sharedStateObject.loading(false);
},
complete: function(request, status) {
self.updateRequest = undefined;
window.history.pushState({}, '', '?' + $.param(queryObj).split('+').join('%20'));
this.sharedStateObject.loading(false);
}
});
},
});

return ko.components.register(componentName, {
Expand Down

0 comments on commit 0bdb2d4

Please sign in to comment.