2023-12-20 08:20:38 +01:00
|
|
|
import {
|
|
|
|
ChangeDetectionStrategy,
|
|
|
|
ChangeDetectorRef,
|
|
|
|
Component,
|
|
|
|
EventEmitter,
|
|
|
|
Input,
|
|
|
|
OnChanges,
|
|
|
|
OnInit,
|
|
|
|
Output,
|
|
|
|
SimpleChanges
|
|
|
|
} from '@angular/core';
|
|
|
|
import { UntypedFormGroup } from '@angular/forms';
|
|
|
|
import { DescriptionTemplateSection } from '@app/core/model/description-template/description-template';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
|
|
|
import { ToCEntry } from '../../../table-of-contents/models/toc-entry';
|
|
|
|
import { ToCEntryType } from '../../../table-of-contents/models/toc-entry-type.enum';
|
|
|
|
import { LinkToScroll } from '../../../table-of-contents/table-of-contents.component';
|
|
|
|
import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service';
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
2024-02-02 17:43:24 +01:00
|
|
|
selector: 'app-description-form-section',
|
2023-12-20 08:20:38 +01:00
|
|
|
templateUrl: './form-section.component.html',
|
|
|
|
styleUrls: ['./form-section.component.scss'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
})
|
|
|
|
export class DescriptionFormSectionComponent extends BaseComponent implements OnInit, OnChanges {
|
|
|
|
|
|
|
|
@Input() section: DescriptionTemplateSection;
|
|
|
|
@Input() propertiesFormGroup: UntypedFormGroup;
|
|
|
|
@Input() visibilityRulesService: VisibilityRulesService;
|
2023-12-28 16:18:49 +01:00
|
|
|
@Input() path: string;
|
2023-12-20 08:20:38 +01:00
|
|
|
|
|
|
|
// @Input() datasetProfileId: String;
|
|
|
|
// @Input() form: UntypedFormGroup;
|
|
|
|
@Input() tocentry: ToCEntry;
|
|
|
|
@Input() pathName: string;
|
|
|
|
@Input() linkToScroll: LinkToScroll;
|
|
|
|
@Input() hiddenEntriesIds: string[] = [];
|
|
|
|
panelExpanded = true;
|
|
|
|
subsectionLinkToScroll: LinkToScroll;
|
|
|
|
@Output() askedToScroll = new EventEmitter<string>();
|
|
|
|
tocentriesType = ToCEntryType;
|
|
|
|
@Input() TOCENTRY_ID_PREFIX = "";
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private changeDetector: ChangeDetectorRef
|
|
|
|
) {
|
|
|
|
super();
|
2023-12-28 16:18:49 +01:00
|
|
|
|
2023-12-20 08:20:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
2023-12-28 16:18:49 +01:00
|
|
|
// this.visibilityRulesService.getElementVisibilityMapObservable().pipe(takeUntil(this._destroyed)).subscribe(x => {
|
|
|
|
// this.changeDetector.markForCheck();
|
|
|
|
// });
|
2023-12-20 08:20:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges) {
|
|
|
|
|
|
|
|
if (changes['linkToScroll']) {
|
|
|
|
if (changes['linkToScroll'].currentValue && changes['linkToScroll'].currentValue.section) {
|
|
|
|
|
|
|
|
if (this.pathName === changes['linkToScroll'].currentValue.section) {
|
|
|
|
this.panelExpanded = true;
|
|
|
|
} else if (changes['linkToScroll'].currentValue.section.includes(this.pathName)) {
|
|
|
|
this.subsectionLinkToScroll = changes['linkToScroll'].currentValue;
|
|
|
|
this.panelExpanded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|