Pathfinder 1e for Foundry VTT
    Preparing search index...

    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 Summary)

    Index

    Constructors

    Properties

    _debouncedFilterChoices: (...args: [event: Event, html: HTMLElement]) => void = ...
    booleanOperator: "NONE" | "AND" | "OR" = 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, Methods<FilterChoice>> = null

    A Collection of FilterChoices for this filter.

    compendiumBrowser: null | CompendiumBrowser

    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.

    autoSort: boolean = false

    Should the choices be automatically sorted?

    Affects only choices retrieved from config.

    booleanOperator: boolean = true

    Is this filter viable for boolean operator?

    defaultBooleanOperator: "AND" = BOOLEAN_OPERATOR.AND

    Default booleanOperator

    Must be "AND" or "OR".

    localizeChoices: boolean = false

    Auto-localize choices.

    Defaults to false due to pre-translation.

    localizeLabel: boolean = false

    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.

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

    The handlebars template used to render this filter.

    type: string = "class"

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

    types: string[] = []

    The types of document this filter applies to.

    Accessors

    • get active(): boolean

      Whether this filter has any active choices.

      Returns boolean

    • get activeChoiceCount(): number

      The number of active choices.

      Returns number

    • get hasControls(): boolean

      Whether this filter provides controls in addition to its choices.

      Returns boolean

    • get hasSearch(): any

      Returns any

    • get handledTypes(): Set<string>

      The authoritative Set of types this filter applies to.

      Returns Set<string>

    • get indexField(): string

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

      Returns string

    • get label(): | "PF1.SavingThrowFort"
      | "PF1.SavingThrowRef"
      | "PF1.SavingThrowWill"

      The label for this filter visible to the user.

      Returns "PF1.SavingThrowFort" | "PF1.SavingThrowRef" | "PF1.SavingThrowWill"

    Methods

    • Protected

      Filter this filter's choices based on a string query.

      Parameters

      • event: Event

        The originating input event

      • html: HTMLElement

        The rendered HTML of this filter

      Returns void

    • Activate event listeners for this filter.

      Parameters

      • html: any

        The rendered HTML element for this filter only

      Returns void

    • Check whether an entry matches this filter. If the filter is not active, this will always return true.

      Parameters

      • entry: any

        The entry to check against this filter

      Returns undefined | boolean

      • Whether the entry matches this filter
    • Provide data necessary to render this filter. The data object generated by BaseFilter#getData contains the minimum data not only required by the filter itself, but also by the rendering CompendiumBrowser.

      Returns {
          boolean: boolean | "NONE" | "AND" | "OR";
          choiceQuery: string;
          hasControls: boolean;
          hasSearch: boolean;
      }

      } The data object for this filter

    • 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
    • Prepare the boolean operator for this filter.

      Returns void

    • Prepare the choices for this filter. This is called after the compendium browser has gathered its entries. By default, this will generate a list of choices from the index field of all entries in the compendium.

      Returns void

    • Adds the index fields checked by this filter to the document's CONFIG object, so that CompendiumCollection#getIndex will include them.

      Returns void

    • Reset all choices and controls to their default state (inactive)

      Returns void

    • Prepare the filter for use. This step expects the compendium browser to have gathered its entries.

      Returns Promise<void>

    • 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?: boolean; labelKey?: string } = {}

        Options determining how the choices are generated.

        • OptionalinnerSet?: boolean

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

        • OptionallabelKey?: 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, Methods<FilterChoice>>

      • A Collection of FilterChoices