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> </button>
<mat-menu #menu="matMenu"> <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)="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> <button [disabled]="saving" mat-menu-item (click)="saveAndContinue()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CONTINUE' | translate }}</button>
</mat-menu> </mat-menu>

View File

@ -63,6 +63,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
viewOnly = false; viewOnly = false;
lockStatus: Boolean; lockStatus: Boolean;
descriptionIsOnceSaved = false; descriptionIsOnceSaved = false;
isFinalized = false;
@ViewChild('table0fContents') table0fContents: TableOfContentsComponent; @ViewChild('table0fContents') table0fContents: TableOfContentsComponent;
step: number = 0; step: number = 0;
@ -576,6 +577,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel); this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted) { if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted) {
this.viewOnly = true; this.viewOnly = true;
this.isFinalized = true;
this.formGroup.disable(); this.formGroup.disable();
}else{ }else{
this.viewOnly = false; this.viewOnly = false;
@ -622,7 +624,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
if (this.isNew) { if (this.isNew) {
let route = []; 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 }); this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route });
} else { } else {
this.refreshData(); this.refreshData();
@ -637,8 +639,16 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
complete => { complete => {
onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete); onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete);
this.descriptionIsOnceSaved = true; 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(){ saveAndClose(){
this.formSubmit((data) => { 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.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']); this.backToDmp();
});
}
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
}); });
} }
@ -757,7 +760,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
hasReversableStatus(): boolean { hasReversableStatus(): boolean {
if (this.item?.dmp) { 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 { } else {
return false; return false;
} }
@ -1091,8 +1094,9 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
}; };
this.descriptionService.persistStatus(dmpUserRemovePersist, DescriptionEditorResolver.lookupFields()).pipe(takeUntil(this._destroyed)) this.descriptionService.persistStatus(dmpUserRemovePersist, DescriptionEditorResolver.lookupFields()).pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.isFinalized = false;
this.prepareForm(data); this.prepareForm(data);
this.onCallbackSuccess() this.onCallbackSuccess();
}, (error: any) => { }, (error: any) => {
this.onCallbackError(error) 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> <app-description-form-field-set-title class="row" [fieldSet]="fieldSet" [path]="path" [isChild]="isChild"></app-description-form-field-set-title>
</div> </div>
<div class="col-auto"> <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> <mat-icon matTooltip="{{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.ANNOTATIONS' | translate}}" [matBadge]="annotationsCount" [matBadgeHidden]="annotationsCount <= 0" matBadgeColor="warn">comment</mat-icon>
</button> </button>
</div> </div>

View File

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

View File

@ -20,7 +20,8 @@
"SUCCESSFUL-DELETE": "Successful Delete", "SUCCESSFUL-DELETE": "Successful Delete",
"UNSUCCESSFUL-DELETE": "Unsuccessful Delete", "UNSUCCESSFUL-DELETE": "Unsuccessful Delete",
"UNSUCCESSFUL-EMAIL-SEND": "Failed sending email", "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": { "ERRORS": {
"HTTP-REQUEST-ERROR": "An Unexpected Error Has Occurred" "HTTP-REQUEST-ERROR": "An Unexpected Error Has Occurred"