projects/i-components/src/lib/components/xam-tree-item/xam-tree-item.component.ts
XamTreeItem component class
selector | wm-xam-tree-item |
styleUrls | ./xam-tree-item.component.scss |
templateUrl | ./xam-tree-item.component.html |
Properties |
|
Methods |
Inputs |
Accessors |
Public
constructor(injectedModel: XamTreeItemModel)
|
||||||
Creates an instance of XamTreeItemComponent.
Parameters :
|
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 |
checkAndRegisterCompatibilityBinding | |||||||||
checkAndRegisterCompatibilityBinding(property: DependencyProperty, bindingObjectCandidate: any)
|
|||||||||
Verifies if the given object (bindingObjectCandidate) is a binding object. If so the binding will be registered.
Parameters :
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
|
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. |
header | ||||||
getheader()
|
||||||
Header text
Returns :
any
|
||||||
setheader(value: any)
|
||||||
Gets/sets the visibility property for the XamTreeItemModel
Parameters :
Returns :
void
|
visibility | ||||||
getvisibility()
|
||||||
setvisibility(value: boolean)
|
||||||
Gets/sets the visibility property for the XamTreeItemModel
Parameters :
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 :
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