projects/i-components/src/lib/components/grid-row-definition/grid-row-definition.component.ts
Angular Component for the RowDefinition.
selector | wm-grid-row-definition |
styleUrls | ./grid-row-definition.component.scss |
templateUrl | ./grid-row-definition.component.html |
Properties |
|
Methods |
Inputs |
Accessors |
constructor(injector: Injector, injectedModel: GridRowDefinition)
|
|||||||||
Creates an instance of GridRowDefinitionComponent.
Parameters :
|
height | |
Type : string
|
|
Property used to save the row height. |
maxHeight | |
Type : number
|
|
Sets the maxHeight for the row |
minHeight | |
Type : number
|
|
Sets the minHeight for the row |
model | |
Type : GridRowDefinition
|
|
Object with properties and events for the GridRowDefinition. |
ngOnInit |
ngOnInit()
|
Angular lifecycle.
Returns :
void
|
model |
Type : GridRowDefinition
|
Decorators :
@Input()
|
Object with properties and events for the GridRowDefinition. |
Private modelProxy |
Type : GridRowDefinition
|
Default value : ModelProxy.create<GridRowDefinition>()
|
ModelProxy is a copy of the model, used on the component initial building to prevent crashes with external bindings. |
height | ||||||
setheight(value: string)
|
||||||
Property used to save the row height.
Parameters :
Returns :
void
|
maxHeight | ||||||
setmaxHeight(value: number)
|
||||||
Sets the maxHeight for the row
Parameters :
Returns :
void
|
minHeight | ||||||
setminHeight(value: number)
|
||||||
Sets the minHeight for the row
Parameters :
Returns :
void
|
heightValue |
getheightValue()
|
Gets the Height value from the GridRowDefinition model.
Returns :
number
|
import { Component, Injector, Input, OnInit, Optional } from '@angular/core';
import {
GridLength,
GridRowDefinition,
ModelProxy,
GridUnitType,
} from '@mobilize/wms-framework';
/**
* Angular Component for the RowDefinition.
*
* @export
* @class GridRowDefinitionComponent
* @implements {OnInit}
*/
@Component({
selector: 'wm-grid-row-definition',
templateUrl: './grid-row-definition.component.html',
styleUrls: ['./grid-row-definition.component.scss'],
})
export class GridRowDefinitionComponent implements OnInit {
/**
* Object with properties and events for the GridRowDefinition.
*
* @type {GridRowDefinition}
* @memberof GridRowDefinitionComponent
*/
@Input()
model: GridRowDefinition;
/**
* ModelProxy is a copy of the model, used on the component initial building to prevent crashes with external bindings.
*
* @private
* @type {GridRowDefinition}
* @memberof GridRowDefinitionComponent
*/
private modelProxy: GridRowDefinition =
ModelProxy.create<GridRowDefinition>();
/**
* Creates an instance of GridRowDefinitionComponent.
*
* @param {Injector} injector
* @param {GridRowDefinition} [injectedModel=null]
* @memberof GridRowDefinitionComponent
*/
/* istanbul ignore next */
constructor(
private injector: Injector,
@Optional() protected injectedModel: GridRowDefinition = null
) {
this.model = injectedModel;
}
/**
* Property used to save the row height.
*
* @memberof GridRowDefinitionComponent
*/
@Input()
set height(value: string) {
if (Number(value)) {
this.modelProxy.Height = new GridLength(
Number(value),
GridUnitType.Pixel
);
} else if (value.toLowerCase() === 'auto') {
this.modelProxy.Height = new GridLength(0, GridUnitType.Auto);
} /* istanbul ignore else */ else if (value.endsWith('*')) {
const starNumber =
Number(value.slice(0, -1)) === 0 ? 1 : Number(value.slice(0, -1));
this.modelProxy.Height = new GridLength(starNumber, GridUnitType.Star);
}
}
/**
* Sets the maxHeight for the row
*
* @memberof GridRowDefinitionComponent
*/
@Input()
set maxHeight(value: number) {
this.modelProxy.MaxHeight = value;
}
/**
* Sets the minHeight for the row
*
* @memberof GridRowDefinitionComponent
*/
@Input()
set minHeight(value: number) {
this.modelProxy.MinHeight = value;
}
/**
* Gets the Height value from the GridRowDefinition model.
*
* @readonly
* @type {number}
* @memberof GridRowDefinitionComponent
*/
get heightValue(): number {
return this.model.Height.Value;
}
/**
* Angular lifecycle.
*
* @memberof GridRowDefinitionComponent
*/
ngOnInit(): void {
this.model = this.model || this.injectedModel || new GridRowDefinition();
ModelProxy.copy(this.modelProxy, this.model);
this.modelProxy = this.model;
}
}
<div></div>
./grid-row-definition.component.scss