/* Copyright CloudLinux Zug GmbH 2010-2017 All Rights Reserved
*
* Licensed under CLOUD LINUX LICENSE AGREEMENT
* http://cloudlinux.com/docs/LICENSE.TXT
*/
import { ConvertFormat } from './types';
import { Tool } from '../model/tool';
export interface ColumnProperties {
name: string;
descr: string;
group?: string;
convertToFormat: ConvertFormat;
hidden?: boolean;
showEditOrValue?: boolean;
}
export class Column {
name: string;
descr: string;
hidden: boolean;
group: string;
icon: string;
tooltip: string = '';
sortable: boolean = true;
showEditOrValue: boolean = true;
alignClass: string = '';
additionCssClass: string = '';
action: Function = null;
button: Tool = null;
isSwitcher: boolean = false;
hasRunningStatus: boolean = false;
convertToFormat: ConvertFormat;
span: number = 1;
isVisible: boolean = true;
constructor(params: ColumnProperties){
this.name = params.name;
this.descr = params.descr;
this.convertToFormat = params.convertToFormat;
this.hidden = params.hidden || false;
this.group = params.group || null;
this.showEditOrValue = params.showEditOrValue || false;
}
setAlign(align: TypeOfAlignment = null) {
this.alignClass = align + '-align';
return this;
}
setAdditionCssClass(addClass: string) {
this.additionCssClass = addClass;
return this;
}
setIcon(icon: string) {
this.icon = icon;
return this;
}
setTooltip(tooltip: string) {
this.tooltip = tooltip;
return this;
}
setButton(button: Tool) {
this.button = button;
return this;
}
sortableDisable() {
this.sortable = false;
return this;
}
setFormat(format: ConvertFormat) {
this.convertToFormat = format;
return this;
}
hide() {
this.hidden = true;
return this;
}
show() {
this.hidden = false;
return this;
}
setAction(action: Function) {
this.action = action;
return this;
}
makeSwitcher() {
this.isSwitcher = true;
return this;
}
makeRunningStatus() {
this.hasRunningStatus = true;
return this;
}
}
export type TypeOfAlignment = 'left' | 'center' | 'right' | null;
|