aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/directives/property-types/type-map
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2023-06-23 17:26:51 +0000
committerMichaelMorris <michael.morris@est.tech>2023-06-23 18:39:31 +0100
commit86dc4e7f69e6a05277e123391649fa3f4f7b83a5 (patch)
tree6f3944bbcc2539f377f78262240a4947080ac87d /catalog-ui/src/app/directives/property-types/type-map
parentfc3869ca4c430cc29e46bb42125f5672230b83f0 (diff)
Revert "Provide tosca function capability to complex type fields in composition view"
This reverts commit fc3869ca4c430cc29e46bb42125f5672230b83f0. Reason for revert: Looks to be causing an issue with setting node filter using custom tosca function (save button disbaled) Change-Id: I684aae7a23d30ed5a20aa4630cd658997b4628a5 Issue-ID: SDC-4528 Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'catalog-ui/src/app/directives/property-types/type-map')
-rw-r--r--catalog-ui/src/app/directives/property-types/type-map/type-map-directive.html4
-rw-r--r--catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts72
2 files changed, 32 insertions, 44 deletions
diff --git a/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.html b/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.html
index fad6838d01..f53f5cf205 100644
--- a/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.html
+++ b/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.html
@@ -41,7 +41,7 @@
</div>
<div data-ng-if="!isSchemaTypeDataType" class="i-sdc-form-item map-item-field" data-ng-class="{error:(parentFormObj['mapValue'+fieldsPrefixName+$index].$dirty && parentFormObj['mapValue'+fieldsPrefixName+$index].$invalid)}">
<label class="i-sdc-form-label required">Value</label>
- <form class="temp-form" data-ng-if="isService && complexToscapath == null">
+ <form class="temp-form" data-ng-if="isService">
<input type="radio" name="hasToscaFunction-{{fieldsPrefixName}}-{{$index}}" data-ng-checked="{{showToscaFunction[$index] == false}}" data-ng-click="onEnableTosca(false,$index)"/>
Value
<input type="radio" name="hasToscaFunction-{{fieldsPrefixName}}-{{$index}}" data-ng-checked="{{showToscaFunction[$index]}}" data-ng-click="onEnableTosca(true,$index)" ng-disabled="mapKeys[$index] == '' || mapKeys[$index] == null"/>
@@ -120,7 +120,7 @@
</div>
<div class="add-map-item" data-ng-class="{'schema-data-type':isSchemaTypeDataType}" data-ng-if="showAddBtn">
<div class="add-btn" data-tests-id="add-map-item"
- data-ng-class="{'disabled': readOnly || !isMapKeysUnique}"
+ data-ng-class="{'disabled': readOnly || !schemaProperty.type || mapKeys.indexOf('')>-1 || !isMapKeysUnique}"
data-ng-click="addMapItemFields()" title="{{'PROPERTY_EDIT_MAP_ADD_ITEM' | translate}}">Add</div>
</div>
</div>
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 875a49cbd2..098b28936b 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,7 +49,6 @@ export interface ITypeMapScope extends ng.IScope {
showToscaFunction: boolean[];
types: DataTypesMap;
isService: boolean;
- complexToscapath: string;
getValidationPattern(type: string): RegExp;
validateIntRange(value: string): boolean;
@@ -78,8 +77,7 @@ export class TypeMapDirective implements ng.IDirective {
showAddBtn: '=?',
parentProperty: '=',
types: '=',
- isService: '=',
- complexToscapath: '='
+ isService: '='
};
restrict = 'E';
@@ -184,30 +182,26 @@ export class TypeMapDirective implements ng.IDirective {
const currentKey = currentKeySet[index];
const existingKeyIndex = currentKeySet.indexOf(newKey);
if (existingKeyIndex > -1 && existingKeyIndex != index) {
- if (scope.parentFormObj != null) {
- scope.parentFormObj[fieldName].$setValidity('keyExist', false);
- }
+ scope.parentFormObj[fieldName].$setValidity('keyExist', false);
scope.isMapKeysUnique = false;
return;
}
- 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.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;
+ }
+ });
+ }
};
scope.deleteMapItem = (index: number): void => {
@@ -239,7 +233,7 @@ export class TypeMapDirective implements ng.IDirective {
if (scope.parentProperty.subPropertyToscaFunctions != null) {
const subToscaFunctionList: SubPropertyToscaFunction[] = [];
scope.parentProperty.subPropertyToscaFunctions.forEach((SubPropertyToscaFunction, index) => {
- if (SubPropertyToscaFunction.subPropertyPath.toString() != scope.mapKeys[flagIndex]) {
+ if (SubPropertyToscaFunction.subPropertyPath.indexOf(scope.mapKeys[flagIndex]) == -1) {
subToscaFunctionList.push(SubPropertyToscaFunction);
}
});
@@ -248,30 +242,24 @@ export class TypeMapDirective implements ng.IDirective {
}
};
- scope.onGetToscaFunction = (toscaGetFunction: ToscaGetFunction, index:string): void => {
- let key:string = index;
+ scope.onGetToscaFunction = (toscaGetFunction: ToscaGetFunction, key: string): void => {
if (scope.parentProperty.subPropertyToscaFunctions != null) {
- let toscaFlag : boolean = true;
- scope.parentProperty.subPropertyToscaFunctions.forEach(SubPropertyToscaFunction => {
- if (SubPropertyToscaFunction.subPropertyPath.toString() == key) {
+ scope.parentProperty.subPropertyToscaFunctions.forEach((SubPropertyToscaFunction) => {
+ if (SubPropertyToscaFunction.subPropertyPath.indexOf(key) != -1) {
SubPropertyToscaFunction.toscaFunction = toscaGetFunction;
- toscaFlag = false;
return;
}
});
- 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];
+
}
- }
+ if (scope.parentProperty.subPropertyToscaFunctions == null) {
+ scope.parentProperty.subPropertyToscaFunctions = [];
+ }
+ const subPropertyToscaFunction = new SubPropertyToscaFunction();
+ subPropertyToscaFunction.toscaFunction = toscaGetFunction;
+ subPropertyToscaFunction.subPropertyPath = [key];
+ scope.parentProperty.subPropertyToscaFunctions.push(subPropertyToscaFunction);
+ };
scope.addMapItemFields = (): void => {
if (!scope.valueObjRef) {