Wrapper for the search interfaces, i.e. general, blog, event, and collections. Contains logic to handle search facets, display data in various views, and determine what to do with faulty feedback from the server.
Dependencies:
| Name | Type | Description |
|---|---|---|
| $transitions$ | UI-router object |
|
| searchFacets | Service that handles manipulating parameters in the state. |
|
| keywordSearcher | Service that wraps calls to the search APIs |
Methods
-
addDateFacet (datePart, value)
-
Update the selected values of year, month, or day. The new value is verified, then the new facet is added to the state.
Parameters:
Name Type Description datePart Piece of the date that should be changed (i.e. year, month, or day)
value The new value for the provided datePart
-
addFacet (facetType, currentFacet)
-
Adds a search facet (a.k.a. filter) to the state, which triggers a transition which in turn triggers the
onStartlistener. Inside theonStarttransition listener, an API call is made with the updated state parameters.Parameters:
Name Type Description facetType Major category of facet, e.g. 'department' or 'collection'
currentFacet Specific facet to filter by, e.g. 'Archival Collections'
-
clearFacets
-
Remove all facets for the state and by consequence the URL hash.
-
getInfiniteNextPage
-
Manage infinite scrolling for the thumbnail view. Every API call retrieves 20 items. Every time this function is called it adds four elements to those shown. If there are no more elements in memory, then call the API again.
-
isAFacetSelected (facetType)
-
Returns true if the provided facet type has at least one selected facet in the url hash.
Parameters:
Name Type Description facetType Major category of facet, e.g. 'dept' or 'collection'
Returns:
true if there is at least one facet of the given type in the url hash, false otherwise.
-
isDateDisabled (day)
-
Determine if a day is a valid choice for selection. By disabling calendar day that have already past, we can prevent users from selecting a past date.
Parameters:
Name Type Description day The day to check
Returns:
True if the day has already past, false otherwise
-
isFacetSelected (facetType, currentFacet)
-
Returns true if the provided facet is in the url hash.
Parameters:
Name Type Description facetType Major category of facet, e.g. 'dept' 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
-
isMonthDisabled (direction)
-
Determine if a navigational arrows should be disabled for a given direction. By disabling those buttons, we can prevent navigation to months outside the allowed range.
Parameters:
Name Type Description direction the direction to check
Returns:
True if the month is not in the allowed range, false otherwise
-
nextMonth
-
Navigate to the next month. If current month is December move to January of the next year. This function has no impact on the selected date.
-
nextPage
-
Navigate to the next page by transitioning to a new state.
-
nextPage
-
Navigate tot the previous page by transitioning to a new state.
-
onDestroy
-
Clean up function called when a component is removed.
-
onDisclaimerClose
-
Hide the disclaimer while this component is alive. If the user navigates away from the search interface then comes back, the disclaimer will be visible again.
-
onInit
-
Initialization code run every time the component is created, used to setup variables and data.
-
onSearchSubmit (q)
-
Called when a new keyword is entered. Updates search text and page number in the state parameters. By updating the parameters, a transition is triggered which runs setupData.
Parameters:
Name Type Description q String representing the search parameter
-
prevMonth
-
Navigate to the previous month. If current month is January move to December of the previous year. This function has no impact on the selected date.
-
removeFacet (facetType, currentFacet)
-
Removes a search facet (a.k.a. filter) from the state, which triggers a transition which in turn triggers the
onStartlistener. Inside theonStarttransition listener, an API call is made with the updated state parameters.Parameters:
Name Type Description facetType Major category of facet, e.g. 'department' or 'collection'
currentFacet Specific facet to filter by, e.g. 'Archival Collections'
-
setDaysToShow
-
Populate the daysToShow array which is used to generate the day selector and logic for determining the accuracy of a date facet. MUST BE CALLED AFTER updating selectedYear and selectedMonth
-
setMonthsToShowStart
-
Determine if the months in the dropdown should start with January or the current month.
-
setPage (num)
-
Navigate to the specified page by transitioning to a new state.
Parameters:
Name Type Description num -
setupCalendar
-
Handle the setup for the event search calendar. This means setting the variables used to display the calendar and validating the date facet.
-
setupData
-
Process data before displaying it. Some of the setup is based on search type, where as, there are pieces that apply to all types.
-
setupEventIcons
-
Unlike other search facets, all event icons need to be visible regardless of if they were returned as viable facets from the API. This function generates a list of icons and counts to display based on the hard coded list of all possible icons and the icons returned from the API.
-
setViewLayout (layout)
-
Switch to given view layout
Parameters:
Name Type Description layout -
setYearsToShow
-
Fill the array used to populate the year dropdown menu.
-
toggleFacet (facetType, currentFacet)
-
If the facet's first character is '-' remove it, else add a minus to the front of the string. Then, remove the old facet and add the new one.
Parameters:
Name Type Description facetType Major category of facet, e.g. 'dept' or 'collection'
currentFacet Specific facet to filter by, e.g. 'Archival Collections'
-
verifyDate
-
Verify selected date. A date is valid if the selected values are in allowed ranges and the selected values can be combined to form one of the following date combinations: yyyy-mm-dd, yyyy-mm, or yyyy-mm-dd.
Returns:
true if a change was made, false otherwise