From bb7637bca2b36eb74c795e555cb24569b989883d Mon Sep 17 00:00:00 2001 From: Julian Brott Date: Thu, 21 Mar 2024 11:47:21 +0100 Subject: [PATCH] Fix predicate form patch on refinement --- src/app/core/services/validation.service.ts | 4 +-- .../predicate-edit-dynamic.component.ts | 33 ++++++++++--------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/app/core/services/validation.service.ts b/src/app/core/services/validation.service.ts index a13d930..b28cdae 100644 --- a/src/app/core/services/validation.service.ts +++ b/src/app/core/services/validation.service.ts @@ -31,7 +31,7 @@ export class ValidationService { const request = JSON.stringify({ "behavior_description": "description", "specification": predicate.predicateSpecification, - "specification_type": "mtl", + "specification_type": "tbv", "predicates_info": [ predicate.predicateInfo ], @@ -80,7 +80,7 @@ export class ValidationService { const request = JSON.stringify({ "behavior_description": "description", "specification": predicateSpecification, - "specification_type": "mtl", + "specification_type": "tbv", "predicates_info": [ predicateFormatted ], diff --git a/src/app/modules/requirement-optimizer/components/predicate-edit-dynamic/predicate-edit-dynamic.component.ts b/src/app/modules/requirement-optimizer/components/predicate-edit-dynamic/predicate-edit-dynamic.component.ts index 0b652cb..e9f9239 100644 --- a/src/app/modules/requirement-optimizer/components/predicate-edit-dynamic/predicate-edit-dynamic.component.ts +++ b/src/app/modules/requirement-optimizer/components/predicate-edit-dynamic/predicate-edit-dynamic.component.ts @@ -57,23 +57,25 @@ export class PredicateEditDynamicComponent implements OnInit { this.predicateForm.valueChanges .pipe(debounceTime(400)) .subscribe(res => { - if (this.predicates) { - - /* const i = this.getPredicateIndex(this.predicates, this.predicateForm.value.predicate_name); - this.predicates[i] = this.predicateForm.value; - this.validatePredicate(); - this.predicatesChange.emit(this.predicateForm.value); */ - - const i = this.getPredicateIndex(this.predicates, this.pspElement?.predicateName!); - if (i === -1) return; - this.predicates[i] = this.predicateForm.value; - this.validatePredicate(); - console.log('EMIT', this.predicates) - this.predicatesChange.emit(this.predicates); - } + this.updatePredicate(); }); } + updatePredicate() { + if (this.predicates) { + /* const i = this.getPredicateIndex(this.predicates, this.predicateForm.value.predicate_name); + this.predicates[i] = this.predicateForm.value; + this.validatePredicate(); + this.predicatesChange.emit(this.predicateForm.value); */ + const i = this.getPredicateIndex(this.predicates, this.pspElement?.predicateName!); + if (i === -1) return; + this.predicates[i] = this.predicateForm.value; + this.validatePredicate(); + console.log('EMIT', this.predicates) + this.predicatesChange.emit(this.predicates); + } + } + initForm() { const predicate = this.getPredicate(this.pspElement?.predicateName); if (predicate) { @@ -137,7 +139,8 @@ export class PredicateEditDynamicComponent implements OnInit { dialogRef.afterClosed().subscribe((comparisonValue: number | null) => { if (typeof comparisonValue === 'number' && comparisonValue !== null) { - this.predicateForm.patchValue({ fComparisonValue: comparisonValue }); + this.predicateForm.patchValue({ predicate_comparison_value: comparisonValue }); + this.updatePredicate(); } }); }