Skip to content

Commit

Permalink
refactor search_component types to componentname-type concat, update …
Browse files Browse the repository at this point in the history
…refs re #10804
  • Loading branch information
whatisgalen committed Aug 14, 2024
1 parent beaa8f7 commit a10ed1c
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ define([
});
queryObj[componentName] = JSON.stringify(advanced);

if (this.getFilterByType('term-filter').hasTag(this.tagId) === false) {
this.getFilterByType('term-filter').addTag(this.tagId, this.name, ko.observable(false));
if (this.getFilterByType('term-filter-type').hasTag(this.tagId) === false) {
this.getFilterByType('term-filter-type').addTag(this.tagId, this.name, ko.observable(false));
}
} else {
delete queryObj[componentName];
this.getFilterByType('term-filter').removeTag(this.tagId);
this.getFilterByType('term-filter-type').removeTag(this.tagId);
}
this.query(queryObj);
},
Expand All @@ -223,7 +223,7 @@ define([
var facets = JSON.parse(query[componentName]);

if (facets.length > 0) {
this.getFilterByType('term-filter').addTag("Advanced Search", this.name, ko.observable(false));
this.getFilterByType('term-filter-type').addTag("Advanced Search", this.name, ko.observable(false));
}
_.each(facets, function(facet) {
var nodeIds = _.filter(Object.keys(facet), function(key) {
Expand Down
8 changes: 4 additions & 4 deletions arches/app/media/js/views/components/search/map-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ define([
var self = this;
var queryObj = this.query();
if (this.filter.feature_collection().features.length > 0) {
if (this.getFilterByType('term-filter').hasTag(this.type) === false) {
this.getFilterByType('term-filter').addTag('Map Filter Enabled', this.name, this.filter.inverted);
if (this.getFilterByType('term-filter-type').hasTag(this.type) === false) {
this.getFilterByType('term-filter-type').addTag('Map Filter Enabled', this.name, this.filter.inverted);
}
this.filter.feature_collection().features[0].properties['inverted'] = this.filter.inverted();
queryObj[componentName] = ko.toJSON(this.filter.feature_collection());
Expand Down Expand Up @@ -553,7 +553,7 @@ define([
this.bufferUnit = ko.observable(bufferUnit).extend({ deferred: true });
this.filter.inverted = ko.observable(inverted).extend({ deferred: true });
if (hasSpatialFilter) {
this.getFilterByType('term-filter').addTag('Map Filter Enabled', this.name, this.filter.inverted);
this.getFilterByType('term-filter-type').addTag('Map Filter Enabled', this.name, this.filter.inverted);
}
this.updateResults();
this.pageLoaded = true;
Expand Down Expand Up @@ -582,7 +582,7 @@ define([
"type": "FeatureCollection",
"features": []
});
this.getFilterByType('term-filter').removeTag('Map Filter Enabled');
this.getFilterByType('term-filter-type').removeTag('Map Filter Enabled');
this.draw.deleteAll();
this.searchGeometries([]);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ define([
if (provisionalQuery.length > 0) {
provisionalQuery.forEach(function(type){
type.inverted = ko.observable(!!type.inverted);
this.getFilterByType('term-filter').addTag(type.provisionaltype, this.name, type.inverted);
this.getFilterByType('term-filter-type').addTag(type.provisionaltype, this.name, type.inverted);
}, this);
this.filter(provisionalQuery);
}
Expand All @@ -57,12 +57,12 @@ define([

selectProvisional: function(item) {
this.filter().forEach(function(val){
this.getFilterByType('term-filter').removeTag(val.provisionaltype);
this.getFilterByType('term-filter-type').removeTag(val.provisionaltype);
}, this);

if(!!item){
var inverted = ko.observable(false);
this.getFilterByType('term-filter').addTag(item.name, this.name, inverted);
this.getFilterByType('term-filter-type').addTag(item.name, this.name, inverted);
this.filter([{provisionaltype: item.name, inverted: inverted}]);

}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define([
};
this.searchFilterVms[componentName](this);

this.searchResultsVm = self.getFilterByType('search-results', false);
this.searchResultsVm = self.getFilterByType('search-results-type', false);
if (ko.unwrap(this.searchResultsVm)) {
this.searchResultsVm = this.searchResultsVm();
setSearchResults();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define([
if (resourceTypeQuery.length > 0) {
resourceTypeQuery.forEach(function(type){
type.inverted = ko.observable(!!type.inverted);
this.getFilterByType('term-filter').addTag(type.name, this.name, type.inverted);
this.getFilterByType('term-filter-type').addTag(type.name, this.name, type.inverted);
}, this);
this.filter(resourceTypeQuery);
}
Expand All @@ -78,11 +78,11 @@ define([

selectModelType: function(item){
this.filter().forEach(function(item){
this.getFilterByType('term-filter').removeTag(item.name);
this.getFilterByType('term-filter-type').removeTag(item.name);
}, this);
if(!!item){
var inverted = ko.observable(false);
this.getFilterByType('term-filter').addTag(item.name, this.name, inverted);
this.getFilterByType('term-filter-type').addTag(item.name, this.name, inverted);
this.filter([{graphid:item.graphid, name: item.name, inverted: inverted}]);
}else{
this.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define([
self.searchResultsVm().details = self;
};

this.searchResultsVm = this.getFilterByType('search-results', false);
this.searchResultsVm = this.getFilterByType('search-results-type', false);
if (ko.unwrap(this.searchResultsVm)) {
setSearchResults();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ define([

this.searchFilterVms[componentName](this);
this.restoreState();
this.mapFilter = this.getFilterByType("map-filter", false);
this.mapFilter = this.getFilter("map-filter", false);
if (ko.unwrap(this.mapFilter)) {
this.mapFilter = this.mapFilter();
this.selectedTab.subscribe(function (tab) {
Expand Down
6 changes: 3 additions & 3 deletions arches/app/media/js/views/components/search/time-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ define([

this.filterChanged = ko.computed(function(){
if(!!this.filter.fromDate() || !!this.filter.toDate()){
this.getFilterByType('term-filter').addTag(this.name, this.name, this.filter.inverted);
this.getFilterByType('term-filter-type').addTag(this.name, this.name, this.filter.inverted);
}
return ko.toJSON(this.filter);
}, this).extend({ deferred: true });
Expand Down Expand Up @@ -147,7 +147,7 @@ define([
if (componentName in query) {
var timeQuery = JSON.parse(query[componentName]);
this.filter.inverted(!!timeQuery.inverted);
this.getFilterByType('term-filter').addTag(this.name, this.name, this.filter.inverted);
this.getFilterByType('term-filter-type').addTag(this.name, this.name, this.filter.inverted);
['fromDate', 'toDate', 'dateNodeId'].forEach(function(key) {
if (key in timeQuery) {
this.filter[key](timeQuery[key]);
Expand Down Expand Up @@ -179,7 +179,7 @@ define([
this.filter.dateNodeId(null);
this.filter.inverted(false);
this.dateRangeType('custom');
this.getFilterByType('term-filter').removeTag(this.name);
this.getFilterByType('term-filter-type').removeTag(this.name);
this.selectedPeriod(null);
return;
}
Expand Down
17 changes: 17 additions & 0 deletions arches/app/models/migrations/10804_core_search_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ class Migration(migrations.Migration):
UPDATE search_component SET config = '{"layoutType":"popup"}' where componentname in ('time-filter', 'saved-searches', 'search-export');
UPDATE search_component SET type = 'term-filter' where componentname = 'term-filter';
UPDATE search_component SET componentpath = null where componentpath = '';
UPDATE search_component SET type = componentname || '-type'
WHERE componentname IN (
'advanced-search',
'related-resources-filter',
'search-result-details',
'search-results',
'map-filter',
'time-filter',
'saved-searches',
'search-export',
'term-filter',
'paging-filter',
'provisional-filter',
'resource-type-filter',
'sort-results',
);
"""
reverse_sql = """
Expand All @@ -49,6 +65,7 @@ class Migration(migrations.Migration):
UPDATE search_component SET type = 'results-list' where componentname = 'search-results';
UPDATE search_component SET type = 'text-input' where componentname = 'term-filter';
UPDATE search_component SET componentpath = '' where componentpath is null;
UPDATE search_component SET type = 'filter' where type like '%-type';
"""

operations = [
Expand Down

0 comments on commit a10ed1c

Please sign in to comment.