Description

Twigkit service for queries

Methods

clearQueries()

Will remove all the queries from the factory.

Example

QueryService.clearQueries();

convertHttpParamsToQuery(httpParams)

Converts http params to query value..

Parameters

ParamTypeDetails
httpParamsobjectThe httpParams of the query.

Example

QueryService.convertHttpParamsToQuery(value);

convertHttpParamsToUrl(httpParams)

Converts http params into a URL.

Parameters

ParamTypeDetails
httpParamsobjectA query object as http params

Example

QueryService.convertHttpParamsToUrl(query, true);

convertQueryToHttpParams(query, excludeHiddenFilters)

Converts an object based query to HTTP Params.

Parameters

ParamTypeDetails
queryobjectQuery to convert
excludeHiddenFilters (optional)booleanWhether to include hidden filters in the params.

Returns

objectReturns the query object as http params.

Example

QueryService.convertQueryToHttpParams(query);

convertQueryToUrl(query, includeHiddenFilters)

Converts query object into a URL, encoding necessary values correctly and optionally removing hidden filters

Parameters

ParamTypeDetails
queryobjectThe query object.
includeHiddenFiltersbooleanWhether to include hidden filters in the URL

Example

QueryService.convertQueryToUrl(query, true);

convertSortObjectToParam()

Will convert sort object into an parameter.

Example

QueryService.convertSortObjectToParam(obj);

convertSortParamToObject()

Will convert sort parameter into an object.

Example

QueryService.convertSortParamToObject(param);

getQuery(name)

Gets the value of the query from the factory. If no query is found, the factory will return null.

Parameters

ParamTypeDetails
namestringName of the query to retrieve.

Returns

objectReturns the query object, if no query object exists it will return null.

Example

QueryService.getQuery(name);

getQueryAsHttpParams(name, excludeHiddenFilters)

Gets the value of the query from the factory. If no query is found, the factory will return null.

Parameters

ParamTypeDetails
namestringName of the query to retrieve.
excludeHiddenFilters (optional)booleanWhether to include hidden filters in the params.

Returns

objectReturns the query object, if no query object exists it will return null.

Example

QueryService.getQueryAsHttpParams(name);

queryContainsFilterForField(query, fieldName, filter)

Will identify if the query contains the filter.

Parameters

ParamTypeDetails
queryobjectThe query object.
fieldNamestringThe name of the field
filterobjectThe filter object

Example

QueryService.queryContainsFilterForField(query, fieldName, filter);

removeFiltersForField(query, fieldName)

Will remove any filters relating to the field name

Parameters

ParamTypeDetails
queryobjectThe query object.
fieldNamestringThe name of the field

Example

QueryService.removeFiltersForField(query, fieldName);

setQuery(name, value)

Adds the query value to the factory.

Parameters

ParamTypeDetails
namestringName to store the query under.
valueobjectThe value of the query.

Example

QueryService.setQuery(name,value);

Events

query_name_updated

When the query is set or changed Lightning will broadcast this message where name is the name of your query query_name_updated

Type:

broadcast

Target:

root scope