Skip to content

Commit

Permalink
Merge pull request #1965 from TimaQT/features/timaqt/EMBCESSMOD-5037
Browse files Browse the repository at this point in the history
EMBCESSMOD-5037
  • Loading branch information
ytqsl authored Mar 27, 2024
2 parents 40bebd4 + db5c06a commit 3a5c7f1
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ export class AnimalsComponent implements OnInit, OnDestroy {
showTable = true;
tabUpdateSubscription: Subscription;
tabMetaData: TabModel;
@Output() ValidPetsIndicator : any = new EventEmitter();
@Output() ValidPetsIndicator: any = new EventEmitter();

constructor(
private router: Router,
private dialog: MatDialog,
private stepEssFileService: StepEssFileService,
private customValidation: CustomValidationService,
private formBuilder: UntypedFormBuilder,
private wizardService: WizardService
) {}
) { }

ngOnInit(): void {
// Creates the Animals form
Expand All @@ -54,17 +54,31 @@ export class AnimalsComponent implements OnInit, OnDestroy {
this.petSource.next(this.animalsForm.get('pets').value);
this.pets = this.animalsForm.get('pets').value;

if (this.animalsForm.get('hasPets').value === 'No' || (this.animalsForm.get('hasPets').value === 'Yes' && this.pets.length > 0)) {
this.ValidPetsIndicator.emit(true);


}
else
this.ValidPetsIndicator.emit(false);
// Set "update tab status" method, called for any tab navigation
this.tabUpdateSubscription =
this.stepEssFileService.nextTabUpdate.subscribe(() => {
this.updateTabStatus();
});
this.animalsForm.valueChanges.subscribe(() => {
if (this.animalsForm.get('hasPets').value === 'No' || (this.animalsForm.get('hasPets').value === 'Yes' && this.pets.length > 0)) {
this.ValidPetsIndicator.emit(true);
} else
this.ValidPetsIndicator.emit(false);

})

// Update Value and Validity for pets form if hasPets changes
this.animalsForm.get('hasPets').valueChanges.subscribe(() => {

this.animalsForm.get('pets').updateValueAndValidity();
this.ValidPetsIndicator.emit(this.animalsForm.valid);


});

Expand Down
Loading

0 comments on commit 3a5c7f1

Please sign in to comment.