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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | 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 1x 1x 1x 1x 1x 1x 1x 1x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 4712x 4712x 3029x 4712x 370x 3359x 114x 3359x 370x 3359x 626x 3359x 203x 4442x 4712x 4712x 561x 561x 561x 4712x 4712x 4712x 1787x 4442x 334x 1837x 167x 3245x 1046x 4712x 866x 3515x 89x 1926x 423x 3245x 4712x 4712x 4712x 4712x 4712x 4712x 4712x 1837x 2875x 2583x 292x 292x 4712x 4712x 561x 561x 561x 561x 561x 561x 561x 561x 561x 561x 1x 1x 1x 1x 17x 17x 17x 1x 1x 1x 38x 6x 6x 32x 32x 38x 38x 1x | /*******************************************************************************
* Copyright bei
* Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
*
*******************************************************************************/
import {
ChangeDetectionStrategy,
Component,
ElementRef,
EventEmitter,
HostBinding,
Input,
Output,
ViewChild,
computed,
input,
} from '@angular/core';
import { Callback, FocusableElementOwner } from '../../utils/util.types';
/** Represents days of the week Monday-Sunday */
export type DayOfWeek = 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun';
/**
* Single appointment component for the Calendar component.
*/
@Component({
selector: 'gc-calendar-appointment',
templateUrl: './calendar-appointment.component.html',
styleUrls: [
'../../utils/styles/reset-button.css',
'./calendar-appointment.component.css',
'../../utils/styles/patterns.css',
],
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
})
export class CalendarAppointmentComponent implements FocusableElementOwner {
/** @ignore */
private static readonly dateFormatter = Intl.DateTimeFormat('de-DE', {
day: 'numeric',
month: 'long',
year: 'numeric',
});
/** Label of the calendar appointment (Primary information). */
@Input({ required: true })
label = '';
/** Sublabel of the calendar appointment. (Secondary information) */
@Input()
sublabel = '';
/** Status of the calendar appointment. */
@Input()
status:
| 'scheduled'
| 'prebooked'
| 'postponed'
| 'cancelled'
| 'all-day'
| 'free-time' = 'scheduled';
/** Decides if the calendar appointment is selected. */
@Input()
selected = false;
/** Affects aria readout. If set to true, the appoinment aria-label will be read starting with information that the appointment is today. */
@Input()
isToday = false;
/** Affects aria readout. Decides the day of the week of the calendar appointment. */
@Input({ required: true })
dayOfTheWeek: DayOfWeek = 'mon';
/** Affects aria readout. Decides the start/end time of the calendar appointment. */
@Input()
time: { start: string; end: string } = { start: '00:00', end: '00:00' };
/** Add the element to the keyboard tab order, otherwise only focusable programatically or via click. */
@Input()
public keyboardFocusable = false;
@Output()
public readonly onAction: EventEmitter<'open-infobox' | 'open-details'> =
new EventEmitter<'open-infobox' | 'open-details'>();
/** @ignore */
@ViewChild('appointmentEl')
public readonly _appointmentEl!: ElementRef<HTMLButtonElement>;
@Input()
public focusCallback?: Callback;
@Input()
public keydownCallback?: (event: KeyboardEvent) => void;
/** Scroll margin to add (top). */
@Input()
@HostBinding('style.--gc-appointment-scroll-margin-top.px')
@HostBinding('class.gc-scrollsnap-top')
public scrollMarginTop?: number;
/** Scroll margin to add (left). */
@Input()
@HostBinding('style.--gc-appointment-scroll-margin-left.px')
@HostBinding('class.gc-scrollsnap-left')
public scrollMarginLeft?: number;
/** @ignore */
protected get statusText(): string {
switch (this.status) {
case 'scheduled':
return 'Terminiert';
case 'prebooked':
return 'Vorgemerkt';
case 'postponed':
return 'Verlegt';
case 'cancelled':
return 'Aufgehoben';
case 'all-day':
return 'Ganztägig';
case 'free-time':
return 'Arbeitsfreie Zeit';
default:
this.status satisfies never;
return '';
}
}
/** @ignore */
protected get ariaLabel(): string {
const generateDayOfTheWeekText = () => {
switch (this.dayOfTheWeek) {
case 'mon':
return 'Montag';
case 'tue':
return 'Dienstag';
case 'wed':
return 'Mittwoch';
case 'thu':
return 'Donnerstag';
case 'fri':
return 'Freitag';
case 'sat':
return 'Samstag';
case 'sun':
return 'Sonntag';
default:
this.dayOfTheWeek satisfies never;
return '';
}
};
const todayText = this.isToday ? 'Heute, ' : '';
const sublabel = this.sublabel.length > 0 ? ', ' + this.sublabel : '';
const dayOfTheWeek = generateDayOfTheWeekText();
if (this.monthViewMode()) {
return `${todayText}${this.statusText}, ${dayOfTheWeek}, ${this.formattedDate()}, ${this.label}${sublabel}`;
} else if (this.status !== 'all-day') {
return `${todayText}${this.statusText}, ${dayOfTheWeek}, ${this.formattedDate()}, ${this.time.start} Uhr bis ${this.time.end} Uhr, ${this.label}${sublabel}`;
} else {
return `${todayText}${this.statusText}, ${dayOfTheWeek}, ${this.formattedDate()}, ${this.label}${sublabel}`;
}
}
/** Date of the appointment (e.g. shown in accessible readout), in ISO 8601 format. */
public readonly date = input.required<string>();
/** If true, the appointment is shown in month view mode. */
public readonly monthViewMode = input<boolean>(false);
/** @ignore */
private readonly formattedDate = computed(() =>
CalendarAppointmentComponent.dateFormatter.format(new Date(this.date())),
);
/** @ignore */
public focusChild(): boolean {
this._appointmentEl.nativeElement.focus();
return true;
}
/** @ignore */
protected onKeydownHandler(event: KeyboardEvent): void {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
this.onAction.emit(event.shiftKey ? 'open-details' : 'open-infobox');
} else {
this.keydownCallback?.(event);
}
}
}
|