File

projects/i-components/src/lib/components/xam-tree-item/xam-tree-item.component.ts

Description

XamTreeItem component class

Implements

OnInit

Metadata

selector wm-xam-tree-item
styleUrls ./xam-tree-item.component.scss
templateUrl ./xam-tree-item.component.html

Index

Properties
Methods
Inputs
Accessors

Constructor

Public constructor(injectedModel: XamTreeItemModel)

Creates an instance of XamTreeItemComponent.

Parameters :
Name Type Optional
injectedModel XamTreeItemModel No

Inputs

header
Type : any

Gets/sets the visibility property for the XamTreeItemModel

model
Type : XamTreeItemModel

Object with properties and events for the XamTree.

name
Type : string

Sets the name model property for the control when the name is an input

visibility
Type : boolean

Gets/sets the visibility property for the XamTreeItemModel

Methods

checkAndRegisterCompatibilityBinding
checkAndRegisterCompatibilityBinding(property: DependencyProperty, bindingObjectCandidate: any)

Verifies if the given object (bindingObjectCandidate) is a binding object. If so the binding will be registered.

Parameters :
Name Type Optional
property DependencyProperty No
bindingObjectCandidate any No
Returns : boolean

{boolean} true if the value is a binding info object and if the binding was registered, false if not

ngOnInit
ngOnInit()

Angular lifecycle hook

Returns : void

Properties

items
Type : QueryList<XamTreeItemComponent>
Decorators :
@ContentChildren(XamTreeItemComponent)

List of XamTreeItemsComponent that are inside of the XamTree Component.

model
Type : XamTreeItemModel
Decorators :
@Input()

Object with properties and events for the XamTree.

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

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

pendingSetValues
Type : Array<>
Default value : []

A collection of pending values to assign to the model

treeItems
Type : any

Array of items to show in the xam-tree component. The data can be obtained from the xamTreeItems input or from the query of the content of type XamItem of the control.

Accessors

header
getheader()

Header text

Returns : any
setheader(value: any)

Gets/sets the visibility property for the XamTreeItemModel

Parameters :
Name Type Optional
value any No
Returns : void
visibility
getvisibility()
setvisibility(value: boolean)

Gets/sets the visibility property for the XamTreeItemModel

Parameters :
Name Type Optional
value boolean No
Returns : void
name
getname()

Gets name from the model

Returns : string
setname(value: string)

Sets the name model property for the control when the name is an input

Parameters :
Name Type Optional
value string No
Returns : void
import {
  Component,
  ContentChildren,
  Input,
  OnInit,
  Optional,
  QueryList,
} from '@angular/core';
import {
  DependencyProperty,
  FrameworkElement,
  ModelProxy,
  setDependencyPropertyValue,
  XamTreeItemModel,
} from '@mobilize/wms-framework';

/**
 * XamTreeItem component class
 *
 * @export
 * @class XamTreeItemComponent
 * @implements {OnInit}
 */
@Component({
  selector: 'wm-xam-tree-item',
  templateUrl: './xam-tree-item.component.html',
  styleUrls: ['./xam-tree-item.component.scss'],
})
export class XamTreeItemComponent implements OnInit {
  /**
   * Object with properties and events for the XamTree.
   *
   * @type {XamTreeItemModel}
   * @memberof XamTreeItemComponent
   */
  @Input() model: XamTreeItemModel;

  /**
   *
   * List of XamTreeItemsComponent that are inside of the XamTree Component.
   *
   * @type {QueryList<XamTreeItemComponent>} Collection of XamTreeItems
   * @memberof XamTreeComponent
   */
  @ContentChildren(XamTreeItemComponent)
  items: QueryList<XamTreeItemComponent>;

  /**
   *  A collection of pending values to assign to the model
   *
   * @protected
   * @type {Array<[DependencyProperty, any]>}
   * @memberof BaseComponent
   */
  pendingSetValues: Array<[DependencyProperty, any]> = [];

  /**
   * Array of items to show in the xam-tree component.
   * The data can be obtained from the xamTreeItems input or from the query
   * of the content of type XamItem
   * of the control.
   *
   * @type {*}
   * @memberof XamTreeItemComponent
   */
  treeItems: any;

  /**
   * Gets/sets the visibility property for the XamTreeItemModel
   *
   * @memberof XamTreeItemComponent
   */
  @Input() set header(value: any) {
    /* istanbul ignore else */
    if (
      !this.checkAndRegisterCompatibilityBinding(
        XamTreeItemModel.HeaderProperty,
        value
      )
    ) {
      this.modelProxy.Header = value;
    }
  }

  /**
   * Header text
   *
   * @readonly
   * @type {boolean}
   * @memberof XamTreeItemComponent
   */
  get header(): any {
    return this.modelProxy.Header;
  }

  /**
   * Gets/sets the visibility property for the XamTreeItemModel
   *
   * @memberof XamTreeItemComponent
   */
  @Input() set visibility(value: boolean) {
    /* istanbul ignore else */
    if (
      !this.checkAndRegisterCompatibilityBinding(
        XamTreeItemModel.VisibilityProperty,
        value
      )
    ) {
      this.modelProxy.Visibility = value;
    }
  }

  get visibility(): boolean {
    return this.modelProxy.Visibility;
  }

  /**
   * Sets the name model property for the control when the name is an input
   *
   * @memberof XamTreeItemComponent
   */
  @Input() set name(value: string) {
    this.modelProxy.Name = value;
  }

  /**
   * Gets name from the model
   *
   * @readonly
   * @type {string}
   * @memberof XamTreeItemComponent
   */
  get name(): string {
    return this.model.Name;
  }

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

  /**
   * Creates an instance of XamTreeItemComponent.
   *
   * @param {XamTreeItemModel} [injectedModel=null]
   * @memberof XamTreeItemComponent
   */
  public constructor(
    @Optional() protected injectedModel: XamTreeItemModel = null
  ) {
    this.model = injectedModel;
  }

  /**
   * Angular lifecycle hook
   *
   * @memberof XamTreeItemComponent
   */
  ngOnInit(): void {
    this.model = this.model || this.injectedModel || new XamTreeItemModel();
    ModelProxy.copy(this.modelProxy, this.model);
    this.modelProxy = this.model;
  }

  /**
   *  Verifies if the given object (bindingObjectCandidate) is a binding object.  If so the binding will be registered.
   *
   * @protected
   * @param {DependencyProperty} property
   * @param {*} bindingObjectCandidate
   * @return {*}  {boolean} true if the value is a binding info object and if the binding was registered, false if not
   * @memberof BaseComponent
   */
  /* istanbul ignore next */
  checkAndRegisterCompatibilityBinding(
    property: DependencyProperty,
    bindingObjectCandidate: any
  ): boolean {
    if (
      bindingObjectCandidate &&
      typeof bindingObjectCandidate === 'object' &&
      bindingObjectCandidate.bindingPath
    ) {
      if (
        this.modelProxy instanceof FrameworkElement &&
        this.pendingSetValues.length === 0
      ) {
        setDependencyPropertyValue(
          property,
          bindingObjectCandidate,
          this.modelProxy
        );
      } else {
        this.pendingSetValues.push([property, bindingObjectCandidate]);
      }
      return true;
    } else if (
      bindingObjectCandidate &&
      typeof bindingObjectCandidate.resourceKey === 'string'
    ) {
      this.pendingSetValues.push([property, bindingObjectCandidate]);
      return true;
    } else {
      return false;
    }
  }
}
<ng-container></ng-container>

./xam-tree-item.component.scss

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""