From c8ce77ff8144b707f6ebb7533a8c8e3f1aef6e6f Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Fri, 19 Mar 2021 14:32:17 +0200 Subject: [PATCH] Dataset Wizard. Fix "Previous" and "Next " steps behaviour. Uncompleted guide steps appear with red when user attempts to save. --- .../dataset-wizard.component.html | 4 +-- .../dataset-wizard.component.ts | 29 ++++++++++++++----- .../table-of-contents.ts | 6 ++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html index ff03921a6..b131ac730 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html @@ -50,11 +50,11 @@
{{'DMP-EDITOR.STEPPER.USER-GUIDE' | translate}}
-
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (2)
+
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (2)
0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (done)
- +
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index db210e626..7ae47a871 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; @@ -23,7 +23,7 @@ import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; -import { Link, LinkToScroll } from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents'; +import { Link, LinkToScroll, TableOfContents } from '@app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents'; import { BaseComponent } from '@common/base/base.component'; import { FormService } from '@common/forms/form-service'; import { FormValidationErrorsDialogComponent } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.component'; @@ -93,6 +93,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr //the table seraches for elements to scroll on page with id (TOCENTRY_ID_PREFIX+fieldsetId) TOCENTRY_ID_PREFIX="TocEntRy"; showtocentriesErrors = false; + @ViewChild('table0fContents', {static: false}) table0fContents: TableOfContents; + hintErrors: boolean = false; constructor( private datasetWizardService: DatasetWizardService, @@ -654,11 +656,21 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr } save(saveType?: SaveType) { - this.formService.touchAllFormFields(this.formGroup); + + Object.keys(this.formGroup.controls).forEach(controlName=>{ + if(controlName == 'datasetProfileDefinition'){ + return; + } + this.formService.touchAllFormFields(this.formGroup.get(controlName)); + }) + + + // this.formService.touchAllFormFields(this.formGroup); if (!this.isSemiFormValid(this.formGroup)) { //build messages const errorMessages = this._buildSemiFormErrorMessages(); this.showValidationErrorsDialog(undefined, errorMessages); + this.hintErrors = true; return; } this.submit(saveType); @@ -998,17 +1010,19 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr public nextStep() { if(this.step < this.maxStep){//view is changing - this.step +=1; + if(this.step === 0 && this.table0fContents){ + this.table0fContents.seekToFirstElement(); + } + this.step++; this.resetScroll(); } // this.step = this.step < this.maxStep ? this.step + 1 : this.step; } public previousStep() { - if(this.step !== 0){ - + if(this.step > 0){ this.resetScroll(); - this.step =-1; + this.step--; } // this.step = this.step !== 0 ? this.step - 1 : this.step; @@ -1025,6 +1039,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr discardChanges() { this.isDiscarded = true; this.hasChanges = false; + this.hintErrors = false; if (this.isNew) { Object.keys(this.formGroup['controls']).forEach((key: string) => { if (key !== 'dmp') { diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts index 4c783ed94..aa67829c8 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts @@ -310,6 +310,12 @@ export class TableOfContents extends BaseComponent implements OnInit { } + public seekToFirstElement(){//only on tocentry mode + if(this.tocentries && this.tocentries.length){ + this.tocentrySelected = this.tocentries[0]; + } + } + } export interface LinkToScroll {