API Docs for: 0.25.0
Show:

discover-page Class

Module: utils
Parent Module: ember-osf

Discover-page component. Builds a search interface utilizing SHARE. See retraction-watch, registries, and preprints discover pages for working examples.

Majority adapted from Ember-SHARE https://github.com/CenterForOpenScience/ember-share, with additions from PREPRINTS and REGISTRIES discover pages. Original Ember-SHARE facets and PREPRINTS/REGISTRIES facets behave differently at this time. You can build a discover-page that uses Ember-SHARE type facets -OR- PREPRINTS/REGISTRIES type facets. Would not recommend mixing until code is combined.

How to Use: Pass in custom text like searchPlaceholder. The facets property will enable you to customize the filters on the left-hand side of the discover page. Sort options are the sort dropdown options. Each query parameter must be passed in individually, so they are reflected in the URL. Logo and custom colors must be placed in the consuming application's stylesheet. Individual components can additionally be overridden in your application.

Sample usage:

{{discover-page
 consumingService=consumingService
 searchPlaceholder=searchPlaceholder
 detailRoute=detailRoute
 discoverHeader=discoverHeader
 themeProvider=themeProvider

 sortOptions=sortOptions
 filterReplace=filterReplace
 whiteListedProviders=whiteListedProviders
 fetchedProviders=externalProviders

 facets=facets
 results=results
 numberOfResults=numberOfResults
 aggregations=aggregations
 queryParamsState=queryParamsState

 showActiveFilters=showActiveFilters
 loading=fetchData.isRunning

 clearFilters=(action 'clearFilters')
 search=(action 'search')

 size=size
 page=page
 q=q
 sort=sort
}}
{{!-- plus any query params (e.g. provider=provider) --}}

Methods

buildLockedQueryBody

(
  • lockedParams
)
List

For services where portion of query is restricted. Builds the locked portion of the query. For example, in preprints, types=['preprint', 'thesis'] is something that cannot be modified by the user.

Parameters:

  • lockedParams Object
    • Locked param keys matched to the locked value.

Returns:

List:

queryBody - locked portion of query body

buildQueryBody

(
  • queryParams
  • filters
  • queryParamsChanged
)
String

Construct queryBody for OSF facets

Parameters:

  • queryParams Object
    • Ember Parachute queryParams
  • filters List
    • Filters for query body
  • queryParamsChanged Boolean
    • Whether or not any queryParams differ from their defaults

Returns:

String:

queryBody - Stringified queryBody

constructBasicFilters

(
  • filterMap
  • filters
  • isProvider
  • queryParams
)
List

Construct filters for OSF facets (e.g., providers, subjects, etc.)

Parameters:

  • filterMap Object
    • Mapping from OSF params to SHARE params
  • filters List
    • Filters for query body
  • isProvider Boolean
    • theme.isProvider
  • queryParams Object
    • Ember Parachute queryParams

Returns:

List:

filters - Filters for query body

sortContributors

(
  • contributors
)
List private

Sort contributors by order cited and set bibliographic property

Parameters:

  • contributors List
    • list.contributors from a SHARE ES result

Returns:

List:

transformShareData

(
  • result
)
Object private

Make share data look like apiv2 preprints data and pull out identifiers

Parameters:

  • result Object
    • hit from a SHARE ES

Returns:

Properties

detailRoute

String

Provided by the components module.

Defined in addon/components/discover-page/component.js:108

Name of detail route for consuming application, like "content" or "detail". Override if search result title should link to detail route.

discoverHeader

String

Provided by the components module.

Defined in addon/components/discover-page/component.js:114

Text header for top of discover page.

fetchedProviders

Object

Provided by the components module.

Defined in addon/components/discover-page/component.js:121

For PREPRINTS ONLY. Pass in the providers fetched in preprints app so they can be used in the provider carousel

filterReplace

Object

Provided by the components module.

Defined in addon/components/discover-page/component.js:127

For PREPRINTS and REGISTRIES. A mapping of filter names for front-end display. Ex. {OSF: 'OSF Preprints'}.

page

Integer

Provided by the components module.

Defined in addon/components/discover-page/component.js:94

Page query parameter. If "page" is one of your query params, it must be passed to the component so it can be updated.

Default: 1

Preprint provider loaded from theme service. Should be passed from consuming service so it is loaded before SHARE is queried.

Object

Provided by the components module.

Defined in addon/components/discover-page/component.js:171

themeProvider

Default: ''

q

String

Provided by the components module.

Defined in addon/components/discover-page/component.js:101

q query parameter. If "q" is one of your query params, it must be passed to the component so it can be updated.

Default: ''

showActiveFilters

Boolean

Provided by the components module.

Defined in addon/components/discover-page/component.js:133

For PREPRINTS and REGISTRIES. Displays activeFilters box above search facets.

size

Integer

Provided by the components module.

Defined in addon/components/discover-page/component.js:80

Size query parameter. If "size" is one of your query params, it must be passed to the component so it can be updated.

Default: 10

sort

String

Provided by the components module.

Defined in addon/components/discover-page/component.js:87

Sort query parameter. If "sort" is one of your query params, it must be passed to the component so it can be updated.

Default: ''

sortOptions

Array

Provided by the components module.

Defined in addon/components/discover-page/component.js:146

Sort dropdown options - Array of dictionaries. Each dictionary should have display and sortBy keys.

Default: [{ display: 'Relevance', sortBy: '' }]