summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components
diff options
context:
space:
mode:
authorsiddharth0905 <siddharth.singh4@amdocs.com>2019-04-10 17:49:51 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2019-04-11 07:11:04 +0000
commit6896c1b309aaa50dca820169b9f1ae3f8af84294 (patch)
tree8da13382863f2e4adc9724dd046b535032ae58c7 /catalog-ui/src/app/ng2/components
parent4568e48647b15b5654a669651ddf536d590288b0 (diff)
Apply Valid Value Constraints validation
Apply Valid Value Constraints validation for FE and BE in Property Assignment, Input, Service Consumption screen Change-Id: I01c7523bad702f003cd52fd88bc69fe950b2b4f3 Issue-ID: SDC-2224 Signed-off-by: siddharth0905 <siddharth.singh4@amdocs.com>
Diffstat (limited to 'catalog-ui/src/app/ng2/components')
-rw-r--r--catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html1
-rw-r--r--catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html1
-rw-r--r--catalog-ui/src/app/ng2/components/logic/service-consumption/service-consumption.component.ts2
-rw-r--r--catalog-ui/src/app/ng2/components/ui/dynamic-element/dynamic-element.component.ts28
4 files changed, 31 insertions, 1 deletions
diff --git a/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html b/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html
index 65873a35a5..3ef1f57bf2 100644
--- a/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html
+++ b/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html
@@ -57,6 +57,7 @@
pattern="validationUtils.getValidationPattern(input.type)"
[value]="input.defaultValueObj"
[type]="input.type"
+ [constraints]="input.constraints"
[name]="input.name"
(elementChanged)="onInputChanged(input, $event)"
[readonly]="readonly"
diff --git a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
index 3f87b070e8..c4639aeda0 100644
--- a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
+++ b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
@@ -51,6 +51,7 @@
[childType]="property.schema.property.type"
[name]="property.name"
[path]="property.propertiesName"
+ [constraints]="property.constraints"
(elementChanged)="onElementChanged($event)"
[readonly]="readonly || property.isDeclared || property.isDisabled"
[testId]="'prop-' + propertyTestsId"
diff --git a/catalog-ui/src/app/ng2/components/logic/service-consumption/service-consumption.component.ts b/catalog-ui/src/app/ng2/components/logic/service-consumption/service-consumption.component.ts
index b0f6dfb649..ef8d63df97 100644
--- a/catalog-ui/src/app/ng2/components/logic/service-consumption/service-consumption.component.ts
+++ b/catalog-ui/src/app/ng2/components/logic/service-consumption/service-consumption.component.ts
@@ -39,6 +39,7 @@ export class ConsumptionInput extends PropertyFEModel{
type: string;
source: string;
value: any;
+ constraints: Array<any>;
constructor(input?: any) {
super(input);
@@ -47,6 +48,7 @@ export class ConsumptionInput extends PropertyFEModel{
this.type = input.type;
this.source = input.source;
this.value = input.value || "";
+ this.constraints = input.constraints;
}
}
}
diff --git a/catalog-ui/src/app/ng2/components/ui/dynamic-element/dynamic-element.component.ts b/catalog-ui/src/app/ng2/components/ui/dynamic-element/dynamic-element.component.ts
index 4f283fb3f1..049d40831a 100644
--- a/catalog-ui/src/app/ng2/components/ui/dynamic-element/dynamic-element.component.ts
+++ b/catalog-ui/src/app/ng2/components/ui/dynamic-element/dynamic-element.component.ts
@@ -22,7 +22,7 @@
import * as _ from "lodash";
import { Component, Compiler, EventEmitter, ViewContainerRef, ViewChild, Input, Output, ElementRef, ComponentRef, ComponentFactoryResolver } from '@angular/core'
-import {ValidationConfiguration} from "app/models";
+import {ValidationConfiguration, PropertyFEModel} from "app/models";
import {IUiElementChangeEvent} from "../form-components/ui-element-base.component";
import {UiElementInputComponent} from "../form-components/input/ui-element-input.component";
import {UiElementPopoverInputComponent} from "../form-components/popover-input/ui-element-popover-input.component";
@@ -36,6 +36,7 @@ enum DynamicElementComponentCreatorIdentifier {
FLOAT,
BOOLEAN,
SUBNETPOOLID,
+ ENUM,
DEFAULT
}
@@ -58,6 +59,7 @@ export class DynamicElementComponent {
@Input() name: string;
@Input() testId: string;
@Input() readonly:boolean;
+ @Input() constraints: Array<any>;
@Input() path:string;//optional param. used only for for subnetpoolid type
@Input() value: any;
@@ -86,6 +88,9 @@ export class DynamicElementComponent {
case this.path && this.path.toUpperCase().indexOf("SUBNETPOOLID") !== -1:
this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.SUBNETPOOLID;
break;
+ case this.getValidValues() !== undefined && this.getValidValues() !== null:
+ this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.ENUM;
+ break;
case this.type === 'integer':
this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.INTEGER;
break;
@@ -153,6 +158,19 @@ export class DynamicElementComponent {
this.createComponent(UiElementPopoverInputComponent);
break;
+ case DynamicElementComponentCreatorIdentifier.ENUM:
+ this.createComponent(UiElementDropDownComponent);
+ let validVals:Array<DropdownValue> = [...this.getValidValues()].map(val => new DropdownValue(val, val));
+ if (this.type === 'float' || this.type === 'integer') {
+ this.value = this.value && Number(this.value);
+ validVals = _.map(
+ validVals,
+ val => new DropdownValue(Number(val.value), val.value)
+ );
+ }
+ this.cmpRef.instance.values = validVals;
+ break;
+
case DynamicElementComponentCreatorIdentifier.INTEGER:
this.createComponent(UiElementIntegerInputComponent);
this.cmpRef.instance.pattern = this.validation.validationPatterns.integer;
@@ -195,6 +213,14 @@ export class DynamicElementComponent {
this.cmpRef.instance.valueChange.subscribe((event) => { this.valueChange.emit(event); });
}
+ getValidValues(): Array<string> {
+ let validVals;
+ _.forEach(this.constraints, constraint => {
+ validVals = validVals || constraint.validValues;
+ });
+ return validVals;
+ }
+
createComponent(ComponentToCreate:any):void {
let factory = this.componentFactoryResolver.resolveComponentFactory(ComponentToCreate);
this.cmpRef = this.target.createComponent(factory);