Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 1x 1x 16x 19x 19x 19x 3x 3x 1x 3x 3x 3x 16x 19x 16x 16x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 15x 15x 15x 15x 1x | /*******************************************************************************
* Copyright bei
* Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
*
*******************************************************************************/
import {
Component,
computed,
effect,
input,
model,
untracked,
viewChild,
viewChildren,
} from '@angular/core';
import { FocusableElementOwner } from '../utils/util.types';
import { AriaLiveReaderComponent } from '../internal/aria-live-reader/aria-live-reader.component';
import {
AppHeaderButtonComponent,
AppHeaderButtonType,
} from './app-header-button/app-header-button.component';
export type { AppHeaderButtonType }; // re-export to ensure it's part of the public API (moving it completely to this location would create an import cycle in Angular)
/**
* `gc-app-header` is a horizontal user interface element that contains buttons to show tools and subcontent related to the page
*/
@Component({
selector: 'gc-app-header',
templateUrl: './app-header.component.html',
styleUrls: ['./app-header.component.css'],
host: {
'[style.--gc-right-buttons-count]': 'rightHeaderButtonsCount()',
},
standalone: false,
})
export class AppHeaderComponent implements FocusableElementOwner {
/**
* Label that will show on the header.
*/
public label = input('');
/**
* Number of new appointment notifications.
*/
public newAppointments = input<number>();
/**
* Number of new message notifications.
*/
public newMessages = input<number>();
/**
* Prefix text shown in loading tooltip.
*/
public loadingTextPrefix = input('Behördenname');
/**
* Buttons showing up on the header right side.
*/
public shownHeaderButtons = input<ReadonlySet<AppHeaderButtonType>>(
new Set(['search', 'calendar', 'notifications', 'person', 'help']),
);
/**
* Currently selected button.
* When `undefined`, no button is selected.
*/
public selectedButton = model<AppHeaderButtonType | undefined>(undefined);
/**
* Indicates that the app-header is in a loading state.
*/
public isLoading = input(false);
/** @ignore */
protected newAppointmentsDescription = computed(() => {
const newAppointments = this.newAppointments();
if (newAppointments === undefined || newAppointments === 0) {
return '';
} else {
return (
newAppointments.toString() +
(newAppointments === 1 ? ' neuer Termin' : ' neue Termine')
);
}
});
/** @ignore */
protected newMessagesDescription = computed(() => {
const newMessages = this.newMessages();
if (newMessages === undefined || newMessages === 0) {
return '';
} else {
return (
newMessages.toString() +
(newMessages === 1 ? ' neue Meldung' : ' neue Meldungen')
);
}
});
/** @ignore */
protected rightHeaderButtonsCount = computed(() => {
return this.shownHeaderButtons().size;
});
/** @ignore */
protected loadingTooltipText = computed(
() => this.loadingTextPrefix() + ' wird geladen',
);
/** @ignore */
private loadedAfterTwoSeconds = false;
/**
* @ignore
*/
private readonly appHeaderButtons = viewChildren(AppHeaderButtonComponent);
/** @ignore */
private readonly ariaLiveRegion =
viewChild<AriaLiveReaderComponent>('ariaLiveRegion');
constructor() {
effect(onCleanup => {
const loading = this.isLoading();
if (loading) {
this.loadedAfterTwoSeconds = false;
const timer = setTimeout(() => {
this.loadedAfterTwoSeconds = true;
}, 2000);
onCleanup(() => {
clearTimeout(timer);
});
} else if (this.loadedAfterTwoSeconds) {
untracked(() => {
this.ariaLiveRegion()?.readText(
`${this.loadingTextPrefix()} geladen`,
);
});
}
});
}
public focusChild(): boolean {
const foundButton = this.appHeaderButtons().find(
btn => btn.type() === this.selectedButton(),
);
if (foundButton) {
foundButton.focusChild();
return true;
} else if (this.appHeaderButtons().at(0)?.button) {
this.appHeaderButtons().at(0)?.focusChild();
return true;
} else {
return false;
}
}
/**
* @ignore
*/
public _onSelect(button: AppHeaderButtonComponent): void {
this.selectedButton.update(current =>
current === button.type() ? undefined : button.type(),
);
}
}
|