@@ -3,29 +3,42 @@ import { inject as service } from '@ember/service';
33import CurrentUser from 'ember-osf-web/services/current-user' ;
44import { tracked } from '@glimmer/tracking' ;
55import { action } from '@ember/object' ;
6- import pathJoin from 'ember-osf-web/utils/path-join' ;
7- import config from 'ember-get-config' ;
8- import { OnSearchParams , ResourceTypeFilterValue } from 'osf-components/components/search-page/component' ;
6+ import { Filter , OnSearchParams , ResourceTypeFilterValue } from 'osf-components/components/search-page/component' ;
97
108export default class InstitutionDiscoverController extends Controller {
119 @service currentUser ! : CurrentUser ;
1210
13- @tracked cardSearchText ?: string = '' ;
11+ @tracked q ?: string = '' ;
1412 @tracked sort ?: string = '-relevance' ;
15- @tracked resourceType ?: ResourceTypeFilterValue | null = null ;
13+ @tracked resourceType : ResourceTypeFilterValue = ResourceTypeFilterValue . Projects ;
14+ @tracked activeFilters ?: Filter [ ] = [ ] ;
1615
17- queryParams = [ 'cardSearchText ' , 'sort' , 'resourceType' ] ;
16+ queryParams = [ 'q ' , 'sort' , 'resourceType' , 'activeFilters '] ;
1817
1918 get defaultQueryOptions ( ) {
19+ const identifiers = this . model . iris . join ( ',' ) ;
20+ let key = 'affiliation' ;
21+ const { resourceType } = this ;
22+ switch ( resourceType ) {
23+ case ResourceTypeFilterValue . Preprints :
24+ key = 'creator.affiliation' ;
25+ break ;
26+ case ResourceTypeFilterValue . Files :
27+ key = 'isContainedby.affiliation' ;
28+ break ;
29+ default :
30+ break ;
31+ }
2032 return {
21- publisher : pathJoin ( config . OSF . url , 'institutions' , this . model . id ) ,
33+ [ key ] : identifiers ,
2234 } ;
2335 }
2436
2537 @action
2638 onSearch ( queryOptions : OnSearchParams ) {
27- this . cardSearchText = queryOptions . cardSearchText ;
39+ this . q = queryOptions . cardSearchText ;
2840 this . sort = queryOptions . sort ;
29- this . resourceType = queryOptions . resourceType ;
41+ this . resourceType = queryOptions . resourceType as ResourceTypeFilterValue ;
42+ this . activeFilters = queryOptions . activeFilters ;
3043 }
3144}
0 commit comments