Skip to content

Commit

Permalink
Merge d4b0dd8 into c67b6ba
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeaudoincoveo committed Feb 13, 2017
2 parents c67b6ba + d4b0dd8 commit 6fa3a2b
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/ui/HiddenQuery/HiddenQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,46 @@ export interface IHiddenQueryOptions {
}

/**
* This component job is to handle an 'hidden' query parameter.<br/>
* Concretely, this means that a search interface loaded with #hq=foo&hd=bar will add 'foo' as an expression to the query ('hq'=> hidden query) and render 'bar' in the {@link Breadcrumb}.<br/>
* The HiddenQuery component handles a "hidden" query parameter (`hq`) and its description (`hd`).
*
* Concretely, this means that if a HiddenQuery component is present in your page and you load your search interface
* with `hq=foo&hd=bar` in the URL hash, the component adds `foo` as an expression to the query (`hq` is the hidden
* query) and renders `bar` in the {@link Breadcrumb} (`hd` is the hidden query description).
*/
export class HiddenQuery extends Component {
static ID = 'HiddenQuery';

/**
* Possible options for the `HiddenQuery` component
* @componentOptions
*/
static options: IHiddenQueryOptions = {

/**
* Specifies a maximum character length for a description.<br/>
* After this length, the component will slice the descrption and add [...].<br/>
* Default value is 100.
* Specifies the maximum number of characters from the hidden query description (`hd`) to display in the
* {@link Breadcrumb}.
*
* Beyond this length, the HiddenQuery component slices the rest of the description and replaces it by `...`.
*
* Default value is `100`. Minimum value is `0`.
*/
maximumDescriptionLength: ComponentOptions.buildNumberOption({ min: 0, defaultValue: 100 }),

/**
* Specifies a title that will appear in the {@link Breadcrumb} when it is populated by the `HiddenQuery` component.<br/>
* By default, it is a localized string for 'Additional filters :'
* Specifies the title that should appear in the {@link Breadcrumb} when the HiddenQuery populates it.
*
* Default value is the localized string for `"Additional filters:"`
*/
title: ComponentOptions.buildLocalizedStringOption({ defaultValue: l('AdditionalFilters') + ' : ' })
title: ComponentOptions.buildLocalizedStringOption({ defaultValue: l('AdditionalFilters') + ': ' })
};

/**
* Create a new HiddenQuery component, which bind multiple events (building query as well as {@link Breadcrumb} events).
* @param element
* @param options
* @param bindings
* Creates a new HiddenQuery component, which binds multiple events ({@link QueryEvents.buildingQuery},
* {@link BreadcrumbEvents.populateBreadcrumb} and {@link BreadcrumbEvents.clearBreadcrumb}).
* @param element The HTMLElement on which to instantiate the component.
* @param options The options for the HiddenQuery component.
* @param bindings The bindings that the component requires to function normally. If not set, these will be
* automatically resolved (with a slower execution time).
*/
constructor(public element: HTMLElement, public options?: IHiddenQueryOptions, bindings?: IComponentBindings) {

Expand All @@ -58,7 +70,8 @@ export class HiddenQuery extends Component {
}

/**
* Clear any hd or hq set in the {@link QueryStateModel}, log an analytics event and trigger a new query.
* Clears any `hd` or `hq` set in the {@link QueryStateModel}.
* Also logs the `contextRemove` event in the usage analytics and triggers a new query.
*/
public clear() {
this.setStateEmpty();
Expand Down

0 comments on commit 6fa3a2b

Please sign in to comment.