@amirsavand/ngx-common - v5.1.0
    Preparing search index...

    Class Selection<T>

    Takes a list of items and handles selection for them.

    Type Parameters

    • T
    Index

    Constructors

    • Type Parameters

      • T

      Parameters

      • items: T[]

        List of original items to set up selection for.

      • pkField: keyof T = ...

        Item unique property key to store selection by.

      • pksSelected: PK[] = []

        List of item PKs that are selected.

      Returns Selection<T>

    Properties

    deselected: number = 0

    Number of deselected items.

    indeterminate: boolean = false

    Is selection indeterminate?

    items: T[]

    List of original items to set up selection for.

    onChange: EventEmitter<void> = ...

    Triggers whenever any selection change happen.

    onDeselect: EventEmitter<T> = ...

    Triggers when an item is deselected.

    onDeselectAll: EventEmitter<T> = ...

    Triggers when all items are deselected. Only when Selection.deselectAll is called.

    onSelect: EventEmitter<T> = ...

    Triggers when an item is selected.

    onSelectAll: EventEmitter<T> = ...

    Triggers when all items are selected. Only when Selection.selectAll is called.

    pkField: keyof T = ...

    Item unique property key to store selection by.

    selected: number = 0

    Number of selected items.

    selection: Record<PK, boolean> = {}

    Selection dict.

    This is where we keep which item is selected (value true) and which item is not (value not true).

    Accessors

    • get selectedItems(): T[]

      Returns T[]

      List of original items that are selected

    Methods

    • Update selected and deselected numbers. Also update indeterminate status.

      Returns void

    • Deselect an item.

      Parameters

      • item: T

        to deselect.

      • count: boolean = true

        Whether to generate counts (default is true).

      Returns void

    • Deselect all items.

      Returns void

    • Parameters

      • item: T

      Returns PK

      the PK of the given item.

    • Reset all selection and update the count.

      Returns void

    • Select an item.

      Parameters

      • item: T

        to select.

      • count: boolean = true

        Whether to generate counts (default is true).

      Returns void

    • Select all items.

      Returns void

    • Select all if selection is indeterminate or no item is selected otherwise deselect all.

      Returns void

    • Select the given items PKs

      Parameters

      • pks: PK[]

        to select.

      Returns void

    • Toggle an item selection status.

      Parameters

      • item: T

        to toggle selection.

      • count: boolean = true

        Whether to generate counts (default is true).

      Returns void