Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10804 componentizing core search #10807

Merged
merged 218 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
218 commits
Select commit Hold shift + click to select a range
f5b8466
creates empty method execute_query in base search filter, re #10804
whatisgalen Apr 19, 2024
ecac100
filters for only search components that are enabled, re #10805
whatisgalen Apr 19, 2024
0cd8638
includes request as pos arg on base search filter append_dsl method, …
whatisgalen Apr 19, 2024
dfa1372
includes search_res_obj, request, and response_obj as pos args of exe…
whatisgalen Apr 19, 2024
55361d3
re-arrange pos args in base filter methods, re #10804
whatisgalen Apr 19, 2024
b922d21
removes core search logic out of search_results method, replaced by s…
whatisgalen Apr 19, 2024
138e6dd
moves core search logic from search_results into own search_component…
whatisgalen Apr 19, 2024
cdc9eec
moves localize_descriptors logic into own search_component, LocalizeR…
whatisgalen Apr 19, 2024
7550890
adds details dict to core_search, re #10804
whatisgalen Apr 19, 2024
cba2d87
adds details dict to localize_result_descriptors, re #10804
whatisgalen Apr 19, 2024
cd11e0f
commits migration for 2 new core search filters, re #10804
whatisgalen Apr 19, 2024
2f6cf77
includes components for core-search filters in migration, re #10804
whatisgalen Apr 19, 2024
7611866
commits lightweight ko components for new core-search components, re …
whatisgalen Apr 19, 2024
cada203
commits empty templates for core-search backend filters, re #10804
whatisgalen Apr 19, 2024
4426e32
refactors signature for append_dsl() and post_search_hook() to includ…
whatisgalen Apr 19, 2024
0c97cd9
Revert "refactors signature for append_dsl() and post_search_hook() t…
whatisgalen Apr 19, 2024
c40a676
rm redundant request pos arg, use self.request in search_filter facto…
whatisgalen Apr 19, 2024
1b9da96
minor tweak to migration sortorder update, re #10804
whatisgalen Apr 19, 2024
e703699
rm unused imports in migration, re #10804
whatisgalen Apr 19, 2024
f1a5646
commits core-search filters as request kwargs where search_results ma…
whatisgalen Apr 19, 2024
b8bc867
manually set core-search kwargs on request obj, re #10804
whatisgalen Apr 19, 2024
e5b2adc
conforms references to results to response_obj.results, re #10804
whatisgalen Apr 19, 2024
d034f04
changes pos arg results -> response_object in base.py search-filter, …
whatisgalen Apr 19, 2024
3f79e8f
fixes bug in declaring response_object dict, re #10804
whatisgalen Apr 19, 2024
72bd61d
type checks response_object, leaves unformatted if already json, re #…
whatisgalen Apr 19, 2024
d044f3c
format core-search query kwargs in search_test to json str, re #10804
whatisgalen Apr 19, 2024
8b5c9bd
rm redundant JSONResponse, re #10804
whatisgalen Apr 19, 2024
c2d4aad
includes componentpath, filter type in core-search filters details ob…
whatisgalen Apr 19, 2024
4b2f7a2
reset response_object results equal to None, re #10804
whatisgalen Apr 19, 2024
3326826
adds missing pos arg object called by getattr(object, serialize)(), r…
whatisgalen Apr 19, 2024
bf83bdd
formally declares response_object as dict in search, re #10804
whatisgalen Apr 19, 2024
4c6b966
rename pos arg object to obj to avoid confusion with builtin, re #10804
whatisgalen Apr 19, 2024
65365b9
Revert "rename pos arg object to obj to avoid confusion with builtin,…
whatisgalen Apr 19, 2024
0d5f8d5
pops query before passing response_object to JSONResponse, re #10804
whatisgalen Apr 19, 2024
dd7569f
Revert "adds missing pos arg object called by getattr(object, seriali…
whatisgalen Apr 19, 2024
218ab2b
moves queryStr ko.comptd to commonsearchvm, re #10804
whatisgalen Apr 21, 2024
253538a
rm doQuery method and queryStr subscriptn from search view, re #10804
whatisgalen Apr 21, 2024
c2b51e5
adds addtnl refs for common searchvm, rm unused imports, re #10804
whatisgalen Apr 21, 2024
4c4acc9
imports deps and params as needed in core-search vm, re #10804
whatisgalen Apr 21, 2024
fb42134
moves doQuery method out of search view and into core-search componen…
whatisgalen Apr 21, 2024
dc8453f
Merge branch 'dev/7.6.x' into 10804_componentizing_core_search
apeters May 16, 2024
a07695e
rm unneeded base class overrides, re #10804
whatisgalen May 21, 2024
e77cc27
creates comment in localizedescriptors search component to advise imp…
whatisgalen May 21, 2024
65eccf5
changes searchcomp type of core_search to core, re #10804
whatisgalen May 21, 2024
26388d6
Merge branch '10804_componentizing_core_search' of https://github.com…
whatisgalen May 21, 2024
2921dc1
moves UI from search.htm into core-search.htm; instantiates filter.ty…
whatisgalen May 21, 2024
ffaf660
rm debug el in core-search template, re #10804
whatisgalen May 21, 2024
831e0de
rm redundant backend filter compnt inst, re #10804
whatisgalen May 21, 2024
910406b
replaces django jinja user_can_read with js from basemgr, assigns men…
whatisgalen May 21, 2024
5db6b8a
rm template file for localize-desc search comp, re #10804
whatisgalen May 21, 2024
7926eee
migrates addtnl UI and logic from search view into core-search, re #1…
whatisgalen May 22, 2024
8acb42d
rm log statements, re #10804
whatisgalen May 22, 2024
a9ab811
minor cleanup, setting of default query after clear, re #10804
whatisgalen May 22, 2024
a352c2d
ensures searchfilterfactory uses searchfilter.sortorder; creates meth…
whatisgalen May 22, 2024
53a29b8
iterates through sorted query_dict in search_results, re #10804
whatisgalen May 22, 2024
728335d
fix: ensure json-friendly str quotes in search_test using core-search…
whatisgalen Jun 7, 2024
7034946
Merge branch 'archesproject-dev/7.6.x' into 10804_componentizing_core…
whatisgalen Jun 7, 2024
2ee2de5
fix migration conflict, re #10804
whatisgalen Jun 7, 2024
b5a481e
Merge branch 'archesproject-dev/7.6.x' into 10804_componentizing_core…
whatisgalen Jun 11, 2024
cfd8cf0
commits black lints
whatisgalen Jun 11, 2024
e001ba4
ignore style changes
whatisgalen Jun 11, 2024
8f4e2a8
get requiredFilters from the search_component in db, set on filter.in…
whatisgalen Jun 11, 2024
aac44d0
set and retrieve requiredComponents from backend search components, r…
whatisgalen Jun 11, 2024
006e190
style fixes, re #10804
whatisgalen Jun 12, 2024
ab5474b
change instance default to callable dict in search_component.config, …
whatisgalen Jun 12, 2024
754a4f8
fix searchcomponent.config json default in migration, re #10804
whatisgalen Jun 12, 2024
d1ddd6f
set localize-descriptors as required for core-search comp, re #10804
whatisgalen Jun 12, 2024
3c687a1
declare constant in lieu of broken multi-line statement in core-searc…
whatisgalen Jun 12, 2024
04c4f4d
style changes in core-search, re #10804
whatisgalen Jun 12, 2024
0f8c8f0
make core-search require other comps vs other way around, re #10804
whatisgalen Jun 13, 2024
c056bd7
update details objs in indiv search comp classes, re #10804
whatisgalen Jun 13, 2024
9af28b2
integrate localize_descriptors into search-results component, rm refs…
whatisgalen Jun 19, 2024
5677582
Merge branch 'archesproject-dev/7.6.x' into 10804_componentizing_core…
whatisgalen Jun 19, 2024
57a4287
conform migration to latest sequence, re #10804
whatisgalen Jun 19, 2024
1ec9a61
fix: search filters getRequiredFilters fn, only query enabled search_…
whatisgalen Jun 19, 2024
28275a1
refactor: search template to only instantiate core-filter, identify c…
whatisgalen Jun 19, 2024
3c7775c
create_search_query_dict method, implmnt pattern for core= url reques…
whatisgalen Jun 19, 2024
7322ce2
rm refs to explicit core-search query param, re #10804
whatisgalen Jun 20, 2024
468cce1
only send core search component requiredFilters in searchview resp, r…
whatisgalen Jun 20, 2024
3aa01a9
only add search-export if listed in core cmpnt requiredFilters, re #1…
whatisgalen Jun 20, 2024
3ec85d9
include search-results in core-search requiredComponents, re #10804
whatisgalen Jun 20, 2024
44c92cf
minor updates to requiredComponents sortorder, core-search template, …
whatisgalen Jun 22, 2024
90609c5
make core-search extend BaseFilter, re #10804
whatisgalen Jun 22, 2024
705528a
enforce requiredComponentSortorder among searchview response dict, re…
whatisgalen Jun 22, 2024
737d5ed
require core_component in base filter helper methods, re #10804
whatisgalen Jun 22, 2024
744bc48
rm sortorder, enabled fields from searchComponent model, re #10804
whatisgalen Jun 22, 2024
650502a
rm sorting in searchView resp, re #10804
whatisgalen Jun 22, 2024
07c342d
fix: sql syntax errors in migration, re #10804
whatisgalen Jun 23, 2024
4867533
cleanup core-search vm re #10804
whatisgalen Jun 25, 2024
f923874
rename arches coreSearch component, update name refs, create CoreSear…
whatisgalen Jul 2, 2024
9406339
create request_handler method on core_component class, move logic out…
whatisgalen Jul 2, 2024
0848147
make componentpath non-unique so new components can reuse frontend vm…
whatisgalen Jul 2, 2024
b0cafba
rm commented requiredFilters decs on frontend, re #10804
whatisgalen Jul 2, 2024
9395ce0
refactor search_filter_factory helper methods, re #10804
whatisgalen Jul 2, 2024
3e445c7
fix super() in CoreSearchComponent class, re #10804
whatisgalen Jul 2, 2024
8613b83
pass component name to class method when instantiating core search co…
whatisgalen Jul 2, 2024
aa4898b
check for kwarg core in search query before del, re #10804
whatisgalen Jul 2, 2024
a89554c
fix misnamed var in search_results, re #10804
whatisgalen Jul 2, 2024
93709bc
revert migration model change for non-unique searchcomponentname, re …
whatisgalen Jul 2, 2024
78deaf5
create generic core-search-component on frontend, make arches-core-se…
whatisgalen Jul 2, 2024
1d1b7be
minor cleanup of code, re #10804
whatisgalen Jul 2, 2024
b5fff8c
refactor base search component method signatures to use kwargs, call …
whatisgalen Jul 2, 2024
6d3ee54
fill out base.py CoreSearchComponent handle_search_results_query, re …
whatisgalen Jul 2, 2024
f93d956
refactor append_dsl-adjacent method in search view, re #10804
whatisgalen Jul 2, 2024
5c27770
rm unused imports, re #10804
whatisgalen Jul 2, 2024
7fc2de2
force es index refresh in tests, re #10804
whatisgalen Jul 2, 2024
d493e3c
fix merge conflict in sort_results, re #10804
whatisgalen Jul 3, 2024
4835cee
fix arg not converted to kwarg in arches_core_search, re #10804
whatisgalen Jul 3, 2024
93ae9ba
fix ES prefixed test index name, re #10804
whatisgalen Jul 3, 2024
c82c0ad
fix merge conflicts in latest perm framework pr into dev/7.6.x, re #1…
whatisgalen Jul 5, 2024
a33a4fe
refactor var results_object to response_object in search and filters …
whatisgalen Jul 5, 2024
95fd665
refactor core-search-component->base-core-search, CoreSearchComponent…
whatisgalen Jul 5, 2024
09921db
update core-search migration to ref to latest, re #10804
whatisgalen Jul 5, 2024
51bee2a
set query={} as kwarg in helper method in search_tests, re #10804
whatisgalen Jul 6, 2024
c70d4f2
create 2 tests specific to core-search component, re #10804
whatisgalen Jul 6, 2024
aa836d0
respond with error in search view if no/bad core-search component, re…
whatisgalen Jul 6, 2024
109ce3d
move sync_es into utils file, re #10804
whatisgalen Jul 7, 2024
7f93505
Merge branch 'archesproject-dev/7.6.x' into 10804_componentizing_core…
whatisgalen Jul 8, 2024
940736f
fix mutability issue in get_resp_json method header, re #10804
whatisgalen Jul 8, 2024
87ac44d
commit new test for searchview, re #10804
whatisgalen Jul 8, 2024
b64fdd9
commit new test for searchview from anon user, re #10804
whatisgalen Jul 8, 2024
5fcad0d
create str_util method to get str_kwarg as bool from dict-like, re #1…
whatisgalen Jul 8, 2024
f6c1fbc
include constraint regarding single core as default for search_cmpnt,…
whatisgalen Jul 8, 2024
e9a1f7a
use get_str_kwarg_as_bool in search_export instead of redundant logic…
whatisgalen Jul 8, 2024
bf894e9
replace enabled, sortorder fields on search_compnt details object wit…
whatisgalen Jul 10, 2024
4286b40
include kwargs on core-search component execute_query method, re #10804
whatisgalen Jul 10, 2024
b0400f6
distinguish requiredComponents (backend) from availableComponents (fr…
whatisgalen Jul 10, 2024
8779da1
move core-appropriate logic into class methods, out of search method,…
whatisgalen Jul 10, 2024
43d4843
fix bad django lookup in search_component pre_save, re #10804
whatisgalen Jul 10, 2024
b306c52
correct refs to req_comps to avail_comps for searchview_comps in arch…
whatisgalen Jul 10, 2024
a8485f7
Merge branch 'archesproject-dev/7.6.x' into 10804_componentizing_core…
whatisgalen Jul 10, 2024
7a8d186
change in-place mutation of response_object, search_query in search t…
whatisgalen Jul 11, 2024
cc43faa
ensure paging-filter mutates response_obj, not search_query_obj, re #…
whatisgalen Jul 11, 2024
a2a4272
Revert "ensure paging-filter mutates response_obj, not search_query_o…
whatisgalen Jul 11, 2024
b1d04f9
rm search-results from manual queryObj mutation in frontend as its al…
whatisgalen Jul 11, 2024
203e55a
ensure paging-filter mutates response_obj, not search_query_obj, re #…
whatisgalen Jul 11, 2024
315fecb
Merge branch 'archesproject-dev/7.6.x' into 10804_componentizing_core…
whatisgalen Jul 11, 2024
b4b145c
Merge branch 'dev/7.6.x' into 10804_componentizing_core_search
apeters Jul 17, 2024
e30f657
alter componentpath column to be non-unique, re #10804
whatisgalen Jul 19, 2024
b1ab24a
Update arches/app/media/js/views/components/search/base-core-search.js
whatisgalen Jul 19, 2024
a8d5a44
import arches in requre in base-core-search, re #10804
whatisgalen Jul 19, 2024
838ee9d
import AlertViewModel into base-core-search, re #10804
whatisgalen Jul 19, 2024
0b4547f
rm redundant method override in arches-core-search, re #10804
whatisgalen Jul 19, 2024
91dfc0f
alter SearchComponent.componentpath model field to be non-unique, re …
whatisgalen Jul 19, 2024
516bc7a
move base_core_search into own file, re #10804
whatisgalen Jul 19, 2024
b56beb8
fix merge conflict, re #10804
whatisgalen Jul 19, 2024
8c3020b
nit, re #10804
whatisgalen Jul 19, 2024
c6b990f
include permissions on es results _source, re #10804
whatisgalen Jul 23, 2024
efa5aa4
ensure sortorder maintained for available, reqd components of core se…
whatisgalen Jul 23, 2024
40dd723
nit list comprehension var names, re #10804
whatisgalen Jul 23, 2024
4a8ceb0
merge conflicts from latest in dev/7.6.x, re #10804
whatisgalen Jul 23, 2024
1fb977c
refactor term, concept of core to search-logic, re #10804
whatisgalen Jul 23, 2024
aef291a
update to latest migration, re #10804
whatisgalen Jul 23, 2024
aeb43e8
include release note for changes, re #10804
whatisgalen Jul 23, 2024
c87c47b
enables reuse of python search component modules by accepting compone…
whatisgalen Jul 25, 2024
833da4b
fix merge conflict from latest in dev/7.6.x
whatisgalen Jul 25, 2024
0aa1390
replace hard-coded componentname with param in saved-searches, re #10804
whatisgalen Jul 25, 2024
a1e0c5f
access saved-searches component data via componentname key, re #10804
whatisgalen Jul 26, 2024
f5fcd59
add horizontal padding to search filter tabs in map-filter panel, re …
whatisgalen Jul 26, 2024
5cb30ba
refactor var param name to sharedState, ensure search-export added to…
whatisgalen Jul 29, 2024
0f66af8
change componentName var to const in provisional-filter, re #10804
whatisgalen Jul 29, 2024
d0147d2
ensure that availableComponents are set as reqd components for search…
whatisgalen Jul 29, 2024
5e3b2b2
prevent 1st query in search-logic if not requiredFiltersLoaded, re #1…
whatisgalen Jul 29, 2024
b791821
ensure req filters loaded = true before doQuery, re #10804
whatisgalen Jul 29, 2024
a4df288
keep unique constraint on searchcomponent componentpath re #10804
whatisgalen Jul 29, 2024
e3b8f95
set default enabled value on reverse migration, re #10804
whatisgalen Jul 29, 2024
5dc856f
set enabled true for all search components on migration reversal, re …
whatisgalen Jul 29, 2024
53fdab6
disenable search-logic components on migration reversal, re #10804
whatisgalen Jul 29, 2024
e060ab2
fix requiredFilters computed, re #10804
whatisgalen Jul 29, 2024
8f3dce8
rm ko.unwrap from req filter check, re #10804
whatisgalen Jul 30, 2024
d2b1dc7
manual revert non-unique searchcomponent componentpath, re #10804
whatisgalen Jul 30, 2024
6063ed4
test updating build order #10804
chrabyrd Jul 30, 2024
0d4c983
nit #10804
chrabyrd Jul 30, 2024
5aee5bf
nit #10804
chrabyrd Jul 30, 2024
3c12642
nit #10804
chrabyrd Jul 30, 2024
ae6f1e0
nit #10804
chrabyrd Jul 30, 2024
545f466
nit #10804
chrabyrd Jul 30, 2024
a0f9f6d
nit #10804
chrabyrd Jul 30, 2024
2ba2a8b
nit #10804
chrabyrd Jul 30, 2024
5883dd5
nit #10804
chrabyrd Jul 30, 2024
a7c5546
refer to key search filters by their type; assign functional type nam…
whatisgalen Jul 30, 2024
f5e5acb
refactor this.filters --> this.searchComponentVms for explicit clarit…
whatisgalen Jul 30, 2024
6ae2293
include search-export in searchComponentVms refactor, re #10804
whatisgalen Jul 30, 2024
69ae59f
Merge branch '10804_componentizing_core_search' of https://github.com…
whatisgalen Jul 30, 2024
266af40
Merge branch 'archesproject-dev/7.6.x' into 10804_componentizing_core…
whatisgalen Jul 30, 2024
0cbc609
Merge branch 'archesproject-dev/7.6.x' into 10804_componentizing_core…
whatisgalen Aug 2, 2024
9658f4d
rename refs to search-logic to search-view for type, re #10804
whatisgalen Aug 7, 2024
4bb7573
Merge branch 'dev/7.6.x' into 10804_componentizing_core_search
apeters Aug 7, 2024
0c36502
fix merge conflict with latest from dev/7.6.x, re #10804
whatisgalen Aug 8, 2024
a2eeb4a
replace usage of this.getFilter(term-filter) with getFilterByType, re…
whatisgalen Aug 8, 2024
fc69927
rename get_searchview_components -> get_searchview_filters, re #10804
whatisgalen Aug 8, 2024
b816e36
rename required_search_components -> required_search_filters, re #10804
whatisgalen Aug 8, 2024
da76681
refactor search_query_dict methods out of base filter into base searc…
whatisgalen Aug 12, 2024
d52e1d5
make search_component.componentpath nullable in postgres to indicate …
whatisgalen Aug 12, 2024
3a0d74a
rename filtersList -> searchFilterConfigs, centralize state mgmt of w…
whatisgalen Aug 12, 2024
80c1da1
rename get_searchview_component -> get_searchview_instance, re #10804
whatisgalen Aug 12, 2024
2aef800
include layoutType on all filters with ko component, re #10804
whatisgalen Aug 12, 2024
df715eb
rename get_searchview_component_name -> get_searchview_name re #10804
whatisgalen Aug 13, 2024
0b013e7
rename searchComponentVms -> searchFilterVms re #10804
whatisgalen Aug 13, 2024
c6fe910
move defaultQuery into constructor of base-search-view, rm from stand…
whatisgalen Aug 13, 2024
aaae683
rm old release note
whatisgalen Aug 13, 2024
fad1310
fix merge conflict for latest dev/7.6.x
whatisgalen Aug 13, 2024
beaa8f7
rm redundant getFilter from base-search-view; add unwrap arg in getFi…
whatisgalen Aug 13, 2024
a10ed1c
refactor search_component types to componentname-type concat, update …
whatisgalen Aug 14, 2024
f5e371a
rm stray comma in migration, re #10804
whatisgalen Aug 14, 2024
86eb048
include default int value for filters sans layoutSortorder, re #10804
whatisgalen Aug 14, 2024
cbce600
commit commented test logs for ko cmpnt load, re #10804
whatisgalen Aug 14, 2024
ddf1291
only make prov-filter invisble, not un-rendered if user not reviewer,…
whatisgalen Aug 14, 2024
fda66ea
fix migration reversion of old search_component type values, re #10804
whatisgalen Aug 15, 2024
60c1207
rm unused componentName assignment, re #10804
whatisgalen Aug 15, 2024
235dd52
nit empty line
whatisgalen Aug 20, 2024
811990f
move called out global var back into if block, re #10804
whatisgalen Aug 20, 2024
d0c3722
Merge branch 'dev/7.6.x' into 10804_componentizing_core_search
apeters Aug 21, 2024
185dd09
fix migration merge issue, re #10804
apeters Aug 21, 2024
4deaaa9
cleanup migration, re #10804
whatisgalen Aug 21, 2024
0749dfc
updates to use reference the filter types in the selected tabs and po…
apeters Aug 21, 2024
d458d12
cleanup imports, details objects in search component class files, re …
whatisgalen Aug 21, 2024
6aa5c2c
rm unused imports, consolidate models imports, re #10804
whatisgalen Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arches/app/media/css/arches.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10025,7 +10025,7 @@ table.table.dataTable {

.search-type-btn {
height: 50px;
padding: 0px;
padding: 0px 4px;
font-size: 1.2rem;
font-weight: 600;
color: #888;
Expand Down
11 changes: 5 additions & 6 deletions arches/app/media/js/views/components/search/advanced-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ define([
initialize: function(options) {
var self = this;
options.name = 'Advanced Search Filter';

BaseFilter.prototype.initialize.call(this, options);
this.urls = arches.urls;
this.tagId = "Advanced Search";
Expand Down Expand Up @@ -179,7 +178,7 @@ define([
options.loading(false);
});

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

updateQuery: function() {
Expand All @@ -194,12 +193,12 @@ define([
});
queryObj[componentName] = JSON.stringify(advanced);

if (this.getFilter('term-filter').hasTag(this.tagId) === false) {
this.getFilter('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.getFilter('term-filter').removeTag(this.tagId);
this.getFilterByType('term-filter-type').removeTag(this.tagId);
}
this.query(queryObj);
},
Expand All @@ -223,7 +222,7 @@ define([
var facets = JSON.parse(query[componentName]);

if (facets.length > 0) {
this.getFilter('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
11 changes: 0 additions & 11 deletions arches/app/media/js/views/components/search/base-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,12 @@ define([
this.name = 'Base Filter';
// the various filters managed by this widget
this.filter = {};
this.requiredFilters = [];
// Call the original constructor
Backbone.View.apply(this, arguments);
},

initialize: function(options) {
$.extend(this, options);
this.requiredFiltersLoaded = ko.computed(function() {
var self = this;
var res = this.requiredFilters.every(function(f){return self.getFilter(f) !== null;});
return res;
}, this);
},


getFilter: function(filterName) {
return ko.unwrap(this.filters[filterName]);
}
});
});
102 changes: 102 additions & 0 deletions arches/app/media/js/views/components/search/base-search-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
define([
'jquery',
'underscore',
'knockout',
'backbone',
'arches',
'viewmodels/alert',
], function($, _, ko, BackBone, arches, AlertViewModel) {
return Backbone.View.extend({
constructor: function() {
this.name = 'Base Search View';
this.filter = {};
this.defaultQuery = {};
Backbone.View.apply(this, arguments);
},

initialize: function(sharedStateObject) {
const self = this;
$.extend(this, sharedStateObject);
this.query = sharedStateObject.query;
this.queryString = sharedStateObject.queryString;
this.updateRequest = sharedStateObject.updateRequest;
this.userIsReviewer = sharedStateObject.userIsReviewer;
this.total = sharedStateObject.total;
this.userid = sharedStateObject.userid;
this.hits = sharedStateObject.hits;
this.alert = sharedStateObject.alert;
this.sharedStateObject = sharedStateObject;
this.queryString.subscribe(function() {
if (this.searchViewFiltersLoaded()) {
this.doQuery();
} else {
this.searchViewFiltersLoaded.subscribe(function() {
this.doQuery();
}, this);
}
}, this);
// init query
if (self.updateRequest === undefined) {
if (this.searchViewFiltersLoaded()) {
this.doQuery();
} else {
this.searchViewFiltersLoaded.subscribe(function() {
this.doQuery();
}, 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.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'){
self.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);
}
});
},

clearQuery: function(){
Object.values(this.searchFilterVms).forEach(function(value){
if (value()){
if (value().clear){
value().clear();
}
}
}, this);
this.query(this.defaultQuery);
},
});
});
10 changes: 5 additions & 5 deletions arches/app/media/js/views/components/search/map-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ define([
updateSearchResultPointLayer();
};

this.filters[componentName](this);
this.searchFilterVms[componentName](this);
this.map.subscribe(function(){
this.setupDraw();
this.restoreState();
Expand Down Expand Up @@ -514,8 +514,8 @@ define([
var self = this;
var queryObj = this.query();
if (this.filter.feature_collection().features.length > 0) {
if (this.getFilter('term-filter').hasTag(this.type) === false) {
this.getFilter('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 @@ -552,7 +552,7 @@ define([
this.bufferUnit = ko.observable(bufferUnit).extend({ deferred: true });
this.filter.inverted = ko.observable(inverted).extend({ deferred: true });
if (hasSpatialFilter) {
this.getFilter('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 @@ -581,7 +581,7 @@ define([
"type": "FeatureCollection",
"features": []
});
this.getFilter('term-filter').removeTag('Map Filter Enabled');
this.getFilterByType('term-filter-type').removeTag('Map Filter Enabled');
this.draw.deleteAll();
this.searchGeometries([]);
},
Expand Down
6 changes: 3 additions & 3 deletions arches/app/media/js/views/components/search/paging-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define([
'utils/aria',
'templates/views/components/search/paging-filter.htm',
], function(BaseFilter, ko, koMapping, ariaUtils, pagingFilterTemplate) {
var componentName = 'paging-filter';
const componentName = 'paging-filter';
const viewModel = BaseFilter.extend({
initialize: function(options) {
options.name = 'Paging Filter';
Expand Down Expand Up @@ -45,7 +45,7 @@ define([
this.updateResults();
}, this);

this.filters[componentName](this);
this.searchFilterVms[componentName](this);
this.restoreState();
this.pageInitialized = true;
},
Expand All @@ -60,7 +60,7 @@ define([
if(page){
this.userRequestedNewPage = true;
this.page(page);
this.shiftFocus('#search-results-list');
this.shiftFocus('#search-results-list-type');
}
},

Expand Down
30 changes: 14 additions & 16 deletions arches/app/media/js/views/components/search/provisional-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,30 @@ define([
'views/components/search/base-filter',
'templates/views/components/search/provisional-filter.htm',
], function(ko, arches, BaseFilter, provisionalFilterTemplate) {
var componentName = 'provisional-filter';
const componentName = 'provisional-filter';
const viewModel = BaseFilter.extend({
initialize: function(options) {
options.name = 'Provisional Filter';
this.translations = arches. translations;
this.requiredFilters = ['term-filter'];
this.translations = arches.translations;
BaseFilter.prototype.initialize.call(this, options);
this.filter = ko.observableArray();
this.provisionalOptions = [{'name': 'Authoritative'},{'name': 'Provisional'}];

if (this.requiredFiltersLoaded() === false) {
this.requiredFiltersLoaded.subscribe(function() {
this.restoreState();
}, this);
} else {
this.restoreState();
}

var filterUpdated = ko.computed(function() {
return JSON.stringify(ko.toJS(this.filter()));
}, this);
filterUpdated.subscribe(function() {
this.updateQuery();
}, this);

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

if (this.searchViewFiltersLoaded() === false) {
this.searchViewFiltersLoaded.subscribe(function() {
this.restoreState();
}, this);
} else {
this.restoreState();
}
},

updateQuery: function() {
Expand All @@ -49,7 +47,7 @@ define([
if (provisionalQuery.length > 0) {
provisionalQuery.forEach(function(type){
type.inverted = ko.observable(!!type.inverted);
this.getFilter('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 @@ -58,12 +56,12 @@ define([

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

if(!!item){
var inverted = ko.observable(false);
this.getFilter('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 @@ -10,30 +10,28 @@ define([
const viewModel = BaseFilter.extend ({
initialize: function(options) {
options.name = 'Related Resources Filter';


this.requiredFilters = ['search-results'];
BaseFilter.prototype.initialize.call(this, options);
this.ready = ko.observable(false);
this.options = options;
this.urls = arches.urls;
var self = this;
// this component is just a light weight wrapper around the relatd resources manager
// need to wait for the search-resutls filter to be ready
// before we can load the realated-resources-filter
// 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.relatedResourcesManager = self;
options.filters[componentName](self);
self.searchResultsVm.relatedResourcesManager = self;
self.ready(true);
};
this.searchFilterVms[componentName](this);

if (this.requiredFiltersLoaded() === false) {
this.requiredFiltersLoaded.subscribe(setSearchResults, this);
} else {
this.searchResultsVm = self.getFilterByType('search-results-type', false);
if (ko.unwrap(this.searchResultsVm)) {
this.searchResultsVm = this.searchResultsVm();
setSearchResults();
} else {
this.searchResultsVm.subscribe(searchResultsFilter => {
if (searchResultsFilter) {
this.searchResultsVm = searchResultsFilter;
setSearchResults();
}
}, this);
}
}
});
Expand Down
Loading