File

projects/i-components/src/lib/components/solid-color-brush/solid-color-brush.component.ts

Description

Angular Component for the SolidColorBrush Control.

Extends

BaseWrapperComponent

Implements

OnInit

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector wm-solid-color-brush
styleUrls ./solid-color-brush.component.scss
templateUrl ./solid-color-brush.component.html

Index

Properties
Methods
Inputs
Accessors

Constructor

Public constructor(injector: Injector, injectedModel: SolidColorBrushModel)

Creates an instance of SolidColorBrushComponent.

Parameters :
Name Type Optional Description
injector Injector No
  • Angular Injector
injectedModel SolidColorBrushModel No
  • SolidColorBrush model for the current Angular Component

Inputs

color
Type : any

Sets a value indicating whether ther user can interact with the control

model
Type : SolidColorBrushModel

Object with properties and events for the SolidColorBrush.

Methods

getBrush
getBrush()

Returns a SolidColorBrush object with the color assigned

Returns : SolidColorBrush

SolidColorBrush

ngOnInit
ngOnInit()

Angular lifeCycle hook

Returns : void
Protected applyPendingResourceAssignment
applyPendingResourceAssignment(model: DependencyObject)
Inherited from BaseWrapperComponent

Apply pending resource assignments

Parameters :
Name Type Optional
model DependencyObject No
Returns : void
Protected checkForStaticResourceReference
checkForStaticResourceReference(property: DependencyProperty, obj: any)
Inherited from BaseWrapperComponent

Verifies if the given value is a resource value

Parameters :
Name Type Optional Description
property DependencyProperty No

property to assign

obj any No

static resource reference candidate

Returns : boolean

{boolean} true if the value was assigned

Protected resolveResource
resolveResource(key: any)
Inherited from BaseWrapperComponent

Resolve the resource in the current context

Parameters :
Name Type Optional
key any No
Returns : any

Properties

model
Type : SolidColorBrushModel
Decorators :
@Input()

Object with properties and events for the SolidColorBrush.

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

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

Protected pendingResourceValues
Type : Array<>
Inherited from BaseWrapperComponent

Pending resource assignments

These assignments are performed when the model is available

Protected pendingSetValuesColumns
Type : Array<>
Default value : []
Inherited from BaseWrapperComponent

A collection of pending values to assign to the model

Accessors

color
getcolor()

Gets the color of the brush

Returns : any
setcolor(value: any)

Sets a value indicating whether ther user can interact with the control

Parameters :
Name Type Optional
value any No
Returns : void
import {
  Component,
  OnInit,
  Input,
  Optional,
  Injector,
  ChangeDetectionStrategy,
} from '@angular/core';
import {
  SmColor,
  SolidColorBrushModel,
  SolidColorBrush,
  ModelProxy,
  ComponentId,
  AngularComponentId,
} from '@mobilize/wms-framework';
import { Utils } from '../../utils/utilities';
import { BaseWrapperComponent } from '../basewrapper/basewrapper.component';

/**
 * Angular Component for the SolidColorBrush Control.
 *
 * @export
 * @class SolidColorBrushComponent
 * @implements {OnInit}
 */
@Component({
  selector: 'wm-solid-color-brush',
  templateUrl: './solid-color-brush.component.html',
  styleUrls: ['./solid-color-brush.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
@ComponentId([AngularComponentId.solidColorBrush])
export class SolidColorBrushComponent
  extends BaseWrapperComponent
  implements OnInit
{
  /**
   * Object with properties and events for the SolidColorBrush.
   *
   * @type {SolidColorBrushModel}
   * @memberof SolidColorBrushComponent
   */
  @Input() model: SolidColorBrushModel;

  /**
   * Sets a value indicating whether ther user can interact with the control
   *
   * @memberof SolidColorBrushComponent
   */
  @Input() set color(value: any) {
    if (
      !this.checkForStaticResourceReference(
        SolidColorBrushModel.ColorProperty,
        value
      )
    ) {
      this.modelProxy.Color =
        value instanceof SmColor ? value : Utils.createSmColor(value);
    }
  }

  /**
   * Gets the color of the brush
   *
   * @readonly
   * @type {any}
   * @memberof SolidColorBrushComponent
   */
  get color(): any {
    return this.model.Color ? this.model.Color : undefined;
  }

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

  /**
   * Creates an instance of SolidColorBrushComponent.
   *
   * @param {Injector} injector - Angular Injector
   * @param {SolidColorBrushModel} [injectedModel=null] - SolidColorBrush model for the current Angular Component
   * @memberof SolidColorBrushComponent
   */
  /* istanbul ignore next */
  public constructor(
    private injector: Injector,
    @Optional() protected injectedModel: SolidColorBrushModel = null
  ) {
    super();
    this.model = injectedModel;
  }

  /**
   * Angular lifeCycle hook
   *
   * @memberof SolidColorBrushComponent
   */
  ngOnInit(): void {
    this.model = this.model || this.injectedModel || new SolidColorBrushModel();
    ModelProxy.copy(this.modelProxy, this.model);
    this.modelProxy = this.model;
    this.applyPendingResourceAssignment(this.model);
  }

  /**
   * Returns a SolidColorBrush object with the color assigned
   *
   * @returns SolidColorBrush
   */
  getBrush(): SolidColorBrush {
    const brush = new SolidColorBrush(this.color);
    return brush;
  }
}
<ng-container></ng-container>

./solid-color-brush.component.scss

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""