fixed description discard changes

This commit is contained in:
Sofia Papacharalampous 2024-06-11 13:37:21 +03:00
parent 6899bf7c26
commit fe34afec05
2 changed files with 20 additions and 7 deletions

View File

@ -368,7 +368,8 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
setTimeout(x => {
this.ngOnInit();
if (this.isNew) this._resetFields();
else this.refreshOnNavigateToData(this.editorModel?.id);
});
}
});
@ -755,4 +756,11 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
}
});
}
private _resetFields(): void {
this.formGroup.get('label').reset();
this.formGroup.get('description').reset();
this.formGroup.get('tags').reset();
this.formGroup.get('properties').reset();
}
}

View File

@ -1,5 +1,5 @@
import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { Component, ElementRef, Input, OnInit, SimpleChanges, ViewChild } from '@angular/core';
import { Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core';
import { FormControl, UntypedFormBuilder, UntypedFormControl } from '@angular/forms';
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
import { MatChipInputEvent } from '@angular/material/chips';
@ -8,14 +8,14 @@ import { TagService } from '@app/core/services/tag/tag.service';
import { BaseComponent } from '@common/base/base.component';
import { QueryResult } from '@common/model/query-result';
import { Observable } from 'rxjs';
import { map, mergeMap, startWith } from 'rxjs/operators';
import { map, mergeMap, startWith, takeUntil } from 'rxjs/operators';
@Component({
selector: 'app-tags-field-component',
templateUrl: 'tags-field.component.html',
styleUrls: ['./tags-field.component.scss']
})
export class TagsComponent extends BaseComponent implements OnInit {
export class TagsComponent extends BaseComponent implements OnInit, OnChanges {
@Input() form: UntypedFormControl = null;
@Input() label: string;
@ -34,12 +34,17 @@ export class TagsComponent extends BaseComponent implements OnInit {
) {
super();
}
ngOnChanges(changes: SimpleChanges) {
if(changes['form']) this.applyTags();
}
ngOnInit(): void {
this.applyTags();
this.form?.valueChanges.pipe(takeUntil(this._destroyed)).subscribe( _ => {
this.applyTags()
})
}
ngOnChanges(changes: SimpleChanges) {
if(changes['form']) this.applyTags();
}
applyTags(){