Skip to content

Commit

Permalink
refactor this.filters --> this.searchComponentVms for explicit clarit…
Browse files Browse the repository at this point in the history
…y, re #10804
  • Loading branch information
whatisgalen committed Jul 30, 2024
1 parent a7c5546 commit f5e5acb
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ define([
options.loading(false);
});

this.filters[componentName](this);
this.searchComponentVms[componentName](this);
},

updateQuery: function() {
Expand Down
4 changes: 2 additions & 2 deletions arches/app/media/js/views/components/search/base-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define([
this.requiredFilters = this.getRequiredFilters(this.componentName);
this.requiredFiltersLoaded = ko.computed(function() {
let res = true;
Object.entries(this.filters).forEach(function([componentName, filter]) {
Object.entries(this.searchComponentVms).forEach(function([componentName, filter]) {
res = res && filter !== null;
});
return res;
Expand All @@ -27,7 +27,7 @@ define([


getFilter: function(filterName) {
return ko.unwrap(this.filters[filterName]);
return ko.unwrap(this.searchComponentVms[filterName]);
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define([
this.requiredFilters = this.getRequiredFilters(this.componentName);
this.requiredFiltersLoaded = ko.computed(function() {
let res = true;
Object.entries(this.filters).forEach(function([componentName, filter]) {
Object.entries(this.searchComponentVms).forEach(function([componentName, filter]) {
res = res && filter !== null;
});
return res;
Expand Down Expand Up @@ -99,11 +99,11 @@ define([
},

getFilter: function(filterName) {
return ko.unwrap(this.filters[filterName]);
return ko.unwrap(this.searchComponentVms[filterName]);
},

clearQuery: function(){
Object.values(this.filters).forEach(function(value){
Object.values(this.searchComponentVms).forEach(function(value){
if (value()){
if (value().clear){
value().clear();
Expand Down
2 changes: 1 addition & 1 deletion arches/app/media/js/views/components/search/map-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ define([
updateSearchResultPointLayer();
};

this.filters[componentName](this);
this.searchComponentVms[componentName](this);
this.map.subscribe(function(){
this.setupDraw();
this.restoreState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ define([
this.updateResults();
}, this);

this.filters[componentName](this);
this.searchComponentVms[componentName](this);
this.restoreState();
this.pageInitialized = true;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ define([
this.updateQuery();
}, this);

this.filters[componentName](this);
this.searchComponentVms[componentName](this);
},

updateQuery: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ define([
// because we need to pass the entire rsearch results filter into the
// related resources filter
var setSearchResults = function(){
options.searchResultsVm = self.getFilter('search-results');
options.searchResultsVm = self.getFilterByType('search-results');
options.searchResultsVm.relatedResourcesManager = self;
options.filters[componentName](self);
options.searchComponentVms[componentName](self);
self.ready(true);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ define([
this.updateQuery();
}, this);

this.filters[componentName](this);
this.searchComponentVms[componentName](this);

if (this.requiredFiltersLoaded() === false) {
this.requiredFiltersLoaded.subscribe(function() {
Expand Down
4 changes: 2 additions & 2 deletions arches/app/media/js/views/components/search/saved-searches.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define([
const componentName = 'saved-searches';
const viewModel = function(params) {
var self = this;
self.filters = params.filters;
self.searchComponentVms = params.searchComponentVms;


self.urls = arches.urls;
Expand All @@ -29,7 +29,7 @@ define([
searchUrl: search.SEARCH_URL[arches.activeLanguage].value
});
});
self.filters[componentName](self);
self.searchComponentVms[componentName](self);
});

self.options = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define([
var setSearchResults = function(){
options.searchResultsVm = self.getFilterByType('search-results');
options.searchResultsVm.details = self;
options.filters[componentName](self);
options.searchComponentVms[componentName](self);
};

if (this.requiredFiltersLoaded() === false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ define([
this.updateResults();
}, this);

this.filters[componentName](this);
this.searchComponentVms[componentName](this);
this.restoreState();
if (this.requiredFiltersLoaded() === false) {
this.requiredFiltersLoaded.subscribe(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define([
BaseFilter.prototype.initialize.call(this, options);

this.filter = ko.observable('');
this.filters[componentName](this);
this.searchComponentVms[componentName](this);

this.filter.subscribe(function(){
this.updateQuery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ define([
this.selectedPopup(componentname);
}
};
this.filters[componentName](this);
this.searchComponentVms[componentName](this);
},

});
Expand Down
4 changes: 2 additions & 2 deletions arches/app/media/js/views/components/search/term-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ define([
return tag.value.type === currentTag.type;
}, this);
if(!found){
_.each(this.filters, function(filter){
_.each(this.searchComponentVms, function(filter){
if(!!filter() && filter().name === tag.value.type){
filter().clear();
}
Expand All @@ -52,7 +52,7 @@ define([
}, this);
}, this, "arrayChange");

this.filters[componentName](this);
this.searchComponentVms[componentName](this);
this.restoreState();
},

Expand Down
2 changes: 1 addition & 1 deletion arches/app/media/js/views/components/search/time-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ define([
this.filterChanged.subscribe(function() {
this.updateQuery();
}, this);
this.filters[componentName](this);
this.searchComponentVms[componentName](this);
},

updateQuery: function() {
Expand Down
6 changes: 3 additions & 3 deletions arches/app/media/js/views/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ define([
};

var CommonSearchViewModel = function() {
this.filters = {};
this.searchComponentVms = {};
this.filtersList = Object.values(SearchComponents);
this.defaultSearchLogicComponent = this.filtersList.find(component => component.type == "search-logic" && component.config.default == true); // approach: let the backend decide
this.searchLogicComponentName = ko.observable(false);
Expand Down Expand Up @@ -71,10 +71,10 @@ define([
const filter = this.filtersList.find(component => component.type == type);
if (!filter)
return null;
return ko.unwrap(this.filters[filter.componentname]);
return ko.unwrap(this.searchComponentVms[filter.componentname]);
};
Object.values(SearchComponents).forEach(function(component) {
this.filters[component.componentname] = ko.observable(null);
this.searchComponentVms[component.componentname] = ko.observable(null);
}, this);
this.query = ko.observable(getQueryObject());
if (this.query()["search-logic"] !== undefined) {
Expand Down

0 comments on commit f5e5acb

Please sign in to comment.