discard description ui fix

This commit is contained in:
amentis 2024-06-18 17:55:37 +03:00
parent 3b426db49c
commit 3efd945f8f
2 changed files with 6 additions and 1 deletions

View File

@ -44,7 +44,7 @@
<mat-divider *ngIf="formGroup.get('id').value && (!viewOnly || (!isLocked && !viewOnly) || isLocked || (hasReversableStatus() && !isLocked))" [vertical]="true" class="ml-2 mr-2"></mat-divider>
<div *ngIf="isDirty() && !viewOnly" class="col-auto d-flex align-items-center pr-0">
<div *ngIf="!isPristine() && !viewOnly" class="col-auto d-flex align-items-center pr-0">
<button [disabled]="saving" type="button" mat-raised-button class="description-discard-btn" (click)="discardChanges()">
{{'DESCRIPTION-EDITOR.ACTIONS.DISCARD.DISCARD' | translate}}
</button>

View File

@ -533,6 +533,10 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
return this.formGroup.dirty; //TODO: check if needed //&& this.hasChanges; // do we need this.formGroup.dirty
}
isPristine() {
return this.formGroup.pristine; //use for discard
}
hasReversableStatus(): boolean {
if (this.item?.dmp) {
return (this.item.dmp.status == DmpStatus.Draft && this.isFinalized);
@ -768,5 +772,6 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.formService.removeAllBackEndErrors(this.formGroup);
this.formService.validateAllFormFields(this.formGroup);
this.descriptionFormService.detectChanges(true);
this.formGroup.markAsPristine();
}
}