Make DMP Editor more safe when saving and make save pop messages more consistent

This commit is contained in:
George Kalampokis 2022-04-01 18:13:50 +03:00
parent a9199ab8f0
commit ae7988aa13
7 changed files with 27 additions and 19 deletions

View File

@ -179,7 +179,6 @@
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.save-btn {
@ -194,7 +193,6 @@
align-items: center;
font-weight: 700;
color: #129d99;
cursor: pointer;
}
.dataset-discard-btn {
@ -208,7 +206,6 @@
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.dataset-save-btn {
@ -221,7 +218,6 @@
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.dataset-to-dmp {

View File

@ -943,6 +943,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
}
this.uiNotificationService.snackBarNotification(feedbackMessage, SnackBarNotificationLevel.Warning);
this.setErrorModel(error.error);
this.saving = false;
}
public setErrorModel(validationErrorModel: ValidationErrorModel) {

View File

@ -11,14 +11,14 @@
<div class="subtitle">{{ formGroup.get('label').value }} <span *ngIf="isDirty()" class="changes">({{'DMP-EDITOR.CHANGES' | translate}})</span></div>
</div>
<div class="ml-auto d-flex flex-row">
<button *ngIf="isDirty()" type="button" mat-raised-button class="discard-btn mr-3" (click)="discardChanges()">
<button [disabled]="saving" *ngIf="isDirty()" type="button" mat-raised-button class="discard-btn mr-3" (click)="discardChanges()">
{{'DMP-EDITOR.ACTIONS.DISCARD' | translate}}
</button>
<div *ngIf="isNew" mat-raised-button type="button" (click)="save()" class="save-btn">
<div>{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}</div>
</div>
<button [disabled]="saving" *ngIf="isNew" mat-raised-button type="button" (click)="save()" class="save-btn">
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}
</button>
<div *ngIf="!isNew && formGroup.enabled && !lockStatus">
<button *ngIf="!isFinalized" mat-raised-button (click)="formSubmit()" class="save-btn">
<button [disabled]="saving" *ngIf="!isFinalized" mat-raised-button (click)="formSubmit()" class="save-btn">
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}
</button>
</div>
@ -73,10 +73,10 @@
<div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div>
</div>
<!-- <div *ngIf="this.step >= 3 && hasProfile() && !isFinalized" mat-raised-button type="button" class="col-auto stepper-btn add-dataset-btn ml-auto" (click)="addDataset()" target="_blank"> -->
<div *ngIf="this.step >= 3 && !isFinalized" mat-raised-button type="button" class="col-auto stepper-btn add-dataset-btn ml-auto" (click)="addDataset()" target="_blank">
<button [disabled]="saving" *ngIf="this.step >= 3 && !isFinalized" mat-raised-button type="button" class="col-auto stepper-btn add-dataset-btn ml-auto" (click)="addDataset()" target="_blank">
<!-- <mat-icon>add</mat-icon> -->
<div>{{'DMP-EDITOR.ACTIONS.SAVE' | translate}} & {{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</div>
</div>
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}} & {{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}
</button>
</div>
<div class="col-auto pr-0">
<app-form-progress-indication class="col-12" *ngIf="formGroup && !formGroup.disabled && !lockStatus" [formGroup]="formGroup" [isDmpEditor]="true"></app-form-progress-indication>

View File

@ -155,7 +155,6 @@ a:hover {
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.save-btn {
@ -169,7 +168,6 @@ a:hover {
align-items: center;
font-weight: 700;
color: #129d99;
cursor: pointer;
}
.dataset-discard-btn {
@ -346,11 +344,14 @@ mat-icon.size-16 {
}
.add-dataset-btn {
color: #212121;
background: #f7dd72 0% 0% no-repeat padding-box;
box-shadow: 0px 3px 6px #1e202029;
font-weight: 500;
cursor: pointer;
white-space: normal;
word-wrap: break-word;
line-height: normal;
text-align: left;
font-size: 13.8px;
}
.add-dataset-action {

View File

@ -61,6 +61,7 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
editMode = true;
// editMode = false;
saving = false;
breadCrumbs: Observable<BreadcrumbItem[]>;
isNew = true;
@ -416,6 +417,7 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
// }
formSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void {
this.saving = true;
this.formService.touchAllFormFields(this.formGroup);
// if (this.isNewDataset) {
// if (!this.isDatasetFormValid) {
@ -440,6 +442,7 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
const errmess = this._buildDMPDescriptionErrorMessages();
this.showValidationErrorsDialog(undefined, errmess);
this.hintErrors = true;
this.saving = false;
return;
}
this.onSubmit(addNew, showAddDatasetDialog);
@ -554,7 +557,8 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
setTimeout(() => { this.formGroup = null; });
setTimeout(() => { this.formGroup = dmpEditorModel.buildForm(); });
setTimeout(() => { document.getElementById('editor-form').scrollTop = this.scrollTop; });
this.saving = false;
this.isNew = false;
} else {
this.router.navigate(['/reload']).then(() => { this.router.navigate(['/plans']); });
}
@ -570,12 +574,14 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
onCallbackError(error: any) {
this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error);
this.setErrorModel(error.error);
this.saving = false;
//this.validateAllFormFields(this.formGroup);
}
onCallbackSuccessAddNew(dmp?: DmpModel) {
// this.editDataset(dmp.id, true, this.isNew && !this.formGroup.get('datasets').value.length);
this.editDataset(dmp.id, true, false);
this.saving = false;
}
public setErrorModel(validationErrorModel: ValidationErrorModel) {
@ -883,12 +889,13 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
addDataset() {
this.saving = true;
if(!this._isDMPDescriptionValid()){
const errmess = this._buildDMPDescriptionErrorMessages();
this.showValidationErrorsDialog(undefined, errmess);
this.hintErrors = true;
this.saving = false;
return;
}

View File

@ -14,7 +14,7 @@
<app-dmp-wizard-dataset-listing-component [formGroup]="formGroup" [dmpId]="formGroup.get('id').value" *ngIf="formGroup"></app-dmp-wizard-dataset-listing-component>
<div class="navigation-buttons-container">
<button matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK' | translate}}</button>
<button style="float:right;" matStepperNext mat-raised-button (click)='submit()' color="primary">{{'DMP-WIZARD.ACTIONS.SAVE' | translate}}</button>
<button [disabled]="saving" style="float:right;" matStepperNext mat-raised-button (click)='submit()' color="primary">{{'DMP-WIZARD.ACTIONS.SAVE' | translate}}</button>
</div>
</mat-step>
</mat-horizontal-stepper>

View File

@ -31,6 +31,7 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC
dmp: DmpWizardEditorModel;
formGroup: FormGroup;
isClone: boolean;
saving = false;
constructor(
private dmpService: DmpService,
@ -76,6 +77,7 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC
submit() {
this.saving = true;
if (this.isClone) {
this.dmpService.clone(this.formGroup.getRawValue(), this.itemId)
.pipe(takeUntil(this._destroyed))
@ -100,6 +102,7 @@ export class DmpWizardComponent extends BaseComponent implements OnInit, IBreadC
onCallbackError(error: any) {
this.setErrorModel(error.error);
this.saving = false;
//this.validateAllFormFields(this.formGroup);
}