description ui fix finalized issue and remove save and add button

This commit is contained in:
amentis 2024-04-17 13:48:40 +03:00
parent 95e3fd859b
commit 3d8ba6ea7e
5 changed files with 20 additions and 16 deletions

View File

@ -64,7 +64,6 @@
</button>
<mat-menu #menu="matMenu">
<button [disabled]="saving" mat-menu-item (click)="saveAndClose()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CLOSE' | translate }}</button>
<button [disabled]="saving" mat-menu-item (click)="saveAndAddNew()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-ADD-NEW' | translate }}</button>
<button [disabled]="saving" mat-menu-item (click)="saveAndContinue()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CONTINUE' | translate }}</button>
</mat-menu>

View File

@ -63,6 +63,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
viewOnly = false;
lockStatus: Boolean;
descriptionIsOnceSaved = false;
isFinalized = false;
@ViewChild('table0fContents') table0fContents: TableOfContentsComponent;
step: number = 0;
@ -576,6 +577,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted) {
this.viewOnly = true;
this.isFinalized = true;
this.formGroup.disable();
}else{
this.viewOnly = false;
@ -622,7 +624,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
if (this.isNew) {
let route = [];
route.push('/descriptions/overview/' + id);
route.push('/descriptions/edit/' + id);
this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route });
} else {
this.refreshData();
@ -637,8 +639,16 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
complete => {
onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete);
this.descriptionIsOnceSaved = true;
if (this.formGroup.get('status').value == DescriptionStatus.Finalized) this.isFinalized = true;
},
error => this.onCallbackError(error)
error => {
if (this.formGroup.get('status').value == DescriptionStatus.Finalized){
this.formGroup.get('status').setValue(DescriptionStatus.Draft);
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-FINALIZE'), SnackBarNotificationLevel.Error);
}else{
this.onCallbackError(error);
}
}
);
}
@ -654,14 +664,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
saveAndClose(){
this.formSubmit((data) => {
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/descriptions']);
});
}
saveAndAddNew(){
this.formSubmit((data) => {
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
//TODO
this.backToDmp();
});
}
@ -757,7 +760,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
hasReversableStatus(): boolean {
if (this.item?.dmp) {
return (this.item.dmp.status == DmpStatus.Draft && this.formGroup.get('status').value == DescriptionStatus.Finalized);
return (this.item.dmp.status == DmpStatus.Draft && this.isFinalized);
} else {
return false;
}
@ -1091,8 +1094,9 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
};
this.descriptionService.persistStatus(dmpUserRemovePersist, DescriptionEditorResolver.lookupFields()).pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.isFinalized = false;
this.prepareForm(data);
this.onCallbackSuccess()
this.onCallbackSuccess();
}, (error: any) => {
this.onCallbackError(error)
});

View File

@ -6,7 +6,7 @@
<app-description-form-field-set-title class="row" [fieldSet]="fieldSet" [path]="path" [isChild]="isChild"></app-description-form-field-set-title>
</div>
<div class="col-auto">
<button mat-icon-button class="col-auto annotation-icon" (click)="showAnnotations(fieldSet.id)">
<button mat-icon-button class="col-auto annotation-icon" (click)="showAnnotations(fieldSet.id)" [disabled]="propertiesFormGroup.disabled">
<mat-icon matTooltip="{{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.ANNOTATIONS' | translate}}" [matBadge]="annotationsCount" [matBadgeHidden]="annotationsCount <= 0" matBadgeColor="warn">comment</mat-icon>
</button>
</div>

View File

@ -1,6 +1,6 @@
<mat-form-field class="w-100">
<mat-label>{{'DESCRIPTION-EDITOR.BASE-INFO.FIELDS.TAGS' | translate}}</mat-label>
<mat-chip-grid #chipGrid>
<mat-chip-grid #chipGrid [disabled]="form.disabled">
<mat-chip-row *ngFor="let tag of tags" (removed)="remove(tag)">
{{tag}}
<button matChipRemove>

View File

@ -20,7 +20,8 @@
"SUCCESSFUL-DELETE": "Successful Delete",
"UNSUCCESSFUL-DELETE": "Unsuccessful Delete",
"UNSUCCESSFUL-EMAIL-SEND": "Failed sending email",
"UNSUCCESSFUL-REMOVE-TEMPLATE": "Failed to remove template, one or more Descriptions of this Plan use this template"
"UNSUCCESSFUL-REMOVE-TEMPLATE": "Failed to remove template, one or more Descriptions of this Plan use this template",
"UNSUCCESSFUL-FINALIZE": "Unsuccessful Finalize"
},
"ERRORS": {
"HTTP-REQUEST-ERROR": "An Unexpected Error Has Occurred"