[sdc] update to the current code base
[sdc.git] / catalog-ui / src / app / models / properties-inputs / input-fe-model.ts
1 import { SchemaPropertyGroupModel, SchemaProperty } from "../aschema-property";
2 import { PropertyBEModel } from "../../models";
3 import {PROPERTY_DATA} from "../../utils/constants";
4 import {InputBEModel} from "./input-be-model";
5
6 export class InputFEModel extends InputBEModel {
7     isSimpleType: boolean;
8     isDataType: boolean;
9     instanceName: string;
10     instanceId: string;
11     propertyName: string;
12
13
14     constructor(input?: InputBEModel) {
15         super(input);
16         if (input) {
17             this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1;
18             this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1;
19
20             let propNameIndex:number = this.name.indexOf('_');
21             this.instanceName = this.name.substring(0, propNameIndex);
22
23             if(input.properties && input.properties.length){
24                 this.instanceId = input.properties[0].componentInstanceId;
25                 this.propertyName = input.properties[0].name;
26             }else if(input.inputs && input.inputs.length){
27                 this.instanceId = input.inputs[0].componentInstanceId;
28                 this.propertyName = input.inputs[0].name;
29             }else{
30                 if (input.inputPath && input.inputPath.indexOf('#') > -1) { 
31                     this.propertyName = input.inputPath.substring(0, input.inputPath.indexOf('#'))
32                 } else {
33                     this.inputPath = undefined; //input path may be populated even if its a parent - ensure its empty
34                     this.propertyName = this.name.substring(propNameIndex + 1);
35                 }
36             }
37         }
38     }
39
40
41
42     public toJSON = (): any => {
43     };
44
45 }