Date range facet sub-controller
Date range facet sub-controller
This is for:
DeveloperCreate facet sub-controllers using the FacetGenerator
sub-controller of the ProductListing
controller.
const productListingController = buildProductListing(commerceEngine);
const facetGenerator = productListingController.facetGenerator();
for (const facet of facetGenerator.facets) {
switch (facet.type) {
case 'regular':
// facet will be typed as RegularFacet, render it...
break;
case 'dateRange':
// facet will be typed as DateFacet, render it...
break;
case 'numericalRange':
// facet will be typed as NumericFacet, render it...
break;
case 'hierarchical':
// facet will be typed as CategoryFacet, render it...
}
}
Methods
deselectAll
Deselects all facet values.
isValueExcluded
Checks whether the specified facet value is excluded.
Parameters
-
value:
DateFacetValue
The facet value to check.
Returns boolean
: Whether the specified facet value is excluded.
isValueSelected
Checks whether the specified facet value is selected.
Parameters
-
value:
DateFacetValue
The facet value to check.
Returns boolean
: Whether the specified facet value is selected.
setRanges
Replaces the current range values with the specified ones.
Parameters
-
ranges:
DateFacetValue[]
The date ranges to set.
showLessValues
Sets the number of values displayed in the facet to the originally configured value.
showMoreValues
Increases the number of values displayed in the facet to the next multiple of the originally configured value.
toggleExclude
Toggles exclusion of the specified facet value.
Parameters
-
selection:
DateFacetValue
The facet value to toggle exclusion.
toggleSelect
Toggles the specified facet value.
Parameters
-
selection:
DateFacetValue
The facet value to toggle.
toggleSingleExclude
Excludes the specified facet value, deselecting others.
Parameters
-
selection:
DateFacetValue
The facet value to toggle exclusion.
toggleSingleSelect
Toggles the specified facet value, deselecting others.
Parameters
-
selection:
DateFacetValue
The facet value to toggle.
subscribe
Adds a callback that’s invoked on state change.
Parameters
-
listener:
() => void
A callback that’s invoked on state change.
Returns Unsubscribe
: A function to remove the listener.
Attributes
type
The type of the facet.
state
The state of the date range facet controller.
Properties
-
type:
'regular' | 'dateRange' | 'numericalRange' | 'hierarchical'|'location'
The type of the facet.
-
canShowLessValues:
boolean
true
if fewer values can be displayed andfalse
otherwise. -
canShowMoreValues:
boolean
true
if there are more values to display andfalse
otherwise. -
facetId:
string
The facet ID.
-
hasActiveValues:
boolean
true
if there is at least one non-idle value andfalse
otherwise. -
isLoading:
boolean
true
if a search is in progress andfalse
otherwise. -
values:
DateFacetValue[]
The values of the facet.
-
field:
string
The facet field.
-
displayName?:
string
The facet name.
Related Types
DateFacetValue
Properties
-
numberOfResults:
number
The number of results that have the facet value.
-
state:
'idle' | 'selected' | 'excluded'
Whether a facet value is filtering results (
selected
) or not (idle
). -
value:
string
The facet value.
Unsubscribe
Call signatures
-
(): void;