Skip to content

Commit

Permalink
Merge pull request #22 from Cambio-Project/fix-initial-verification
Browse files Browse the repository at this point in the history
Fix predicate evaluation not working initially
  • Loading branch information
franksn90 authored Sep 4, 2024
2 parents 1348b87 + c1e90ce commit 54fce6e
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
import {AfterContentInit, Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { LOGIC_OPERATOR_OPTIONS, requiresComparisonValue } from 'src/app/shared/enums/logic-operator';
import { Dataset } from 'src/app/shared/models/dataset';
Expand All @@ -14,7 +14,7 @@ import { PredicateRefinementDynamicComponent } from '../predicate-refinement-dyn
templateUrl: './predicate-edit-dynamic.component.html',
styleUrls: ['./predicate-edit-dynamic.component.scss']
})
export class PredicateEditDynamicComponent implements OnInit {
export class PredicateEditDynamicComponent implements OnInit, AfterContentInit {

@Input() dataset: Dataset | null = null;
@Input() psp?: PSP;
Expand Down Expand Up @@ -45,8 +45,11 @@ export class PredicateEditDynamicComponent implements OnInit {
private validationSvc: ValidationService,
) { }

ngAfterContentInit(): void {
this.initForm();
}

ngOnInit(): void {
this.initForm();

this.logicOperator.valueChanges
.pipe(debounceTime(400))
Expand Down Expand Up @@ -79,7 +82,7 @@ export class PredicateEditDynamicComponent implements OnInit {
initForm() {
const predicate = this.getPredicate(this.pspElement?.predicateName);
if (predicate) {
this.predicateForm.patchValue(predicate);
this.predicateForm.patchValue(predicate);
this.validatePredicate();
}
}
Expand Down Expand Up @@ -115,8 +118,8 @@ export class PredicateEditDynamicComponent implements OnInit {
}

validatePredicate() {
if (this.dataset && this.predicateForm.valid) {
const predicateSpecification = this.pspElement?.specification!;
if (this.dataset && this.predicateForm.valid) {
const predicateSpecification = this.pspElement?.specification!;
const predicate = this.predicateForm.value;
this.validationSvc.validatePredicateDynamic(this.dataset, predicateSpecification, predicate).then(validationResponse => this.validationResponse = validationResponse);
//this.eventChange.emit(this.event);
Expand Down

0 comments on commit 54fce6e

Please sign in to comment.