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;
15 isChildOfListOrMap: boolean;
16 canBeDeclared: boolean;
19 constructor(property: PropertyBEModel, parentName?: string, createChildOfListOrMap?: boolean, key?:string, value?:any) {
20 if (!createChildOfListOrMap) { //creating a standard derived prop
22 this.parentName = parentName ? parentName : null;
23 this.propertiesName = (parentName) ? parentName + '#' + property.name : property.name;
24 this.canBeDeclared = true; //defaults to true
25 } else { //creating a direct child of list or map (ie. Item that can be deleted, with UUID instead of name)
27 this.isChildOfListOrMap = true;
28 this.canBeDeclared = false;
29 this.name = UUID.UUID();
30 this.parentName = parentName;
31 this.propertiesName = parentName + '#' + this.name;
34 if (property.type == PROPERTY_TYPES.LIST) {
35 this.mapKey = property.schema.property.type.split('.').pop();
36 this.type = property.schema.property.type;
38 this.mapKey = key || "";
39 this.type = property.type;
41 this.valueObj = (this.type == PROPERTY_TYPES.JSON && typeof value == 'object') ? JSON.stringify(value) : value;
42 this.schema = new SchemaPropertyGroupModel(new SchemaProperty(property.schema.property));
44 this.derivedDataType = this.getDerivedPropertyType();
48 export class DerivedFEPropertyMap {
49 [parentPath: string]: Array<DerivedFEProperty>;