2019-01-18 18:03:45 +01:00
|
|
|
import { AfterViewInit, Component, Input, OnInit } from '@angular/core';
|
2019-01-31 11:29:35 +01:00
|
|
|
import { FormGroup, FormArray, AbstractControl } from '@angular/forms';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { FormFocusService } from '../../form-focus/form-focus.service';
|
|
|
|
import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service';
|
2019-01-31 11:29:35 +01:00
|
|
|
import { DatasetDescriptionSectionEditorModel, DatasetDescriptionCompositeFieldEditorModel } from '../../dataset-description-form.model';
|
|
|
|
import { FormCompositeFieldComponent } from '../form-composite-field/form-composite-field.component';
|
2018-01-05 18:02:26 +01:00
|
|
|
|
2017-11-23 11:40:02 +01:00
|
|
|
@Component({
|
2019-01-18 18:03:45 +01:00
|
|
|
selector: 'app-form-section',
|
|
|
|
templateUrl: './form-section.component.html',
|
|
|
|
styleUrls: ['./form-section.component.scss']
|
2017-12-06 11:35:50 +01:00
|
|
|
})
|
2019-01-29 08:47:50 +01:00
|
|
|
export class FormSectionComponent implements OnInit {
|
2017-11-23 11:40:02 +01:00
|
|
|
|
2019-01-31 11:29:35 +01:00
|
|
|
//@Input() section: DatasetDescriptionSectionEditorModel;
|
2019-01-29 08:47:50 +01:00
|
|
|
@Input() datasetProfileId: String;
|
2019-01-28 14:47:31 +01:00
|
|
|
@Input() form: FormGroup;
|
2018-10-05 17:00:54 +02:00
|
|
|
@Input() pathName: string;
|
|
|
|
@Input() path: string;
|
2019-01-28 14:47:31 +01:00
|
|
|
//trackByFn = (index, item) => item ? item['id'] : null;
|
2018-11-01 17:02:15 +01:00
|
|
|
constructor(
|
2019-01-31 11:29:35 +01:00
|
|
|
public visibilityRulesService: VisibilityRulesService,
|
2018-11-01 17:02:15 +01:00
|
|
|
private formFocusService: FormFocusService
|
|
|
|
) { }
|
2017-11-23 11:40:02 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
ngOnInit() {
|
2019-01-28 14:47:31 +01:00
|
|
|
// if (this.section) {
|
|
|
|
// this.form = this.visibilityRulesService.getFormGroup(this.section.id);
|
|
|
|
// }
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
2018-09-18 14:41:24 +02:00
|
|
|
|
2019-01-28 14:47:31 +01:00
|
|
|
// ngAfterViewInit() {
|
|
|
|
// this.visibilityRulesService.triggerVisibilityEvaluation();
|
|
|
|
// }
|
2018-01-05 18:02:26 +01:00
|
|
|
|
2019-01-31 11:29:35 +01:00
|
|
|
addMultipleField(fieldsetIndex: number) {
|
|
|
|
const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldsetIndex) as FormGroup).getRawValue();
|
|
|
|
const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned, fieldsetIndex);
|
|
|
|
(<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
|
|
|
|
}
|
2018-01-05 18:02:26 +01:00
|
|
|
|
2019-01-28 14:47:31 +01:00
|
|
|
// isElementVisible(fieldSet: CompositeField): boolean {
|
|
|
|
// return fieldSet && fieldSet.fields && fieldSet.fields.length > 0
|
|
|
|
// }
|
2018-11-01 17:02:15 +01:00
|
|
|
|
2019-01-28 14:47:31 +01:00
|
|
|
// next(compositeField: CompositeField) {
|
|
|
|
// this.formFocusService.focusNext(compositeField);
|
|
|
|
// }
|
2018-05-28 11:50:42 +02:00
|
|
|
}
|