File

projects/i-components/src/lib/components/grid-column-definition/grid-column-definition.component.ts

Description

Angular Component for the ColumnDefinition.

Implements

OnInit

Metadata

selector wm-grid-column-definition
styleUrls ./grid-column-definition.component.scss
templateUrl ./grid-column-definition.component.html

Index

Properties
Methods
Inputs
Accessors

Constructor

constructor(injector: Injector, injectedModel: GridColumnDefinition)

Creates an instance of GridColumnDefinitionComponent.

Parameters :
Name Type Optional
injector Injector No
injectedModel GridColumnDefinition No

Inputs

maxWidth
Type : number

Sets the maxWidth for the column

minWidth
Type : number

Sets the minWidth for the column

model
Type : GridColumnDefinition

Object with properties and events for the GridColumnDefinition.

width
Type : string

Property used to save the column width.

Methods

ngOnInit
ngOnInit()

Angular lifecycle.

Returns : void

Properties

model
Type : GridColumnDefinition
Decorators :
@Input()

Object with properties and events for the GridColumnDefinition.

Private modelProxy
Type : GridColumnDefinition
Default value : ModelProxy.create<GridColumnDefinition>()

ModelProxy is a copy of the model, used on the component initial building to prevent crashes with external bindings.

Accessors

width
setwidth(value: string)

Property used to save the column width.

Parameters :
Name Type Optional
value string No
Returns : void
maxWidth
getmaxWidth()

Gets the maxWidth for the column

Returns : number
setmaxWidth(value: number)

Sets the maxWidth for the column

Parameters :
Name Type Optional
value number No
Returns : void
minWidth
getminWidth()

Gets the maxWidth for the column

Returns : number
setminWidth(value: number)

Sets the minWidth for the column

Parameters :
Name Type Optional
value number No
Returns : void
widthValue
getwidthValue()

Gets the Width value from the GridColumnDefinition model.

Returns : number
import { Component, Injector, Input, OnInit, Optional } from '@angular/core';
import {
  GridColumnDefinition,
  GridLength,
  ModelProxy,
  GridUnitType,
} from '@mobilize/wms-framework';

/**
 * Angular Component for the ColumnDefinition.
 *
 * @export
 * @class GridColumnDefinitionComponent
 * @implements {OnInit}
 */
@Component({
  selector: 'wm-grid-column-definition',
  templateUrl: './grid-column-definition.component.html',
  styleUrls: ['./grid-column-definition.component.scss'],
})
export class GridColumnDefinitionComponent implements OnInit {
  /**
   * Object with properties and events for the GridColumnDefinition.
   *
   * @type {GridColumnDefinition}
   * @memberof GridColumnDefinitionComponent
   */
  @Input()
  model: GridColumnDefinition;

  /**
   * ModelProxy is a copy of the model, used on the component initial building to prevent crashes with external bindings.
   *
   * @private
   * @type {GridColumnDefinition}
   * @memberof GridColumnDefinitionComponent
   */
  private modelProxy: GridColumnDefinition =
    ModelProxy.create<GridColumnDefinition>();

  /**
   * Creates an instance of GridColumnDefinitionComponent.
   *
   * @param {Injector} injector
   * @param {GridColumnDefinition} [injectedModel=null]
   * @memberof GridColumnDefinitionComponent
   */
  /* istanbul ignore next */
  constructor(
    private injector: Injector,
    @Optional() protected injectedModel: GridColumnDefinition = null
  ) {
    this.model = injectedModel;
  }

  /**
   * Property used to save the column width.
   *
   * @memberof GridColumnDefinitionComponent
   */
  @Input()
  set width(value: string) {
    if (Number(value)) {
      this.modelProxy.Width = new GridLength(Number(value), GridUnitType.Pixel);
    } else if (value.toLowerCase() === 'auto') {
      this.modelProxy.Width = 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.Width = new GridLength(starNumber, GridUnitType.Star);
    }
  }

  /**
   * Sets the maxWidth for the column
   *
   * @memberof GridColumnDefinitionComponent
   */
  @Input()
  set maxWidth(value: number) {
    this.modelProxy.MaxWidth = value;
  }

  /**
   * Gets the maxWidth for the column
   *
   * @readonly
   * @type {number}
   * @memberof GridColumnDefinitionComponent
   */
  get maxWidth(): number {
    return this.model.MaxWidth;
  }

  /**
   * Sets the minWidth for the column
   *
   * @memberof GridColumnDefinitionComponent
   */
  @Input()
  set minWidth(value: number) {
    this.modelProxy.MinWidth = value;
  }

  /**
   * Gets the maxWidth for the column
   *
   * @readonly
   * @type {number}
   * @memberof GridColumnDefinitionComponent
   */
  get minWidth(): number {
    return this.model.MinWidth;
  }

  /**
   * Gets the Width value from the GridColumnDefinition model.
   *
   * @readonly
   * @type {number}
   * @memberof GridColumnDefinitionComponent
   */
  get widthValue(): number {
    return this.model.Width.Value;
  }

  /**
   * Angular lifecycle.
   *
   * @memberof GridColumnDefinitionComponent
   */
  ngOnInit(): void {
    this.model = this.model || this.injectedModel || new GridColumnDefinition();
    ModelProxy.copy(this.modelProxy, this.model);
    this.modelProxy = this.model;
  }
}
<div></div>

./grid-column-definition.component.scss

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""