Merge branch 'feature-context-help-7.4' into w2p-97732_feature-context-help-service

This commit is contained in:
Koen Pauwels
2023-01-27 13:14:40 +01:00
13 changed files with 39 additions and 54 deletions

View File

@@ -1,33 +1,29 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ContextHelpService } from '../../shared/context-help.service';
import { TranslateService } from '@ngx-translate/core';
import { Observable, Subscription, BehaviorSubject } from 'rxjs';
import { combineLatest } from 'rxjs';
import { Observable, Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
/**
* Renders a "context help toggle" button that toggles the visibility of tooltip buttons on the page.
* If there are no tooltip buttons available on the current page, the toggle is unclickable.
*/
@Component({
selector: 'ds-context-help-toggle',
templateUrl: './context-help-toggle.component.html',
styleUrls: ['./context-help-toggle.component.scss']
})
export class ContextHelpToggleComponent implements OnInit, OnDestroy {
buttonDisabled$: Observable<boolean>;
buttonVisible$: Observable<boolean>;
constructor(
private contextHelpService: ContextHelpService,
private translateService: TranslateService
) { }
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() {
@@ -35,6 +31,6 @@ export class ContextHelpToggleComponent implements OnInit, OnDestroy {
}
onClick() {
this.clickEvents.next(null);
this.contextHelpService.toggleIcons();
}
}