Project

General

Profile

Actions

Cleanup #42907

open

mgr/dashboard: make CdTableSelection generic

Added by Patrick Seidensal over 4 years ago. Updated about 3 years ago.

Status:
New
Priority:
Normal
Category:
General
Target version:
-
% Done:

0%

Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:

Description

The CdTableSelection class of the dashboards frontend is a perfect candidate to become a generic class.

export class CdTableSelection<T> {
  selected: T[] = [];
  hasMultiSelection: boolean;
  hasSingleSelection: boolean;
  hasSelection: boolean;

  constructor() {
    this.update();
  }

  /**
   * Recalculate the variables based on the current number
   * of selected rows.
   */
  update() {
    this.hasSelection = this.selected.length > 0;
    this.hasSingleSelection = this.selected.length === 1;
    this.hasMultiSelection = this.selected.length > 1;
  }

  /**
   * Get the first selected row.
   * @return {T | null}
   */
  first(): T {
    return this.hasSelection ? this.selected[0] : null;
  }
}

Actions #1

Updated by Patrick Seidensal over 4 years ago

  • Subject changed from mgr/dashboard: make CdTableColumn generic to mgr/dashboard: make CdTableSelection generic
  • Description updated (diff)
Actions #2

Updated by Ernesto Puerta about 3 years ago

  • Project changed from mgr to Dashboard
  • Category changed from 132 to General
Actions

Also available in: Atom PDF