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.

Abstract

Hierarchy

Constructors

Properties

_choiceQuery: string = ""

A string used to determine which choices are shown.

_debouncedFilterChoices: ((...args) => void)

Type declaration

    • (...args): void
    • Wrap a callback in a debounced timeout. Delay execution of the callback function until the function has not been called for delay milliseconds

      Parameters

      • Rest ...args: [event: Event, html: HTMLElement]

      Returns void

      A wrapped function which can be called to debounce execution

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>

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.

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.

indexField: string = ""

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

Abstract

label: string = ""

The label for this filter visible to the user.

Abstract

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

    • Optional number: 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

    • Optional state: 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

    Throws

    • 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

    • Optional options: {
          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

Generated using TypeDoc