@neoprospecta/angular-data-box
Version:
Data table with REST implementation.
54 lines (51 loc) • 3.54 kB
text/typescript
import { DataBoxAction } from './data-box-action.model';
export class DataBoxColumn {
attr: string | Function; // object attribute to be shown in the column
attr2: string | Function; // sub object attribute to be shown in the column
arrayAttr: string | Function; // used to define the label of items in a given array.
header: string; // the header of the column
sort: boolean = true; // if should sort the column
search: boolean = true; // if should include the the column in the search
align: 'left' | 'center' | 'right' = 'left'; // where the content should be aligned
fitText: boolean = false; // if true, the width of the table will be equal que text contained in it
tooltip: string | Function; // text to be shown when the mouse is over the header
maxLength: number; // max length of the content in the cell. The rest is shown by a tooltip
editable: boolean = false; // Allow object edition directly in the table
selectable: boolean = false; // Allow object edition directly in the table
type: 'date' | 'date-time' | 'text' | 'boolean' | 'array' | 'currency' | 'number' | 'option' | 'text-icon'; // The type pf the data that will be displayed
currencyLocation: string; // Used to define which location currency must be used Eg. 'BRL', 'EUR'
dateFormat: string; // in case of date or date-time tipe, the format should be passed
max: number; // Defines the maximum number value of a number input
min: number; // Defines the minimum number value of a number input
options: any[]; // An array of options to be used in a select. The options must have id and label as [{id: 'option_value', 'label': 'option_label'}]
unique: boolean;
actions: Array<DataBoxAction>;
fontIcon: string | Function;
colorIcon: string | Function;
disable: boolean | Function;
constructor(object?: any) {
this.attr = (object && object.attr) ? object.attr : undefined;
this.attr2 = (object && object.attr2) ? object.attr2 : undefined;
this.arrayAttr = (object && object.arrayAttr) ? object.arrayAttr : undefined;
this.header = (object && object.header) ? object.header : undefined;
this.sort = (object && object.sort) ? object.sort : undefined;
this.search = (object && object.search) ? object.search : undefined;
this.align = (object && object.align) ? object.align : undefined;
this.fitText = (object && object.fitText) ? object.fitText : undefined;
this.tooltip = (object && object.tooltip) ? object.tooltip : undefined;
this.maxLength = (object && object.maxLength) ? object.maxLength : undefined;
this.editable = (object && object.editable) ? object.editable : false;
this.selectable = (object && object.selectable) ? object.selectable : false;
this.type = (object && object.type) ? object.type : 'text';
this.dateFormat = (object && object.dateFormat) ? object.dateFormat : 'dd/MM/yy';
this.currencyLocation = (object && object.currencyLocation) ? object.currencyLocation : 'USD';
this.max = (object && object.max) ? object.max : undefined;
this.min = (object && object.min) ? object.min : undefined;
this.options = (object && object.options) ? object.options : [];
this.unique = (object && object.unique) ? object.unique : false;
this.actions = (object && object.actions) ? object.actions : [];
this.fontIcon = (object && object.fontIcon) ? object.fontIcon : undefined;
this.colorIcon = (object && object.colorIcon) ? object.colorIcon : 'black';
this.disable = (object && object.disable) ? object.disable : false;
}
}