All files / components/tek-grid grid-columns-button-controller.ts

13.33% Statements 2/15
0% Branches 0/7
0% Functions 0/3
14.28% Lines 2/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 291x       1x                                                
import { IterableColumnsButtonController, Checkbox } from '@zeedhi/common';
import { IEventParam } from '@zeedhi/core';
import { TekGridColumn } from './grid-column';
 
export class TekGridColumnsButtonController extends IterableColumnsButtonController {
  public changeGroupedColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
    column.grouped = component.value;
    Iif (!column.grouped) {
      const index = this.iterableComponent.datasource.order.indexOf(`${column.name}.asc`);
      this.iterableComponent.datasource.order.splice(index, 1);
    }
    this.iterableComponent.changeLayout(event, element);
  }
 
  public changeAggregationColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
    const newValue = component.value || undefined;
    Iif (column.aggregation !== newValue) {
      this.iterableComponent.changeLayout(event, element);
    }
    column.aggregation = newValue;
  }
 
  public showHideTekColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
    Iif (!component.value && column.grouped) column.grouped = false;
    column.isVisible = component.value;
    this.iterableComponent.changeLayout(event, element);
  }
}