An interface for adding, deleting, and querying search facets stored in UI-Router State. Router state and URL parameters are synced on state traversal.
Dependencies:
| Name | Type | Description |
|---|---|---|
| $state | UI-Router state |
|
| $uiRouterGlobals | Stores the current state's parameters |
Members
Methods
-
addFacetsForKeywordSearch (query)
-
Update the state to reflect new keyword search.
Parameters:
Name Type Description query Text entered into the search box
-
addFacetToHash (facetType, currentFacet)
-
Adds a search facet (a.k.a. filter) to the state. If the facetType is stored as an array, the new facet is added to the end. If the facetType is stored as a string, it is replaced by the new value. The calls to $state.go cause an update. Any update to the facets, resets the page to 1.
Parameters:
Name Type Description facetType Major category of facet, e.g. 'department' or 'collection'
currentFacet Specific facet to filter by, e.g. 'Archival Collections'
-
getFlattenedFacets
-
Helper function to prep the facets to be displayed in the view. This function also removes several facets that are displayed in other ways in the view.
-
getSearchFacets (facetType)
-
Wrapper for a $uiRouterGlobals lookup. If a parameter is provided, the function will return all of the facets associated with that type. By default, the function returns an object containing all facets currently stored in state.
Parameters:
Name Type Description facetType Major category of facet, e.g. 'department' or 'collection'
Returns:
Object containing all search facets, an array of facets, or a string facet for a particular type
-
isAFacetSelected (facetType)
-
Returns true if the provided facet type has at least one selected facet in the state.
Parameters:
Name Type Description facetType Major category of facet, e.g. 'department' or 'collection'
Returns:
true if there is at least one facet of the given type in the url hash, false otherwise.
-
isFacetSelected (facetType, currentFacet)
-
Returns true if the provided facet is in the state.
Parameters:
Name Type Description facetType Major category of facet, e.g. 'department' or 'collection'
currentFacet Specific facet to filter by, e.g. 'Archival Collections'
Returns:
True if the given facet is in the url hash, false otherwise
-
removeAllFacetsFromHash
-
Resets state to the defaults stored in the Router config
-
removeFacetFromHash (facetType, currentFacet)
-
Removes a search facet (a.k.a. filter) from the state. If the facetType is stored as an array and the currentFacet is provided, the currentFacet is removed from the array, else the entire array is emptied. If the facetType is stored as a string, it is replaced by an empty string. The calls to $state.go cause an update. Any update to the facets, resets the page to 1.
Parameters:
Name Type Description facetType Major category of facet, e.g. 'department' or 'collection'
currentFacet Specific facet to filter by, e.g. 'Archival Collections'
-
toggleFacetInHash (facetType, currentFacet)
-
If the facet's first character is '-' remove it, else add a minus to the front of the string, then replace the old facet with the updated one. Any update to the facets, resets the page to 1.
Parameters:
Name Type Description facetType Major category of facet, e.g. 'department' or 'collection'
currentFacet Specific facet to filter by, e.g. 'Archival Collections'