DMP wizard improvement. (Issue #170)

This commit is contained in:
apapachristou 2019-09-25 17:09:19 +03:00
parent 446717da97
commit 94550ce0c4
3 changed files with 22 additions and 13 deletions

View File

@ -9,7 +9,7 @@
<mat-step [stepControl]="sectionFormGroup">
<ng-template matStepLabel>{{pageFormGroup.get('title').value}}</ng-template>
<!-- <div *ngIf="stepper.selectedIndex == z" class="row"> -->
<div class="row">
<div class="row">
<app-form-section class="col-12" [form]="sectionFormGroup" [path]="z+1" [pathName]="'pages.'+z+'.sections.'+i" [datasetProfileId]="datasetProfileId"></app-form-section>
</div>
</mat-step>

View File

@ -1,16 +1,9 @@
import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
import { AfterViewInit, Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { MatStepper } from '@angular/material/stepper';
import { MatHorizontalStepper } from '@angular/material/stepper';
import { ActivatedRoute, Router } from '@angular/router';
import { takeUntil } from 'rxjs/operators';
import { Pair } from '../../../common/types/pair';
import { BaseComponent } from '../../../core/common/base/base.component';
import { CompositeField } from '../../../core/model/dataset-profile-definition/composite-field';
import { DatasetProfileDefinitionModel } from '../../../core/model/dataset-profile-definition/dataset-profile-definition';
import { Rule } from '../../../core/model/dataset-profile-definition/rule';
import { Section } from '../../../core/model/dataset-profile-definition/section';
import { DatasetDescriptionFormEditorModel } from './dataset-description-form.model';
import { FormFocusService } from './form-focus/form-focus.service';
import { VisibilityRulesService } from './visibility-rules/visibility-rules.service';
@ -19,7 +12,7 @@ import { VisibilityRulesService } from './visibility-rules/visibility-rules.serv
templateUrl: './dataset-description-form.component.html',
styleUrls: ['./dataset-description-form.component.scss']
})
export class DatasetDescriptionFormComponent extends BaseComponent implements OnInit, AfterViewInit {
export class DatasetDescriptionFormComponent extends BaseComponent implements OnInit, AfterViewInit, OnChanges {
// pathName: string;
// pages: Array<number>;
@ -27,7 +20,7 @@ export class DatasetDescriptionFormComponent extends BaseComponent implements On
// visibleSidebar = false;
// datasetProfileDefinitionModel: DatasetDescriptionFormEditorModel;
// private currentPageIndex = 0;
// @ViewChild('stepper') stepper: MatStepper;
@ViewChild('stepper', { static: false }) stepper: MatHorizontalStepper;
// //@Input() dataModel: DatasetProfileDefinitionModel;
@Input() path: string;
@ -78,6 +71,14 @@ export class DatasetDescriptionFormComponent extends BaseComponent implements On
// });
}
ngOnChanges(changes: SimpleChanges) {
// When the form is changed set stepper index to 0.
if (changes['form'] && !changes['form'].isFirstChange()) {
this.stepper.selectedIndex = 0;
}
}
ngAfterViewInit() {
//this.visibilityRulesService.triggerVisibilityEvaluation();
// this.route.queryParams

View File

@ -88,7 +88,7 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition);
let formGroup = dataset.buildForm();
if(isFirst) {
if (isFirst) {
formGroup.get('datasetLabel').setValue(
this.datasetProfile.value["label"] + " " +
this.language.instant('GENERAL.NAMES.DATASET')
@ -106,9 +106,17 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
formArray.push(formGroup);
this.lastIndexOfDataset = formArray.length - 1;
this.editedDataset = true;
this.scrollToTop();
}
listingMode() {
if (this.toggleButton === 0) return true;
}
scrollToTop() {
var currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
if (currentScroll > 0) {
window.scrollTo(0, 0);
}
}
}