summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2022-12-02 15:34:23 +0000
committerMichael Morris <michael.morris@est.tech>2022-12-06 09:46:44 +0000
commit6f7618074a0b5c2760c7eb2b29e88acab0c00c9a (patch)
tree1d8109489b4f70c23ebe16aa01ff07270123b276 /catalog-ui/src
parent64e74fe385d262fe91fe97828f9834f79a10dfd2 (diff)
Fix constraint not displayed when cycling through properties
Issue-ID: SDC-4286 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: I8346fe8bd001adf89516c5d5ea886c11b4283b4d
Diffstat (limited to 'catalog-ui/src')
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/constraints/constraints.component.ts44
1 files changed, 23 insertions, 21 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/constraints/constraints.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/constraints/constraints.component.ts
index 831732dcf5..1e0eb4f2aa 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/constraints/constraints.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/constraints/constraints.component.ts
@@ -27,23 +27,8 @@ import { PROPERTY_DATA, PROPERTY_TYPES } from "app/utils/constants"
})
export class ConstraintsComponent implements OnInit {
- @Input() set propertyConstraints(propertyConstraints: any[]) {
- this.constraints = new Array();
- if(propertyConstraints) {
- propertyConstraints.forEach((constraint: any) => {
- this.constraints.push(this.getConstraintFromPropertyBEModel(constraint));
- });
- }
- }
- @Input() set propertyType(propertyType: string) {
- if (!this._propertyType || propertyType == this._propertyType) {
- this._propertyType = propertyType;
- return;
- }
- this.constraints = new Array();
- this._propertyType = propertyType;
- this.emitOnConstraintChange();
- }
+ @Input() propertyConstraints: any[];
+ @Input() propertyType: string;
@Input() isViewOnly: boolean = false;
@Output() onConstraintChange: EventEmitter<any> = new EventEmitter<any>();
@@ -51,12 +36,29 @@ export class ConstraintsComponent implements OnInit {
constraintTypes: string[];
ConstraintTypesMapping = ConstraintTypesMapping;
valid: boolean = true;
- _propertyType: string;
ngOnInit() {
this.constraintTypes = Object.keys(ConstraintTypes).map(key => ConstraintTypes[key]);
}
+ ngOnChanges(changes): void {
+ if (changes.propertyType) {
+ if (!this.propertyType || changes.propertyType.currentValue == this.propertyType) {
+ this.propertyType = changes.propertyType.currentValue;
+ } else {
+ this.constraints = new Array();
+ this.propertyType = changes.propertyType;
+ this.emitOnConstraintChange();
+ }
+ }
+ this.constraints = new Array();
+ if(changes.propertyConstraints.currentValue) {
+ changes.propertyConstraints.currentValue.forEach((constraint: any) => {
+ this.constraints.push(this.getConstraintFromPropertyBEModel(constraint));
+ });
+ }
+ }
+
private getConstraintFromPropertyBEModel(constraint: any):Constraint {
let constraintType: ConstraintTypes;
let constraintValue: any;
@@ -265,19 +267,19 @@ export class ConstraintsComponent implements OnInit {
case ConstraintTypes.greater_or_equal:
case ConstraintTypes.greater_than:
case ConstraintTypes.in_range:
- if (this.isComparable(this._propertyType)){
+ if (this.isComparable(this.propertyType)){
return false;
}
break;
case ConstraintTypes.length:
case ConstraintTypes.max_length:
case ConstraintTypes.min_length:
- if (this._propertyType == PROPERTY_TYPES.STRING || this._propertyType == PROPERTY_TYPES.MAP || this._propertyType == PROPERTY_TYPES.LIST){
+ if (this.propertyType == PROPERTY_TYPES.STRING || this.propertyType == PROPERTY_TYPES.MAP || this.propertyType == PROPERTY_TYPES.LIST){
return false;
}
break;
case ConstraintTypes.pattern:
- if (this._propertyType == PROPERTY_TYPES.STRING){
+ if (this.propertyType == PROPERTY_TYPES.STRING){
return false;
}
break;