gp-crm-ui
Version:
Модуль компонентов UI Имя модуля: `gp-crm-ui`
90 lines (63 loc) • 2.58 kB
text/typescript
// Интерфейсы
import { IColumn, IColumnDefinition } from '../interfaces';
// Компоненты
import { CrmTableDefaultCellComponent } from '../components/crm-table-default-cell/crm-table-default-cell.component';
// Перечисления
import { SortType } from '../enums';
// Столбец
export class Column implements IColumn {
// Флаг закрепленного столбца (по умолчанию)
private static readonly IS_PINNED: boolean = false;
// Флаг отображаемого столбца (по умолчанию)
private static readonly IS_VISIBLE: boolean = true;
// Флаг наличия сортировки (по умолчанию)
private static readonly IS_SORTED: boolean = false;
// Тип сортировки (по умолчанию)
private static readonly SORT_TYPE: SortType = SortType.None;
// Ширина столбца (по умолчанию)
private static readonly WIDTH: number = 160;
// Наименование столбца в шапке таблицы
public headerName: string;
// Наименование поля из обьекта строки
public field: string;
// Флаг закрепленного столбца
public isPinned: boolean;
// Флаг отображаемого столбца
public isVisible: boolean;
// Флаг наличия сортировки
public isSorted: boolean;
// Тип сортировки
public sortType: SortType;
// Ширина столбца
public width: number;
// Смещение от начала области отображения
public offset: number;
// Флаг перемещения
public isSwap: boolean;
// Компонент ячейки
public component: any;
// События
public events: any;
// Конструктор
constructor(columnDefinition: IColumnDefinition) {
this.headerName = columnDefinition.headerName;
this.field = columnDefinition.field;
this.events = columnDefinition.events;
this.component = columnDefinition.component || CrmTableDefaultCellComponent;
this.isPinned = columnDefinition.pinned != null
? columnDefinition.pinned
: Column.IS_PINNED;
this.isVisible = columnDefinition.visible != null
? columnDefinition.pinned
: Column.IS_VISIBLE;
this.isSorted = columnDefinition.sorted != null
? columnDefinition.sorted
: Column.IS_SORTED;
this.sortType = Column.SORT_TYPE;
this.width = columnDefinition.width != null
? columnDefinition.width
: Column.WIDTH;
this.offset = 0;
this.isSwap = false;
}
}