mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 20:13:07 +00:00
97732 Context help toggle button only appears when there is at least one element with a tooltip on the page
This commit is contained in:
@@ -2,6 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { ContextHelpService } from '../../shared/context-help.service';
|
||||
import { Observable, Subscription, BehaviorSubject } from 'rxjs';
|
||||
import { combineLatest } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
/**
|
||||
* Renders a "context help toggle" button that toggles the visibility of tooltip buttons on the page.
|
||||
@@ -13,23 +14,17 @@ import { combineLatest } from 'rxjs';
|
||||
styleUrls: ['./context-help-toggle.component.scss']
|
||||
})
|
||||
export class ContextHelpToggleComponent implements OnInit, OnDestroy {
|
||||
buttonDisabled$: Observable<boolean>;
|
||||
buttonVisible$: Observable<boolean>;
|
||||
|
||||
constructor(
|
||||
private contextHelpService: ContextHelpService,
|
||||
) { }
|
||||
|
||||
private clickEvents: BehaviorSubject<null> = new BehaviorSubject(null);
|
||||
private subs: Subscription[];
|
||||
|
||||
ngOnInit(): void {
|
||||
this.buttonDisabled$ = this.contextHelpService.contextHelpEmpty$();
|
||||
this.subs = [
|
||||
this.buttonDisabled$.subscribe(),
|
||||
combineLatest([this.clickEvents, this.buttonDisabled$])
|
||||
.subscribe(([_, disabled]) =>
|
||||
disabled ? null : this.contextHelpService.toggleIcons())
|
||||
];
|
||||
this.buttonVisible$ = this.contextHelpService.tooltipCount$().pipe(map(x => x > 0));
|
||||
this.subs = [this.buttonVisible$.subscribe()];
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -37,6 +32,6 @@ export class ContextHelpToggleComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
onClick() {
|
||||
this.clickEvents.next(null);
|
||||
this.contextHelpService.toggleIcons();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user