description-editor> update template if obsolete and emit refresh data

This commit is contained in:
Sofia Papacharalampous 2024-04-05 11:54:11 +03:00
parent f82501344c
commit 3f69f4ebe2
3 changed files with 11 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { Component, Input } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { IsActive } from '@app/core/common/enum/is-active.enum';
@ -24,6 +24,8 @@ export class DescriptionBaseFieldsEditorComponent extends BaseComponent {
@Input() description: Description;
availableDescriptionTemplates: DescriptionTemplate[] = [];
viewOnly = false; //TODO: not used.
@Output() refresh: EventEmitter<any> = new EventEmitter<any>();
constructor(private dialog: MatDialog,
private descriptionService: DescriptionService) {
@ -67,9 +69,7 @@ export class DescriptionBaseFieldsEditorComponent extends BaseComponent {
})
.subscribe(
result => {
if (result) {
this.loadDescriptionTemplates();
}
this.refresh.emit(result);
},
error => console.error(error));
} else {

View File

@ -121,7 +121,7 @@
</div>
</div>
<div class="col-auto form" id="description-editor-form">
<app-description-base-fields-editor-component [hidden]="this.step !== 0" [formGroup]="formGroup" [description]="item" (formChanged)="formChanged()"></app-description-base-fields-editor-component>
<app-description-base-fields-editor-component [hidden]="this.step !== 0" [formGroup]="formGroup" [description]="item" (formChanged)="formChanged()" (refresh)="fireRefreshDataEvent($event)"></app-description-base-fields-editor-component>
<app-description-form
*ngIf="formGroup && formGroup.get('properties')"
[propertiesFormGroup]="formGroup.get('properties')"

View File

@ -604,6 +604,12 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
}
}
fireRefreshDataEvent(event: boolean): void {
if (event) {
this.refreshData();
}
}
refreshData(): void {
this.getItem(this.editorModel.id, (data: Description) => this.prepareForm(data));
}