Class: QueryRuleView

QueryRuleView()

A view that provides an UI for a user to construct a single filter that is part of a complex query

Screenshot

Constructor

new QueryRuleView()

Since:
  • 2.14.0
Source:

Extends

  • Backbone.View

Members

className :string

The HTML class names for this view element
Type:
  • string
Source:

excludeFields :Array.<string>

Search index fields to exclude in the metadata field selector
Type:
  • Array.<string>
Source:

fieldsClass :string

The class to add to the field select element
Type:
  • string
Source:

model :Filter|BooleanFilter|NumericFilter|DateFilter

A single Filter model that is part of a Filters collection, such as the definition filters for a Collection or Portal or the filters for a Search model. The Filter model must be part of a Filters collection (i.e. there must be a model.collection property)
Type:
Source:

operatorClass :string

The class to add to the operator select element
Type:
  • string
Source:

operatorOptions :Array.<object>

Defined the user-friendly operators that will be available in the dropdown list to connect the query fields to the query values. Each operator must be unique. This definition is used to pre-select the correct operator based on attributes in the associated filter model, as well as to update the filter model when a user selects a new operator.
Type:
  • Array.<object>
Properties:
Name Type Description
label string The label to display to the user
icon string An icon that represents the operator
matchSubstring boolean Whether the matchSubstring attribute is true or false in the filter model that matches this operator
exclude boolean Whether the exclude attribute is true or false in the filter model that matches this operator
hasMax boolean Whether the filter model that matches this operator must have a max attribute
hasMin boolean Whether the filter model that matches this operator must have a min attribute
values Array.<string> For this operator to work as desired, the values that should be set in the filter (e.g. ["true"] for the operator "is true")
types Array.<string> The node names of the filters that this operator is used for (e.g. "filter", "booleanFilter")
Source:

removeClass :string

The class to add to the button that a user clicks to remove a rule
Type:
  • string
Source:

removePreviewClass :string

The class to add to the view when a user hovers over the remove button
Type:
  • string
Source:

ruleColorPalette :Array.<string>

An array of hex color codes used to help distinguish between different rules
Type:
  • Array.<string>
Source:

ruleInfoClass :string

The class to add to the rule number and other information on the left
Type:
  • string
Source:

type :string

The type of View this is
Type:
  • string
Source:

valuesClass :string

The class to add to the value select element
Type:
  • string
Source:

valueSelectUImap :Array.<object>

The third input in each query rule is where the user enters a value, minimum, or maximum for the filter model. Different types of values are appropriate for different solr query fields, and so we display different interfaces depending on the type and category of the selected query fields. This object defines which type of interface to show depending on type and category. The list of interface requirements is ordered from *most* specific to *least*, since the first match will be selected. The query (metadata) fields must match both the filterTypes AND the categoes for a UI to be selected.
Type:
  • Array.<object>
Properties:
Name Type Description
filterTypes Array.<string> An array of one or more filter types that are allowed for this interface. If none are provided then any filter type is allowed.
categories Array.<string> An array of one or more categories that are allowed for this interface. These strings must exactly match the categories provided in QueryField.categoriesMap(). If none are provided then any category is allowed.
queryFields Array.<string> Specific names of fields that are allowed in this interface. If none are provided, then any query fields are allowed that match the other properties.
label string If the interface does not include a label (e.g. number filter), include a string to display here.
uiFunction function A function that returns the UI view to use with all appropriate options set. The function will be called with this view as the context.
Source:

Methods

addFieldSelect()

Create and insert an input that allows the user to select a metadata field to query
Source:

addOperatorSelect(selectedOperator)

Create and insert an input field where the user can select an operator for the given rule. Operators will vary depending on filter model type.
Parameters:
Name Type Description
selectedOperator string optional. The label of an operator to pre-select. Set to an empty string to render an empty operator selector.
Source:

addRemoveButton()

addRemoveButton - Create and insert the button to remove the query rule
Source:

addValueSelect()

Create and insert an input field where the user can provide a search value
Source:

events()

The events this view will listen to and the associated function to call.
Source:

getCategory(fields) → {type}

getCategory - description
Parameters:
Name Type Description
fields type description
Source:
Returns:
description
Type
type

getRequiredFilterType(fields) → {string}

getRequiredFilterType - Based on an array of query (Solr) fields, get the type of filter model this rule should use. For example, if the fields are type text, use a regular filter model. If the fields are tdate, use a dateFilter. Also decide which filter to use if the field types are mixed.
Parameters:
Name Type Description
fields Array.<string> The list of selected fields
Source:
Returns:
The nodeName of the filter model to use
Type
string

getSelectedOperator() → {string}

getSelectedOperator - Based on values set on the model, get the label to show in the "operator" filed of the Query Rule
Source:
Returns:
The operator label
Type
string

handleFieldChange(newFields)

handleFieldChange - Called when the Query Field Select View triggers a change event. Updates the model with the new fields, and if required, 1) converts the filter model to a different type based on the types of fields selected, 2) updates the operator select and the value select
Parameters:
Name Type Description
newFields Array.<string> The list of new query fields that were selected
Source:

handleOperatorChange(newOperatorLabel)

handleOperatorChange - When the operator selection is changed, update the model and re-set the value UI when required
Parameters:
Name Type Description
newOperatorLabel Array.<string> The new operator label within an array, e.g. ["is greater than"]
Source:

handleValueChange(newValues)

handleValueChange - Called when the select values for rule are changed. Updates the model.
Parameters:
Name Type Description
newValues Array.<string> The new values that were selected
Source:

initialize(options)

Creates a new QueryRuleView
Parameters:
Name Type Description
options Object A literal object with options to pass to the view
Source:

removeInput(inputType)

Remove one of the three input fields from the rule
Parameters:
Name Type Description
inputType string Which of the inputs to remove? "field", "operator", or "value"
Source:

removeSelf() → {type}

removeSelf - When the delete button is clicked, remove this entire View and associated model
Source:
Returns:
description
Type
type

render() → {QueryRule}

render - Render the view
Source:
Returns:
Returns the view
Type
QueryRule

validateValue() → {type}

Ensure the value entered is valid, given the metadata field selected. If it's not, show an error. If it is, remove the error if there was one.
Source:
Returns:
description
Type
type