showToscaFunction: boolean[];
types: DataTypesMap;
isService: boolean;
+ complexToscapath: string;
getValidationPattern(type: string): RegExp;
validateIntRange(value: string): boolean;
showAddBtn: '=?',
parentProperty: '=',
types: '=',
- isService: '='
+ isService: '=',
+ complexToscapath: '='
};
restrict = 'E';
const currentKey = currentKeySet[index];
const existingKeyIndex = currentKeySet.indexOf(newKey);
if (existingKeyIndex > -1 && existingKeyIndex != index) {
- scope.parentFormObj[fieldName].$setValidity('keyExist', false);
+ if (scope.parentFormObj != null) {
+ scope.parentFormObj[fieldName].$setValidity('keyExist', false);
+ }
scope.isMapKeysUnique = false;
return;
}
-
- scope.parentFormObj[fieldName].$setValidity('keyExist', true);
- scope.isMapKeysUnique = true;
- if (!scope.parentFormObj[fieldName].$invalid) {
- // To preserve the order of the keys, delete each one and recreate
- const newObj = {};
- angular.copy(scope.valueObjRef, newObj);
- angular.forEach(newObj, function(value: any, key: string) {
- delete scope.valueObjRef[key];
- if (key == currentKey) {
- scope.valueObjRef[newKey] = value;
- } else {
- scope.valueObjRef[key] = value;
- }
- });
+ if (scope.parentFormObj != null) {
+ scope.parentFormObj[fieldName].$setValidity('keyExist', true);
+ if (!scope.parentFormObj[fieldName].$invalid) {
+ // To preserve the order of the keys, delete each one and recreate
+ const newObj = {};
+ angular.copy(scope.valueObjRef, newObj);
+ angular.forEach(newObj, function(value: any, key: string) {
+ delete scope.valueObjRef[key];
+ if (key == currentKey) {
+ scope.valueObjRef[newKey] = value;
+ } else {
+ scope.valueObjRef[key] = value;
+ }
+ });
+ }
}
+ scope.isMapKeysUnique = true;
+
};
scope.deleteMapItem = (index: number): void => {
if (scope.parentProperty.subPropertyToscaFunctions != null) {
const subToscaFunctionList: SubPropertyToscaFunction[] = [];
scope.parentProperty.subPropertyToscaFunctions.forEach((SubPropertyToscaFunction, index) => {
- if (SubPropertyToscaFunction.subPropertyPath.indexOf(scope.mapKeys[flagIndex]) == -1) {
+ if (SubPropertyToscaFunction.subPropertyPath.toString() != scope.mapKeys[flagIndex]) {
subToscaFunctionList.push(SubPropertyToscaFunction);
}
});
}
};
- scope.onGetToscaFunction = (toscaGetFunction: ToscaGetFunction, key: string): void => {
+ scope.onGetToscaFunction = (toscaGetFunction: ToscaGetFunction, index:string): void => {
+ let key:string = index;
if (scope.parentProperty.subPropertyToscaFunctions != null) {
- scope.parentProperty.subPropertyToscaFunctions.forEach((SubPropertyToscaFunction) => {
- if (SubPropertyToscaFunction.subPropertyPath.indexOf(key) != -1) {
+ let toscaFlag : boolean = true;
+ scope.parentProperty.subPropertyToscaFunctions.forEach(SubPropertyToscaFunction => {
+ if (SubPropertyToscaFunction.subPropertyPath.toString() == key) {
SubPropertyToscaFunction.toscaFunction = toscaGetFunction;
+ toscaFlag = false;
return;
}
});
-
- }
- if (scope.parentProperty.subPropertyToscaFunctions == null) {
- scope.parentProperty.subPropertyToscaFunctions = [];
+ if (toscaFlag) {
+ let subPropertyToscaFunction = new SubPropertyToscaFunction();
+ subPropertyToscaFunction.toscaFunction = toscaGetFunction;
+ subPropertyToscaFunction.subPropertyPath = [key];
+ scope.parentProperty.subPropertyToscaFunctions.push(subPropertyToscaFunction);
+ }
+ } else {
+ let subPropertyToscaFunction = new SubPropertyToscaFunction();
+ subPropertyToscaFunction.toscaFunction = toscaGetFunction;
+ subPropertyToscaFunction.subPropertyPath = [key];
+ scope.parentProperty.subPropertyToscaFunctions = [subPropertyToscaFunction];
}
- const subPropertyToscaFunction = new SubPropertyToscaFunction();
- subPropertyToscaFunction.toscaFunction = toscaGetFunction;
- subPropertyToscaFunction.subPropertyPath = [key];
- scope.parentProperty.subPropertyToscaFunctions.push(subPropertyToscaFunction);
- };
+ }
scope.addMapItemFields = (): void => {
if (!scope.valueObjRef) {