1 import { SchemaPropertyGroupModel, SchemaProperty } from '../aschema-property';
2 import { DerivedPropertyType, PropertyBEModel } from '../../models';
3 import { PROPERTY_TYPES } from 'app/utils';
4 import { UUID } from "angular2-uuid";
7 export class DerivedFEProperty extends PropertyBEModel {
10 propertiesName: string; //"network_assignments#ipv4_subnet#use_ipv4 = parentPath + name
11 derivedDataType: DerivedPropertyType;
16 isChildOfListOrMap: boolean;
17 canBeDeclared: boolean;
20 constructor(property: PropertyBEModel, parentName?: string, createChildOfListOrMap?: boolean, key?:string, value?:any) {
21 if (!createChildOfListOrMap) { //creating a standard derived prop
23 this.parentName = parentName ? parentName : null;
24 this.propertiesName = (parentName) ? parentName + '#' + property.name : property.name;
25 this.canBeDeclared = true; //defaults to true
26 } else { //creating a direct child of list or map (ie. Item that can be deleted, with UUID instead of name)
28 this.isChildOfListOrMap = true;
29 this.canBeDeclared = false;
30 this.name = UUID.UUID();
31 this.parentName = parentName;
32 this.propertiesName = parentName + '#' + this.name;
35 if (property.type == PROPERTY_TYPES.LIST) {
36 this.mapKey = property.schema.property.type.split('.').pop();
37 this.type = property.schema.property.type;
39 this.mapKey = key || "";
40 this.type = property.type;
42 this.valueObj = (this.type == PROPERTY_TYPES.JSON && typeof value == 'object') ? JSON.stringify(value) : value;
43 this.schema = new SchemaPropertyGroupModel(new SchemaProperty(property.schema.property));
45 this.derivedDataType = this.getDerivedPropertyType();
49 export class DerivedFEPropertyMap {
50 [parentPath: string]: Array<DerivedFEProperty>;