2019-09-25 16:09:19 +02:00
|
|
|
import { AfterViewInit, Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core';
|
2018-10-30 12:03:02 +01:00
|
|
|
import { FormGroup } from '@angular/forms';
|
2019-09-25 16:09:19 +02:00
|
|
|
import { MatHorizontalStepper } from '@angular/material/stepper';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { BaseComponent } from '../../../core/common/base/base.component';
|
|
|
|
import { Rule } from '../../../core/model/dataset-profile-definition/rule';
|
2019-10-15 16:25:43 +02:00
|
|
|
import { LinkToScroll } from './tableOfContentsMaterial/table-of-contents';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { VisibilityRulesService } from './visibility-rules/visibility-rules.service';
|
2018-01-30 10:35:26 +01:00
|
|
|
|
|
|
|
@Component({
|
2019-01-18 18:03:45 +01:00
|
|
|
selector: 'app-dataset-description-form',
|
|
|
|
templateUrl: './dataset-description-form.component.html',
|
|
|
|
styleUrls: ['./dataset-description-form.component.scss']
|
2018-01-30 10:35:26 +01:00
|
|
|
})
|
2019-09-25 16:09:19 +02:00
|
|
|
export class DatasetDescriptionFormComponent extends BaseComponent implements OnInit, AfterViewInit, OnChanges {
|
2018-01-30 10:35:26 +01:00
|
|
|
|
2019-09-25 16:09:19 +02:00
|
|
|
@ViewChild('stepper', { static: false }) stepper: MatHorizontalStepper;
|
2018-10-05 17:00:54 +02:00
|
|
|
@Input() path: string;
|
|
|
|
@Input() form: FormGroup;
|
2019-01-28 14:47:31 +01:00
|
|
|
@Input() visibilityRules: Rule[] = [];
|
2019-01-28 13:18:48 +01:00
|
|
|
@Input() datasetProfileId: String;
|
2019-10-22 14:46:48 +02:00
|
|
|
@Input() linkToScroll: LinkToScroll;
|
2018-10-05 17:00:54 +02:00
|
|
|
|
2018-10-16 13:11:15 +02:00
|
|
|
constructor(
|
2018-10-05 17:00:54 +02:00
|
|
|
private visibilityRulesService: VisibilityRulesService,
|
|
|
|
) {
|
2018-11-27 18:33:17 +01:00
|
|
|
super();
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2019-02-08 09:48:28 +01:00
|
|
|
this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, this.form);
|
2018-11-01 17:02:15 +01:00
|
|
|
}
|
2018-10-05 17:00:54 +02:00
|
|
|
|
2019-09-25 16:09:19 +02:00
|
|
|
ngOnChanges(changes: SimpleChanges) {
|
|
|
|
|
|
|
|
// When the form is changed set stepper index to 0.
|
2019-11-07 15:37:07 +01:00
|
|
|
if (this.stepper && changes['form'] && !changes['form'].isFirstChange()) {
|
2019-09-25 16:09:19 +02:00
|
|
|
this.stepper.selectedIndex = 0;
|
2019-11-07 15:37:07 +01:00
|
|
|
} else if (this.stepper && changes['linkToScroll'] && changes['linkToScroll'].currentValue) {
|
2019-10-22 14:46:48 +02:00
|
|
|
if (changes['linkToScroll'].currentValue.page >= 0) {
|
|
|
|
this.stepper.selectedIndex = changes['linkToScroll'].currentValue.page;
|
|
|
|
}
|
2019-09-25 16:09:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-01 17:02:15 +01:00
|
|
|
ngAfterViewInit() {
|
2018-10-05 17:00:54 +02:00
|
|
|
|
2019-10-22 14:46:48 +02:00
|
|
|
}
|
2018-05-28 11:50:42 +02:00
|
|
|
}
|