fixed tag-field reset on discard

This commit is contained in:
Sofia Papacharalampous 2024-06-17 11:06:30 +03:00
parent d95a672d6f
commit e46dce9645
2 changed files with 9 additions and 7 deletions

View File

@ -764,6 +764,8 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.formGroup.get('description').reset();
this.formGroup.get('tags').reset();
this.formGroup.get('properties').reset();
this.formService.removeAllBackEndErrors(this.formGroup);
this.formService.validateAllFormFields(this.formGroup);
this.descriptionFormService.detectChanges(true);
}
}

View File

@ -1,6 +1,6 @@
import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core';
import { FormControl, UntypedFormBuilder, UntypedFormControl } from '@angular/forms';
import { FormControl, UntypedFormControl } from '@angular/forms';
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
import { MatChipInputEvent } from '@angular/material/chips';
import { Tag } from '@app/core/model/tag/tag';
@ -30,21 +30,21 @@ export class TagsComponent extends BaseComponent implements OnInit, OnChanges {
tagsCtrl = new FormControl();
constructor(
private tagService: TagService
private tagService: TagService,
) {
super();
}
ngOnInit(): void {
this.applyTags();
this.form?.valueChanges.pipe(takeUntil(this._destroyed)).subscribe( _ => {
this.applyTags()
})
}
ngOnChanges(changes: SimpleChanges) {
if(changes['form']) this.applyTags();
if(changes['form']) {
this.form?.valueChanges.pipe(takeUntil(this._destroyed)).subscribe( _ => this.applyTags());
this.applyTags();
}
}
applyTags(){