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

100% Statements 15/15
100% Branches 7/7
100% Functions 3/3
100% Lines 14/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 29  112x     112x   2x 2x 1x 1x   2x       3x 3x 2x   3x       2x 2x 2x      
import { IEventParam } from '@zeedhi/core';
import { Checkbox, IterableColumnsButtonController } from '../..';
import { TekGridColumn } from '../tek-grid-column';
 
export class TekGridColumnsButtonController extends IterableColumnsButtonController {
	public changeGroupedColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
		column.grouped = component.value;
		if (!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;
		if (column.aggregation !== newValue) {
			this.iterableComponent.changeLayout(event, element);
		}
		column.aggregation = newValue;
	}
 
	public showHideTekColumn(column: TekGridColumn, { component, event, element }: IEventParam<Checkbox>) {
		if (!component.value && column.grouped) column.grouped = false;
		column.isVisible = component.value;
		this.iterableComponent.changeLayout(event, element);
	}
}