97732 ContextHelpToggleComponent added

This commit is contained in:
Koen Pauwels
2023-01-04 17:02:39 +01:00
parent 5ba45cb0fa
commit e16a3edf78
9 changed files with 71 additions and 3 deletions

View File

@@ -58,6 +58,7 @@ import { ThemedPageInternalServerErrorComponent } from './page-internal-server-e
import { PageInternalServerErrorComponent } from './page-internal-server-error/page-internal-server-error.component'; import { PageInternalServerErrorComponent } from './page-internal-server-error/page-internal-server-error.component';
import { APP_CONFIG, AppConfig } from '../config/app-config.interface'; import { APP_CONFIG, AppConfig } from '../config/app-config.interface';
import { ContextHelpToggleComponent } from './header/context-help-toggle/context-help-toggle.component';
export function getConfig() { export function getConfig() {
return environment; return environment;
@@ -167,6 +168,7 @@ const DECLARATIONS = [
RootComponent, RootComponent,
ThemedRootComponent, ThemedRootComponent,
HeaderComponent, HeaderComponent,
ContextHelpToggleComponent,
ThemedHeaderComponent, ThemedHeaderComponent,
HeaderNavbarWrapperComponent, HeaderNavbarWrapperComponent,
ThemedHeaderNavbarWrapperComponent, ThemedHeaderNavbarWrapperComponent,

View File

@@ -0,0 +1,8 @@
<div>
<a href="javascript:void(0);"
role="button"
(click)="onClick()"
>
<i class="fas fa-question-circle ds-context-help-toggle"></i>
</a>
</div>

View File

@@ -0,0 +1,8 @@
.ds-context-help-toggle {
color: var(--ds-header-icon-color);
background-color: var(--ds-header-bg);
}
.ds-context-help-toggle:hover {
color: var(--ds-header-icon-color-hover);
}

View File

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ContextHelpToggleComponent } from './context-help-toggle.component';
describe('ContextHelpToggleComponent', () => {
let component: ContextHelpToggleComponent;
let fixture: ComponentFixture<ContextHelpToggleComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ContextHelpToggleComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ContextHelpToggleComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,22 @@
import { Component, OnInit } from '@angular/core';
import { ContextHelpService } from '../../shared/context-help.service';
@Component({
selector: 'ds-context-help-toggle',
templateUrl: './context-help-toggle.component.html',
styleUrls: ['./context-help-toggle.component.scss']
})
export class ContextHelpToggleComponent implements OnInit {
constructor(
private contextHelpService: ContextHelpService
) { }
ngOnInit(): void {
}
onClick() {
console.log('toggling icons');
this.contextHelpService.toggleIcons();
}
}

View File

@@ -8,6 +8,7 @@
<nav role="navigation" [attr.aria-label]="'nav.user.description' | translate" class="navbar navbar-light navbar-expand-md flex-shrink-0 px-0"> <nav role="navigation" [attr.aria-label]="'nav.user.description' | translate" class="navbar navbar-light navbar-expand-md flex-shrink-0 px-0">
<ds-search-navbar></ds-search-navbar> <ds-search-navbar></ds-search-navbar>
<ds-lang-switch></ds-lang-switch> <ds-lang-switch></ds-lang-switch>
<ds-context-help-toggle></ds-context-help-toggle>
<ds-auth-nav-menu></ds-auth-nav-menu> <ds-auth-nav-menu></ds-auth-nav-menu>
<ds-impersonate-navbar></ds-impersonate-navbar> <ds-impersonate-navbar></ds-impersonate-navbar>
<div class="pl-2"> <div class="pl-2">

View File

@@ -1,4 +1,5 @@
<div class="page-internal-server-error container"> <div class="page-internal-server-error container">
<ds-context-help-toggle></ds-context-help-toggle>
<h1>500</h1> <h1>500</h1>
<h2><small *dsContextHelp="{content: 'context-help.multi-para.test', id: 'server-error'}">{{"500.page-internal-server-error" | translate}}</small></h2> <h2><small *dsContextHelp="{content: 'context-help.multi-para.test', id: 'server-error'}">{{"500.page-internal-server-error" | translate}}</small></h2>
<br/> <br/>

View File

@@ -69,10 +69,11 @@ export class ContextHelpWrapperComponent implements OnInit, AfterViewInit, OnDes
ngOnInit() { ngOnInit() {
this.shouldShowIcon$ = this.contextHelpService.shouldShowIcons$(); this.shouldShowIcon$ = this.contextHelpService.shouldShowIcons$();
this.subs.push(this.shouldShowIcon$.subscribe());
} }
ngAfterViewInit() { ngAfterViewInit() {
this.subs = [ this.subs.push(
this.contextHelpService.getContextHelp$(this.id) this.contextHelpService.getContextHelp$(this.id)
.pipe(hasValueOperator()) .pipe(hasValueOperator())
.subscribe((ch: ContextHelp) => { .subscribe((ch: ContextHelp) => {
@@ -90,7 +91,7 @@ export class ContextHelpWrapperComponent implements OnInit, AfterViewInit, OnDes
this.tooltip.hidden.subscribe(() => { this.tooltip.hidden.subscribe(() => {
this.contextHelpService.hideTooltip(this.id); this.contextHelpService.hideTooltip(this.id);
}) })
]; );
} }
ngOnDestroy() { ngOnDestroy() {

View File

@@ -16,7 +16,7 @@ const initialState: ContextHelpState = {allIconsVisible: true, models: {}};
export function contextHelpReducer(state: ContextHelpState = initialState, action: ContextHelpAction): ContextHelpState { export function contextHelpReducer(state: ContextHelpState = initialState, action: ContextHelpAction): ContextHelpState {
switch (action.type) { switch (action.type) {
case ContextHelpActionTypes.CONTEXT_HELP_TOGGLE_ICONS: { case ContextHelpActionTypes.CONTEXT_HELP_TOGGLE_ICONS: {
return {...state, allIconsVisible: true}; return {...state, allIconsVisible: !state.allIconsVisible};
} }
case ContextHelpActionTypes.CONTEXT_HELP_ADD: { case ContextHelpActionTypes.CONTEXT_HELP_ADD: {
const newModels = {...state.models, [action.model.id]: action.model}; const newModels = {...state.models, [action.model.id]: action.model};