aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts
diff options
context:
space:
mode:
authorimamSidero <imam.hussain@est.tech>2023-06-08 16:07:43 +0100
committerMichael Morris <michael.morris@est.tech>2023-07-04 14:25:27 +0000
commit0977894d34b43eba0846b23dd5bc4f186ca7edc2 (patch)
tree95233cbbc9a03d1ddf45fd418262dfce64cebd82 /catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts
parentb0b217c4ad3252c4eb24d2fc0a5508e51eee0fba (diff)
Provide tosca function capability to complex type fields in composition view
Tosca function capability is provided to all complex type fields in composition view Issue-ID: SDC-4528 Signed-off-by: Imam hussain <imam.hussain@est.tech> Change-Id: I4742c2a46ac7a9ed0fd47677aac5b4be9ad612a1
Diffstat (limited to 'catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts')
-rw-r--r--catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts72
1 files changed, 42 insertions, 30 deletions
diff --git a/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts b/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts
index 098b28936b..875a49cbd2 100644
--- a/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts
+++ b/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts
@@ -49,6 +49,7 @@ export interface ITypeMapScope extends ng.IScope {
showToscaFunction: boolean[];
types: DataTypesMap;
isService: boolean;
+ complexToscapath: string;
getValidationPattern(type: string): RegExp;
validateIntRange(value: string): boolean;
@@ -77,7 +78,8 @@ export class TypeMapDirective implements ng.IDirective {
showAddBtn: '=?',
parentProperty: '=',
types: '=',
- isService: '='
+ isService: '=',
+ complexToscapath: '='
};
restrict = 'E';
@@ -182,26 +184,30 @@ export class TypeMapDirective implements ng.IDirective {
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 => {
@@ -233,7 +239,7 @@ export class TypeMapDirective implements ng.IDirective {
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);
}
});
@@ -242,24 +248,30 @@ export class TypeMapDirective implements ng.IDirective {
}
};
- 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) {