src/lib/components/gridview/PagerStyleManager/pager-style-manager.ts
Pager style manager class
This class provides the methods and build the style for a given pager of a gridview component
Properties |
Methods |
Accessors |
constructor(styleObject: any)
|
||||||
Parameters :
|
style |
Type : PagerStyle
|
The object where the style is built |
styleModel |
Type : any
|
Object to save the pager style coming from the grid view |
setBackColor |
setBackColor()
|
Sets the background color property to style
Returns :
void
|
setBorderColor |
setBorderColor()
|
Sets the border color property to style
Returns :
void
|
setBorderWidth |
setBorderWidth()
|
Sets the border width property to style
Returns :
void
|
setFontColor |
setFontColor()
|
Sets the color property to style
Returns :
void
|
setHeight |
setHeight()
|
Sets the heigth property to style
Returns :
void
|
setPagerStyle |
setPagerStyle()
|
Sets the pager style properties
Returns :
PagerStyle | null
{*} |
setStyleProperty | |||||||||
setStyleProperty(value: propertyStyle, property)
|
|||||||||
Sets the style property new value to the style object
Parameters :
Returns :
void
|
setTop |
setTop()
|
Sets the top property to style
Returns :
PagerStyle
|
setWidth |
setWidth()
|
Sets the width property to style
Returns :
void
|
validateStyleModelProperty | ||||||
validateStyleModelProperty(property: string)
|
||||||
Validates if a property exists into the style model object
Parameters :
Returns :
boolean
{boolean} |
backgroundColor |
getbackgroundColor()
|
Gets the BackColor property
Returns :
any
|
borderColor |
getborderColor()
|
Gets the BorderColor property
Returns :
any
|
borderWidth |
getborderWidth()
|
Gets the BorderWidth property
Returns :
any
|
color |
getcolor()
|
Gets the ForeColor property
Returns :
any
|
height |
getheight()
|
Gets the Height property
Returns :
any
|
width |
getwidth()
|
Gets the Width property
Returns :
any
|
import { PagerVerticalAlign } from '../../../contracts/PagerVerticalAlign';
import { PagerStyle } from '../../../contracts/PagerStyle';
import * as _ from 'lodash';
export type propertyStyle = string | null | undefined;
/**
* Pager style manager class
*
* This class provides the methods and build the style for a given pager of a gridview component
*
* @export
* @class PagerStyleManager
*/
export class PagerStyleManager {
constructor(styleObject: any) {
this.styleModel = styleObject;
this.style = {} as any;
}
/**
* Object to save the pager style coming from the grid view
*
* @type {*}
* @memberof PagerStyleManager
*/
styleModel: any;
/**
* The object where the style is built
*
* @type {PagerStyle}
* @memberof PagerStyleManager
*/
style: PagerStyle;
/**
* Gets the BackColor property
*
* @readonly
* @type {*}
* @memberof PagerStyleManager
*/
get backgroundColor(): any {
return this.styleModel?.BackColor ?? null;
}
/**
* Gets the BorderColor property
*
* @readonly
* @type {*}
* @memberof PagerStyleManager
*/
get borderColor(): any {
return this.styleModel?.BorderColor ?? null;
}
/**
* Gets the BorderWidth property
*
* @readonly
* @type {*}
* @memberof PagerStyleManager
*/
get borderWidth(): any {
return this.styleModel?.BorderWidth ?? null;
}
/**
* Gets the ForeColor property
*
* @readonly
* @type {*}
* @memberof PagerStyleManager
*/
get color(): any {
return this.styleModel?.ForeColor ?? null;
}
/**
* Gets the Height property
*
* @readonly
* @type {*}
* @memberof PagerStyleManager
*/
get height(): any {
return this.styleModel?.Height ?? null;
}
/**
* Gets the Width property
*
* @readonly
* @type {*}
* @memberof PagerStyleManager
*/
get width(): any {
return this.styleModel?.Width ?? '100%';
}
/**
* Sets the background color property to style
*
* @memberof PagerStyleManager
*/
setBackColor(): void {
if (this.validateStyleModelProperty('BackColor')) {
this.setStyleProperty(this.styleModel['BackColor'], 'background-color');
}
}
/**
* Sets the border color property to style
*
* @memberof PagerStyleManager
*/
setBorderColor(): void {
if (this.validateStyleModelProperty('BorderColor')) {
this.setStyleProperty(this.styleModel['BorderColor'], 'border-color');
}
}
/**
* Sets the border width property to style
*
* @memberof PagerStyleManager
*/
setBorderWidth(): void {
if (this.validateStyleModelProperty('BorderWidth')) {
this.setStyleProperty(this.styleModel['BorderWidth'], 'border-width');
}
}
/**
* Sets the color property to style
*
* @memberof PagerStyleManager
*/
setFontColor(): void {
if (this.validateStyleModelProperty('ForeColor')) {
this.setStyleProperty(this.styleModel['ForeColor'], 'color');
}
}
/**
* Sets the heigth property to style
*
* @memberof PagerStyleManager
*/
setHeight(): void {
if (this.validateStyleModelProperty('Height')) {
this.setStyleProperty(this.styleModel['Height'], 'height');
}
}
/**
* Sets the width property to style
*
* @memberof PagerStyleManager
*/
setWidth(): void {
if (this.validateStyleModelProperty('Width')) {
this.setStyleProperty(this.styleModel['Width'], 'width');
}
}
/**
* Sets the top property to style
*
* @memberof PagerStyleManager
*/
setTop(): PagerStyle {
if (this.validateStyleModelProperty('VerticalAlign')) {
switch (this.styleModel['VerticalAlign']) {
case PagerVerticalAlign.Center:
this.setStyleProperty('0%', 'top');
break;
case PagerVerticalAlign.Bottom:
this.setStyleProperty('40%', 'top');
break;
case PagerVerticalAlign.Top:
this.setStyleProperty('-40%', 'top');
break;
default:
break;
}
}
return this.style;
}
/**
* Sets the pager style properties
*
* @return {*} {*}
* @memberof PagerStyleManager
*/
setPagerStyle(): PagerStyle | null {
this.setBackColor();
this.setBorderColor();
this.setBorderWidth();
this.setFontColor();
this.setHeight();
this.setWidth();
this.setTop();
return _.isEmpty(this.style) ? null : this.style;
}
/**
* Sets the style property new value to the style object
*
* @param {propertyStyle} value
* @param {keyof PagerStyle} property
* @memberof PagerStyleManager
*/
setStyleProperty(value: propertyStyle, property: keyof PagerStyle): void {
/* c8 ignore else */
if (value != null && value !== this.style[property]) {
this.style[property] = value;
}
}
/**
* Validates if a property exists into the style model object
*
* @param {string} property
* @return {*} {boolean}
* @memberof PagerStyleManager
*/
validateStyleModelProperty(property: string): boolean {
return this.styleModel && this.styleModel[property] != null;
}
}