Class: Filters

Filters()

A collection of Filter models that represents a full search

Constructor

new Filters()

Source:

Extends

  • Backbone.Collection

Members

mustMatchIds :boolean

If the search results must always match one of the ids in the id filters, then the id filters will be added to the query with an AND operator.
Type:
  • boolean
Source:

Methods

addOwnershipFilter()

Creates and adds a Filter to this collection that filters datasets to only those that the logged-in user has permission to change permission of.
Source:

addWritePermissionFilter()

Creates and adds a Filter to this collection that filters datasets to only those that the logged-in user has permission to write to.
Source:

filterIsAvailable()

Given a Solr field name, determines if that field is set as a filter option
Source:

getGroupQuery(filterModels, operatoropt) → {string}

Get a query string for a group of Filters. The Filters will be ANDed together, unless a different operator is given.
Parameters:
Name Type Attributes Description
filterModels Array.<Filter> The Filters to turn into a query string
operator string <optional>
The oeprator to use between filter models
Source:
Returns:
The query string
Type
string

getQuery() → {string}

Builds the query string to send to the query engine. Iterates over each filter in the collection and adds to the query string.
Source:
Returns:
The query string to send to Solr
Type
string

initialize()

Is executed when a new Filters collection is created
Source:

model(attrs, options) → {Filter|BooleanFilter|ChoiceFilter|DateFilter|NumericFilter|ToggleFilter}

Creates the type of Filter Model based on the given filter type. This function is typically not called directly. It is used by Backbone.js when adding a new model to the collection.
Parameters:
Name Type Description
attrs object A literal object that contains the attributes to pass to the model
options object A literal object of additional options to pass to the model
Properties:
Name Type Description
attrs.filterType string The type of Filter to create
Source:
Returns:
Type
Filter | BooleanFilter | ChoiceFilter | DateFilter | NumericFilter | ToggleFilter

removeEmptyFilters()

removeEmptyFilters - Remove filters from the collection that are lacking fields, values, and in the case of a numeric filter, a min and max value.
Source:

removeFiltersByField(field)

Removes Filter models from this collection if they match the given field
Parameters:
Name Type Description
field string The field whose matching filters that should be removed from this collection
Source:

replaceModel(model, newAttrs) → {Filter}

replaceModel - Remove a Filter from the Filters collection silently, and replace it with a new model.
Parameters:
Name Type Description
model Filter The model to replace
newAttrs object Attributes for the replacement model. Use the filterType attribute to replace with a different type of Filter.
Source:
Returns:
Returns the replacement Filter model, which is already part of the Filters collection.
Type
Filter

visibleIndexOf(model) → {number}

visibleIndexOf - Get the index of a given model, excluding any filters that are marked as invisible.
Parameters:
Name Type Description
model Filter | BooleanFilter | NumericFilter | DateFilter The filter model for which to get the visible index
Source:
Returns:
An integer representing the filter model's position in the list of visible filters.
Type
number