src/services/tabService/factoryNodes/factory-nodes.ts
Properties |
|
Methods |
constructor()
|
create | ||||||
create(componentInstance: any)
|
||||||
Parameters :
Returns :
any
|
getType | ||||||||
getType(componentInstance: any)
|
||||||||
Returns an specific type of Node
Parameters :
Returns :
string
|
register | ||||||||||||
register(name: TabNodeTypes, nodeType: ITabNode)
|
||||||||||||
Regist nodetypes in to the dictionary
Parameters :
Returns :
void
|
Private nodesTypes |
Type : IDictionary
|
Default value : new Dictionary()
|
import { Injectable } from '@angular/core';
import { IDictionary, Dictionary } from '@mobilize/webmap-core';
import { TabNodeTypes } from '../nodes/tabNodeTypes';
import { ITabNode } from '../tabContracts/iTabNode';
import { IFactoryNode } from '../tabContracts/iFactoryNode';
import { ComponentTypeName } from '../../../components/base/base-component/componentTypeName';
@Injectable({
providedIn: 'root'
})
export class FactoryNodes implements IFactoryNode {
constructor() {}
private nodesTypes: IDictionary = new Dictionary();
create(componentInstance: any): any {
// We need to define a variable in order to define node type
const nodeInstance = this.nodesTypes.value(this.getType(componentInstance));
if (!nodeInstance) {
return null;
}
return new nodeInstance(componentInstance);
}
/**
* Regist nodetypes in to the dictionary
* @param name name type node
* @param nodeType tabNode component
*/
register(name: TabNodeTypes, nodeType: ITabNode): void {
this.nodesTypes.add(name as string, nodeType);
}
/**
* Returns an specific type of Node
* @param componentInstance reference of component instance
*/
getType(componentInstance: any): string {
if (
componentInstance.componentName === ComponentTypeName.DataManagerControl
) {
return TabNodeTypes.dmNode;
}
// if component instance is not a defined type and is not a column return default NodeType
if (componentInstance.tabPageOrderServiceInstance) {
return TabNodeTypes.tabPageNode;
}
return !componentInstance.dataManagerEmitter ? TabNodeTypes.tabNode : null;
}
}