2021-03-17 10:08:59 +01:00
|
|
|
import { DOCUMENT } from '@angular/common';
|
|
|
|
import { Component, EventEmitter, Inject, OnInit, Output, Input } from '@angular/core';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
|
|
|
import { interval, Subject, Subscription } from 'rxjs';
|
|
|
|
import { distinctUntilChanged } from 'rxjs/operators';
|
|
|
|
import { type } from 'os';
|
|
|
|
import { SimpleChanges } from '@angular/core';
|
|
|
|
import { ToCEntry, ToCEntryType } from '../../dataset-description.component';
|
|
|
|
import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service';
|
|
|
|
import { Rule } from '@app/core/model/dataset-profile-definition/rule';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'table-of-contents-internal',
|
|
|
|
styleUrls: ['./table-of-contents-internal.scss'],
|
|
|
|
templateUrl: './table-of-contents-internal.html'
|
|
|
|
})
|
|
|
|
export class TableOfContentsInternal implements OnInit {
|
|
|
|
|
|
|
|
@Input() tocentries: ToCEntry[] = null;
|
|
|
|
@Input() selected: ToCEntry = null;
|
|
|
|
// @Input() visibilityRules:Rule[] = [];
|
|
|
|
@Output() entrySelected = new EventEmitter<ToCEntry>();
|
|
|
|
|
|
|
|
expandChildren:boolean[];
|
|
|
|
tocEntryTypeEnum = ToCEntryType;
|
2021-03-18 09:52:18 +01:00
|
|
|
@Input() TOCENTRY_ID_PREFIX="";
|
2021-03-17 10:08:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
constructor(public visibilityRulesService: VisibilityRulesService){
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
|
|
// console.log('component created');
|
|
|
|
if(this.tocentries){
|
|
|
|
this.expandChildren = this.tocentries.map(()=>false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges) {
|
|
|
|
// if (!this.isActive && this.links && this.links.length > 0) {
|
|
|
|
// this.links.forEach(link => {
|
|
|
|
// link.selected = false;
|
|
|
|
// })
|
|
|
|
// this.links[0].selected = true;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleExpand(index){
|
|
|
|
this.expandChildren[index] = !this.expandChildren[index];
|
|
|
|
// console.log(this.expandChildren);
|
|
|
|
}
|
|
|
|
|
|
|
|
navigateToFieldSet(entry:ToCEntry, event){
|
|
|
|
if(entry.type === ToCEntryType.FieldSet){
|
|
|
|
|
|
|
|
const fieldSetId = entry.id;
|
2021-03-17 16:49:42 +01:00
|
|
|
const element = document.getElementById(this.TOCENTRY_ID_PREFIX+fieldSetId);
|
2021-03-17 10:08:59 +01:00
|
|
|
if(element){
|
2021-03-17 16:49:42 +01:00
|
|
|
element.click();//open mat expansion panel
|
|
|
|
|
|
|
|
//scroll asyn in 200 ms so the expansion panel is expanded and the element coordinates are updated
|
|
|
|
setTimeout(() => {
|
|
|
|
const element = document.getElementById(this.TOCENTRY_ID_PREFIX+fieldSetId);
|
|
|
|
if(element){
|
|
|
|
element.scrollIntoView({behavior:'smooth'});
|
|
|
|
}
|
2021-03-18 09:52:18 +01:00
|
|
|
}, 300);
|
2021-03-17 10:08:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onEntrySelected(entry:ToCEntry){
|
|
|
|
this.entrySelected.emit(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
calculateStyle(entry: ToCEntry){
|
|
|
|
const style = {};
|
|
|
|
style['font-size'] = entry.type ===this.tocEntryTypeEnum.FieldSet? '.9em': '1em';
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
|
|
|
calculateClass(entry:ToCEntry){
|
|
|
|
|
|
|
|
if(this.selected && entry.id === this.selected.id){
|
|
|
|
return{'selected': true};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|