This module was written with the express purpose of working with the ComboBox
form control. It extends the Dojo JsonRest module to support queries over the Aikau publication/subscription
communication layer (rather than by direct XHR request).
- Copyright:
- Copyright (C) 2005-2020 Alfresco Software Limited
- License:
- GNU Lesser General Public License, see: Open Source Licensing
- Source:
Extends
Members
-
fixed :array
-
If this is configured to be an array of fixed options then the query will be run against those options without constantly making XHR requests for fresh data.
Type:
- array
- Default Value:
- null
- Source:
-
publishPayload :object
-
The payload to publish on the publishTopic to assist with retrieving data.
Type:
- object
- Default Value:
- null
- Source:
-
publishTopic :string
-
This is the topic to publish to get the options for.
Type:
- string
- Default Value:
- null
- Source:
-
queryAttribute :string
-
This is the attribute to use when querying the result data for matching items. This is set to "name" by default but can be overridden. When used by a form control it would be expected that this would be set to be the name attribute of that form control.
Type:
- string
- Default Value:
- "name"
- Source:
-
searchStartsWith :string
-
Should the results all start with the search query string. If set to false, results that contain the string anywhere will match
Type:
- string
- Default Value:
- false
- Source:
Methods
-
createSearchRegex(queryString, ignorePostMatch) → {object}
-
Create the regex used for querying
Parameters:
Name Type Description queryString
string The supplied query string ignorePostMatch
boolean Whether to append ".*$" to the string (defaults to including this) Returns:
The regular expression to use in the query engine- Type
- object
-
get(id, options)
-
This function is called to retrieve an item from the store. If the store uses fixed options then these are checked and if an XHR request is required then a deferred item will be returned pending a callback to the onGetOptions function.
Parameters:
Name Type Description id
string The id of the item to retrieve from the store options
object Options for finding the item Returns:
Either the item or a promise of the item -
getOption(results, id) → {object}
-
Iterates over the supplied results array to try and find an item where it's valueAttribute matches the supplied id.
Parameters:
Name Type Description results
array The results to iterate over id
string The id of the item to find Returns:
The found item (or the empty string if the item cannot be found)- Type
- object
-
onGetOptions(dfd, resultsProperty, id, payload)
-
This is the callback function that is hitched to the request for
Parameters:
Name Type Description dfd
obejct The deferred object to resolve. resultsProperty
string A dot-notation address in the payload that should contain the list of options. id
string The id of the item to retrieve payload
object The options to use -
onQueryOptions(dfd, query, resultsProperty, payload)
-
This is hitched to a generated topic subscription that is published when the target service has retrieved the requested data. It performs a query on the data provided to generate the result set.
Parameters:
Name Type Description dfd
obejct The deferred object to resolve. query
object The requested query data. resultsProperty
string A dot-notation address in the payload that should contain the list of options. payload
object The options to use -
processResult(options, config, item, index)
-
Processes the results to check that all the data is valid, this is done to ensure any data sets that don't contain all the data are corrected.This is a workaround for an issue with the Dojo query engine that will break when an item doesn't contain the query attribute. This function also adds label and value attributes to the item if they're not present.
Parameters:
Name Type Description options
array The array to add the processed item to config
object The configuration to use for processing the option item
object The current item to process as an option index
number The index of the item in the items list -
query(query, options) → {object}
-
Overrides the inherited function from the JsonRest store to call either the queryXhrOptions or [queryFixedOptions]{@link module:alfresco/forms/controls/utilities/ServiceStore#queryFixedOptions} depending upon how this module has been configured.
Parameters:
Name Type Description query
object The query to use for retrieving objects from the store. options
object The optional arguments to apply to the resultset. Returns:
The rmodule:alfresco/forms/controls/utilities/ServiceStore#onQueryOptions esults of the query, extended with iterative methods.- Type
- object
-
queryFixedOptions(query, options) → {object}
-
Queries a fixed set of options.
Parameters:
Name Type Description query
object The query to use for retrieving objects from the store. options
object The optional arguments to apply to the resultset. Returns:
The results of the query, extended with iterative methods.- Type
- object
-
queryResults(results)
-
This function is used to actually query the results (either from a pub/sub request or defined in a fixed list of options).
Parameters:
Name Type Description results
array The results to query. -
queryXhrOptions(query, options) → {object}
-
Makes a request for data by publishing a request on a specific topic. This returns a Deferred object which is resolved by the onQueryOptions function.
Parameters:
Name Type Description query
object The query to use for retrieving objects from the store. options
object The optional arguments to apply to the resultset. Returns:
The results of the query, extended with iterative methods.- Type
- object