aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app
diff options
context:
space:
mode:
authordavsad <david.sadlier@est.tech>2021-06-08 07:17:07 +0100
committerMichael Morris <michael.morris@est.tech>2021-10-06 11:31:51 +0000
commita03a1059f8e4b8b46ab662e9a865b3ae6bb77b53 (patch)
tree13f488a090b3ec57c07ee04584aa24b9a47080c7 /catalog-ui/src/app
parent7b60bd7a745d38fd9e51630b6245c2f227abe830 (diff)
Adding type safety to the service dependency editor.
Issue-ID: SDC-3725 Signed-off-by: davsad <david.sadlier@est.tech> Change-Id: I63d77837fb0df24f5ee12baa5b852a76ce5f55e3
Diffstat (limited to 'catalog-ui/src/app')
-rw-r--r--catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html19
-rw-r--r--catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.less6
-rw-r--r--catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts47
-rw-r--r--catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.module.ts4
4 files changed, 61 insertions, 15 deletions
diff --git a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html
index 4b23568a06..f84214e4ce 100644
--- a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html
+++ b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html
@@ -24,18 +24,29 @@
<label class="i-sdc-form-label required" >Source</label>
<ui-element-dropdown class="i-sdc-form-select" data-tests-id="sourceType" [values]="sourceTypes" [(value)]="currentRule.sourceName" (change)="onSelectSourceType($event)"></ui-element-dropdown>
</div>
-
- <div class="rule-input-field assigned-value-field">
+ <div [ngClass]="isComplexListMapType() && isStaticSource() ? 'complex-input-field' : ''"
+ class="rule-input-field assigned-value-field">
<label class="i-sdc-form-label required" >{{assignedValueLabel}}</label>
+ <dynamic-property
+ *ngIf="isStaticSource() && isComplexListMapType()"
+ [selectedPropertyId]="selectedPropertyObj.uniqueId"
+ [property]="selectedPropertyObj"
+ [expandedChildId]="selectedPropertyObj.expandedChildPropertyId ?
+ selectedPropertyObj.expandedChildPropertyId : selectedPropertyObj.name"
+ [canBeDeclared]="true"
+ (propertyChanged)="updateComplexListMapTypeRuleValue()"
+ [rootProperty]="selectedPropertyObj"
+ (expandChild)="selectedPropertyObj.updateExpandedChildPropertyId($event)">
+ </dynamic-property>
<dynamic-element
- *ngIf="currentRule.sourceType === SOURCE_TYPES.STATIC.value"
+ *ngIf="isStaticSource() && !isComplexListMapType()"
[(value)]="currentRule.value"
class="rule-assigned-value"
data-tests-id="ruleAssignedValue"
(elementChanged)="onValueChange($event.isValid)"
[type]="selectedPropertyObj ? selectedPropertyObj.type : 'string'">
</dynamic-element>
- <ui-element-dropdown *ngIf="currentRule.sourceType !== SOURCE_TYPES.STATIC.value"
+ <ui-element-dropdown *ngIf="!isStaticSource()"
class="rule-assigned-value"
data-tests-id="ruleAssignedValue"
[(value)]="currentRule.value"
diff --git a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.less b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.less
index e03b73c8c0..b475ed2847 100644
--- a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.less
+++ b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.less
@@ -21,6 +21,7 @@
.rule-builder-content {
display: flex;
align-items: flex-end;
+ flex-wrap: wrap;
.rule-input-field {
flex: 1;
&:not(:last-of-type) {
@@ -38,6 +39,9 @@
height: 30px;
}
}
-
+ .complex-input-field {
+ flex-basis: 100%;
+ display: block;
+ }
}
} \ No newline at end of file
diff --git a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts
index 084ab32b5c..cb3e87c8d1 100644
--- a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts
+++ b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts
@@ -14,7 +14,7 @@
* permissions and limitations under the License.
*/
import {Component} from '@angular/core';
-import {InputBEModel, PropertyBEModel} from 'app/models';
+import {InputBEModel, PropertyBEModel, PropertyFEModel} from 'app/models';
import {
ConstraintObjectUI,
OPERATOR_TYPES
@@ -23,6 +23,7 @@ import {DropdownValue} from 'app/ng2/components/ui/form-components/dropdown/ui-e
import {ServiceServiceNg2} from 'app/ng2/services/component-services/service.service';
import {PROPERTY_DATA} from 'app/utils';
import {ServiceInstanceObject} from '../../../models/service-instance-properties-and-interfaces';
+import { PropertiesUtils } from '../properties-assignment/services/properties.utils';
export class UIDropDownSourceTypesElement extends DropdownValue {
options: any[];
@@ -61,7 +62,7 @@ export class ServiceDependenciesEditorComponent {
};
currentServiceName: string;
selectedServiceProperties: PropertyBEModel[];
- selectedPropertyObj: PropertyBEModel;
+ selectedPropertyObj: PropertyFEModel;
ddValueSelectedServicePropertiesNames: DropdownValue[];
operatorTypes: DropdownValue[];
sourceTypes: UIDropDownSourceTypesElement[] = [];
@@ -77,6 +78,8 @@ export class ServiceDependenciesEditorComponent {
SERVICE_PROPERTY: {label: 'Service Property', value: 'property'}
};
+ constructor(private propertiesUtils: PropertiesUtils) {}
+
ngOnInit() {
this.currentIndex = this.input.serviceRuleIndex;
this.serviceRulesList = this.input.serviceRules;
@@ -124,10 +127,11 @@ export class ServiceDependenciesEditorComponent {
}
syncRuleData() {
- if (!this.currentRule.sourceName && this.currentRule.sourceType === this.SOURCE_TYPES.STATIC.value) {
+ if (!this.currentRule.sourceName || this.currentRule.sourceType === this.SOURCE_TYPES.STATIC.value) {
this.currentRule.sourceName = this.SOURCE_TYPES.STATIC.value;
+ this.currentRule.sourceType = this.SOURCE_TYPES.STATIC.value;
}
- this.selectedPropertyObj = _.find(this.selectedServiceProperties, (prop) => prop.name === this.currentRule.servicePropertyName);
+ this.updateSelectedPropertyObj();
this.updateOperatorTypesList();
this.updateSourceTypesRelatedValues();
}
@@ -154,7 +158,7 @@ export class ServiceDependenciesEditorComponent {
}
}
- onChangePage(newIndex) {
+ onChangePage(newIndex:any) {
if (newIndex >= 0 && newIndex < this.input.serviceRules.length) {
this.currentIndex = newIndex;
this.currentRule = this.serviceRulesList[newIndex];
@@ -163,18 +167,18 @@ export class ServiceDependenciesEditorComponent {
}
onServicePropertyChanged() {
- this.selectedPropertyObj = _.find(this.selectedServiceProperties, (prop) => prop.name === this.currentRule.servicePropertyName);
+ this.currentRule.value = '';
+ this.updateSelectedPropertyObj();
this.updateOperatorTypesList();
this.filterOptionsByType();
- this.currentRule.value = '';
}
onSelectSourceType() {
+ this.currentRule.value = '';
this.currentRule.sourceType = this.currentRule.sourceName === this.SOURCE_TYPES.STATIC.value ?
this.SOURCE_TYPES.STATIC.value :
this.SOURCE_TYPES.SERVICE_PROPERTY.value;
this.updateSourceTypesRelatedValues();
- this.currentRule.value = '';
}
filterOptionsByType() {
@@ -190,7 +194,7 @@ export class ServiceDependenciesEditorComponent {
}, []);
}
- onValueChange(isValidValue) {
+ onValueChange(isValidValue:any) {
this.currentRule.updateValidity(isValidValue);
}
@@ -202,4 +206,29 @@ export class ServiceDependenciesEditorComponent {
// for update all rules
return this.serviceRulesList.every((rule) => rule.isValidRule(rule.sourceName === this.SOURCE_TYPES.STATIC.value));
}
+
+ updateSelectedPropertyObj(): void {
+ this.selectedPropertyObj = null;
+ if (this.currentRule.servicePropertyName) {
+ let newProp = new PropertyFEModel(_.find(this.selectedServiceProperties, (prop) => prop.name === this.currentRule.servicePropertyName));
+ newProp.value = JSON.stringify(this.currentRule.value);
+ this.propertiesUtils.initValueObjectRef(newProp);
+ console.log("TEST" + newProp.value);
+ setTimeout(() => {this.selectedPropertyObj = newProp})
+ }
+ }
+
+ isStaticSource(): boolean {
+ return this.currentRule.sourceType === this.SOURCE_TYPES.STATIC.value
+ }
+
+ isComplexListMapType(): boolean {
+ return this.selectedPropertyObj && this.selectedPropertyObj.derivedDataType > 0;
+ }
+
+ updateComplexListMapTypeRuleValue(): void {
+ let value = PropertyFEModel.cleanValueObj(this.selectedPropertyObj.valueObj);
+ this.currentRule.value = JSON.stringify(value);
+ this.onValueChange(this.selectedPropertyObj.valueObjIsValid);
+ }
}
diff --git a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.module.ts b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.module.ts
index 7b128f4468..cfa466ffa3 100644
--- a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.module.ts
+++ b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.module.ts
@@ -4,6 +4,7 @@ import { FormsModule } from '@angular/forms';
import { FormElementsModule } from 'app/ng2/components/ui/form-components/form-elements.module';
import { UiElementsModule } from 'app/ng2/components/ui/ui-elements.module';
import { ServiceDependenciesEditorComponent } from './service-dependencies-editor.component';
+import { PropertyTableModule } from 'app/ng2/components/logic/properties-table/property-table.module';
@NgModule({
declarations: [
@@ -13,7 +14,8 @@ import { ServiceDependenciesEditorComponent } from './service-dependencies-edito
CommonModule,
FormsModule,
FormElementsModule,
- UiElementsModule
+ UiElementsModule,
+ PropertyTableModule
],
exports: [],
entryComponents: [