taskid 85843 Add a tree to browse hierarchical facets on the search page - overrides

This commit is contained in:
Samuel
2021-12-16 09:51:40 +01:00
committed by Jens Vannerum
parent e4f483c308
commit 9ff1a6a642
3 changed files with 52 additions and 5 deletions

View File

@@ -98,7 +98,7 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit {
/**
* Array to track all subscriptions and unsubscribe them onDestroy
*/
private subs: Subscription[] = [];
protected subs: Subscription[] = [];
/**
* Initialize instance variables
@@ -110,9 +110,9 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit {
*/
constructor(
public activeModal: NgbActiveModal,
private vocabularyTreeviewService: VocabularyTreeviewService,
private store: Store<CoreState>,
private translate: TranslateService
protected vocabularyTreeviewService: VocabularyTreeviewService,
protected store: Store<CoreState>,
protected translate: TranslateService
) {
this.treeFlattener = new VocabularyTreeFlattener(this.transformer, this.getLevel,
this.isExpandable, this.getChildren);
@@ -301,7 +301,7 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit {
/**
* Return an id for a given {@link VocabularyEntry}
*/
private getEntryId(entry: VocabularyEntry): string {
protected getEntryId(entry: VocabularyEntry): string {
return entry.authority || entry.otherInformation.id || undefined;
}
}

View File

@@ -0,0 +1,47 @@
import { Component } from '@angular/core';
import { VocabularyTreeviewComponent } from '../../../../../app/shared/vocabulary-treeview/vocabulary-treeview.component';
import { filter, find, startWith } from 'rxjs/operators';
import { PageInfo } from '../../../../../app/core/shared/page-info.model';
/**
* Component that show a hierarchical vocabulary in a tree view
*/
@Component({
selector: 'ds-okr-vocabulary-treeview',
templateUrl: '../../../../../app/shared/vocabulary-treeview/vocabulary-treeview.component.html',
styleUrls: [
'./okr-vocabulary-treeview.component.scss',
'../../../../../app/shared/vocabulary-treeview/vocabulary-treeview.component.scss',
]
})
export class OkrVocabularyTreeviewComponent extends VocabularyTreeviewComponent {
/**
* Initialize the component, setting up the data to build the tree
*/
ngOnInit(): void {
this.subs.push(
this.vocabularyTreeviewService.getData().subscribe((data) => {
this.dataSource.data = data;
})
);
const descriptionLabel = 'vocabulary-treeview.tree.description.' + this.vocabularyOptions.name;
this.description = this.translate.get(descriptionLabel).pipe(
filter((msg) => msg !== descriptionLabel),
startWith('')
);
// set isAuthenticated
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
this.loading = this.vocabularyTreeviewService.isLoading();
this.isAuthenticated.pipe(
find((isAuth) => isAuth)
).subscribe(() => {
const entryId: string = (this.selectedItem) ? this.getEntryId(this.selectedItem) : null;
this.vocabularyTreeviewService.initialize(this.vocabularyOptions, new PageInfo(), entryId);
});
}
}