A basic filter class containing common functionality for all filters.

Inheriting classes should define the following static properties: label, indexField. Inheriting classes may define the following static properties: type.

Hierarchy (view full)

Constructors

Properties

_debouncedFilterChoices: ((...args: [event: Event, html: HTMLElement]) => void)
booleanOperator: BooleanOperator = BOOLEAN_OPERATOR.NONE

The boolean operator used to combine choices of this filter. If "OR", an entry will be included if at least one active choice matches. If "AND", an entry will only be included if all active choices match.

choices: null | Collection<FilterChoice> = null

A Collection of FilterChoices for this filter.

compendiumBrowser: null | CompendiumBrowser = null

A reference to the CompendiumBrowser this filter is used in.

id: string

The ID of this filter used to identify it in its browser's filters.

indexField: string = ""

The field this filter checks against its choices. Will also be added to the compendiumIndexFields of the document's CONFIG object.

label: string = ""

The label for this filter visible to the user.

localizeChoices: boolean = false

Auto-localize choices.

Defaults to false due to pre-translation.

localizeLabel: boolean = true

Auto-localize filter label

localizePrefix: string = ""

Prefix to add to choices before localization.

MIN_SEARCH_CHOICES: number | boolean = 10

The minimum number of choices that must be present before the filter will show a search box. Booleans can be used to override this check.

TEMPLATE: string = "systems/pf1/templates/apps/compendium-browser/checkbox-filter.hbs"

The handlebars template used to render this filter.

type: string = ""

A convenience property to define a single type this filter applies to.

types: string[] = []

The types of document this filter applies to.

Accessors

Methods

  • Returns whether this filter has more than the given number of choices. Defaults to 1, as a single choice allows for no real filtering.

    Parameters

    • Optionalnumber: number = 1

      The number of choices to check for

    Returns boolean

    • Whether this filter has more than the given number of choices
  • Toggle the active state of a choice, or set it to a specific state.

    Parameters

    • key: string

      The key of the choice to toggle

    • Optionalstate: null | boolean = null

      The state to set the choice to. If null, the choice will be toggled.

    Returns boolean

    • The new state of the choice
    • If the choice does not exist in this filter
  • Generate a Collection of FilterChoices from a CONFIG object.

    Parameters

    • configObject: Record<string, string> | Record<string, Record<string, string>>

      The object to generate choices from; can be a Record<string, string> or

    • Optionaloptions: {
          innerSet: undefined | boolean;
          labelKey: undefined | string;
      } = {}

      Options determining how the choices are generated.

      • innerSet: undefined | boolean

        Whether choices should be generated from direct properties of the configObject, or from the properties of the inner objects.

      • labelKey: undefined | string

        The key to use to determine the label if the configObject is a Record<string, object>; will be ignored if the configObject is a Record<string, string>.

    Returns Collection<FilterChoice>

    • A Collection of FilterChoices