@@ -18,15 +18,34 @@ export default Ember.Controller.extend(Analytics, {
1818 i18n : Ember . inject . service ( ) ,
1919 theme : Ember . inject . service ( ) ,
2020 activeFilters : { providers : [ ] , subjects : [ ] } ,
21+ additionalProviders : Ember . computed ( 'themeProvider' , function ( ) { // Do additionalProviders exist?
22+ // for now, using this property to alter many pieces of the landing/discover page
23+ return ( this . get ( 'themeProvider.additionalProviders' ) || [ ] ) . length > 1 ;
24+ } ) ,
2125 consumingService : 'preprints' , // Consuming service - preprints here
2226 detailRoute : 'content' , // Name of detail route for this application
23- discoverHeader : Ember . computed ( 'i18n' , function ( ) { // Header for preprints discover page
24- return this . get ( 'i18n' ) . t ( 'discover.search.heading' ) ;
27+ discoverHeader : Ember . computed ( 'i18n' , 'additionalProviders' , function ( ) { // Header for preprints discover page
28+ // If additionalProviders, use more generic Repository Search page title
29+ return this . get ( 'additionalProviders' ) ? this . get ( 'i18n' ) . t ( 'discover.search.heading_repository_search' ) : this . get ( 'i18n' ) . t ( 'discover.search.heading' ) ;
30+ } ) ,
31+ end : '' , // End query param. Must be passed to component, so can be reflected in the URL
32+ externalProviders : Ember . computed ( 'model' , function ( ) {
33+ return this . get ( 'model' ) . filter ( item => item . id !== 'osf' ) ;
2534 } ) ,
26- facets : Ember . computed ( 'i18n.locale' , function ( ) { //List of facets available for preprints
27- return [
28- { key : 'sources' , title : `${ this . get ( 'i18n' ) . t ( 'discover.main.providers' ) } ` , component : 'search-facet-provider' } ,
29- { key : 'subjects' , title : `${ this . get ( 'i18n' ) . t ( 'discover.main.subject' ) } ` , component : 'search-facet-taxonomy' } ]
35+ facets : Ember . computed ( 'i18n.locale' , 'additionalProviders' , function ( ) { // List of facets available for preprints
36+ if ( this . get ( 'additionalProviders' ) ) { // if additionalProviders exist, use subset of SHARE facets
37+ return [
38+ { key : 'sources' , title : this . get ( 'i18n' ) . t ( 'discover.main.source' ) , component : 'search-facet-source' } ,
39+ { key : 'date' , title : this . get ( 'i18n' ) . t ( 'discover.main.date' ) , component : 'search-facet-daterange' } ,
40+ { key : 'type' , title : this . get ( 'i18n' ) . t ( 'discover.main.type' ) , component : 'search-facet-worktype' } ,
41+ { key : 'tags' , title : this . get ( 'i18n' ) . t ( 'discover.main.tag' ) , component : 'search-facet-typeahead' } ,
42+ ] ;
43+ } else { // Regular preprints and branded preprints get provider and taxonomy facets
44+ return [
45+ { key : 'sources' , title : `${ this . get ( 'i18n' ) . t ( 'discover.main.providers' ) } ` , component : 'search-facet-provider' } ,
46+ { key : 'subjects' , title : `${ this . get ( 'i18n' ) . t ( 'discover.main.subject' ) } ` , component : 'search-facet-taxonomy' }
47+ ]
48+ }
3049 } ) ,
3150 filterMap : { // Map active filters to facet names expected by SHARE
3251 providers : 'sources' ,
@@ -38,15 +57,21 @@ export default Ember.Controller.extend(Analytics, {
3857 OSF : 'OSF Preprints' ,
3958 'Research Papers in Economics' : 'RePEc'
4059 } ,
41- lockedParams : { types : 'preprint' } , // Parameter names which cannot be changed
60+ lockedParams : Ember . computed ( 'additionalProviders' , function ( ) { // Query parameters that cannot be changed.
61+ // if additionalProviders, open up search results to all types of results instead of just preprints.
62+ return this . get ( 'additionalProviders' ) ? { } : { types : 'preprint' } ;
63+ } ) ,
4264 page : 1 , // Page query param. Must be passed to component, so can be reflected in URL
4365 provider : '' , // Provider query param. Must be passed to component, so can be reflected in URL
4466 q : '' , // q query param. Must be passed to component, so can be reflected in URL
45- queryParams : [ 'page' , 'q' , 'subject' , 'provider' ] , // Pass in the list of queryParams for this component
46- searchPlaceholder : Ember . computed ( 'i18n' , function ( ) { // Search bar placeholder
47- return this . get ( 'i18n' ) . t ( 'discover.search.placeholder' ) ;
67+ queryParams : [ 'page' , 'q' , 'sources' , 'tags' , 'type' , 'start' , 'end' , 'subject' , 'provider' ] , // Pass in the list of queryParams for this component
68+ searchPlaceholder : Ember . computed ( 'i18n' , 'additionalProviders' , function ( ) { // Search bar placeholder
69+ return this . get ( 'additionalProviders' ) ? this . get ( 'i18n' ) . t ( 'discover.search.repository_placeholder' ) : this . get ( 'i18n' ) . t ( 'discover.search.placeholder' ) ;
70+ } ) ,
71+ showActiveFilters : Ember . computed ( 'additionalProviders' , function ( ) { // Whether Active Filters should be displayed.
72+ // additionalProviders are using SHARE facets which do not work with Active Filters at this time
73+ return ! this . get ( 'additionalProviders' ) ;
4874 } ) ,
49- showActiveFilters : true , // Whether Active Filters should be displayed.
5075 sortOptions : Ember . computed ( 'i18n.locale' , function ( ) { // Sort options for preprints
5176 const i18n = this . get ( 'i18n' ) ;
5277 return [ {
@@ -60,7 +85,20 @@ export default Ember.Controller.extend(Analytics, {
6085 sortBy : '-date_updated'
6186 } ] ;
6287 } ) ,
63- subject : '' , // Subject query param. Must be passed to component, so can be reflected in URL,
88+ sources : '' , // Sources query param. Must be passed to component, so can be reflected in the URL
89+ start : '' , // Start query param. Must be passed to component, so can be reflected in the URL
90+ subject : '' , // Subject query param. Must be passed to component, so can be reflected in URL
91+ tags : '' , // Tags query param. Must be passed to component, so can be reflected in URL
92+ themeProvider : Ember . computed ( 'model' , function ( ) { // Pulls the preprint provider from the already loaded model
93+ let themeProvider = null ;
94+ this . get ( 'model' ) . forEach ( provider => {
95+ if ( provider . id === this . get ( 'theme.id' ) ) {
96+ themeProvider = provider ;
97+ }
98+ } ) ;
99+ return themeProvider ;
100+ } ) ,
101+ type : '' , //Type query param. Must be passed to component, so can be reflected in URL
64102 _clearFilters ( ) {
65103 this . set ( 'activeFilters' , {
66104 providers : [ ] ,
0 commit comments