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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | 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 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 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 71993x 71993x 71993x 1x 1x 1670x 1670x 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 2x 2x 2x 1x 1x 1x 85x 82x 82x 82x 82x 82x 82x 85x 8x 5x 5x 3x 3x 77x 77x 77x 85x 85x 1x 1x 1x 1x 1x 214x 214x 1x 1x 1x 1828x 1828x 1828x 1828x 1828x 1828x 1828x 1828x 1828x 1828x 1x 1x 1828x 1828x 1828x 1828x 1828x 1x 1x 1x 23326x 23326x 23326x 23326x 23326x 23324x 23324x 23323x 23323x 23323x 23326x 23326x 1x | /******************************************************************************* * Copyright bei * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa * *******************************************************************************/ import { Component, ElementRef, EventEmitter, Input, NgZone, OnInit, Output, ViewChild, } from '@angular/core'; import { FocusableElementOwner, WidgetKeySet } from '../utils/util.types'; import { createWidgetKeySet } from '../utils/utilities'; import { TextInputComponent } from '../text-input-field/text-input-field.component'; /** * A Checkbox element that allows the user to mark a value as selected. */ @Component({ selector: 'gc-checkbox', templateUrl: './checkbox.component.html', styleUrls: ['./checkbox.component.css'], standalone: false, }) export class CheckboxComponent implements FocusableElementOwner, OnInit { /** * Custom ID to use */ @Input() public id?: string; /** * Hides the label of the checkbox. May be used for embedded rendering like in tables. */ @Input() public hideLabel = false; /** * @ignore */ @ViewChild('input') public _inputElement?: ElementRef<HTMLInputElement>; /** * Text that will show near the checkbox */ @Input() public label = ''; /** * Decides if the checkbox will be rendered in a disabled/enabled state */ @Input() public disabled = false; /** * Decides if the checkbox will be rendered in a readonly state */ @Input() public readonly = false; /** * An error message that shows under a checkbox */ @Input() public errorMessage = ''; /** * Hint message that appears under a checkbox */ @Input() public hint = ''; /** * @ignore * Forces the checkbox to use error styling (independent of the error message) */ @Input() public _useErrorStyle = false; /** * Marks the input field as required. */ @Input() public required = false; /** * Enables setting of the value only when the Promise resolves with value "true". */ @Input() public permitValueChange?: (v: boolean) => Promise<boolean> | boolean; /** * Inform about the change of the selection state */ @Output() public readonly valueChange: EventEmitter<boolean> = new EventEmitter<boolean>(); /** @ignore */ @ViewChild('readonlyTextInput') protected readonlyTextInput?: TextInputComponent; @Input() public get value(): boolean { return this._value; } public set value(value: boolean) { this._value = value; } /** * @ignore */ public _hasFocus = false; /** * @ignore */ protected readonly _widgetKeys: WidgetKeySet = createWidgetKeySet('gc-checkbox'); /** * @ignore */ protected readonly _hintId = this._widgetKeys.baseKey + '-hint'; /** * @ignore */ private _value = false; public constructor(private readonly zone: NgZone) {} public focusChild(): boolean { if (!this.disabled) { if (this.readonly && this.readonlyTextInput) { return this.readonlyTextInput.focusChild(); } else if (this._inputElement) { this._inputElement.nativeElement.focus(); return true; } else { return false; } } else { return false; } } /** @ignore */ public async _handleClick(): Promise<void> { const doChange = () => { this.value = !this.value; if (this._inputElement) { this._inputElement.nativeElement.focus(); this.valueChange.emit(this.value); } else { console.error('native input element not present'); // only expected to be missing in readonly state, otherwise should be always present } }; if (this.permitValueChange) { const permit = await this.permitValueChange(!this.value); if (permit) { doChange(); } else if (this._inputElement) { this._inputElement.nativeElement.checked = this.value; } } else { doChange(); } } /** * @ignore */ public _setFocus(focused: boolean) { this._hasFocus = focused; } /** @ignore */ public ngOnInit(): void { // browser may "restore" previous values after navigating (e.g. with browser's "back" button), // potentially leading to an inconsistent state as no events are fired which could be used to // detect this (observed on Chromium) -> sync back state to the native element after it's rendered this.zone.runOutsideAngular(() => { setTimeout(() => { setTimeout(() => { if ( !this.readonly && this._inputElement && this.value !== this._inputElement.nativeElement.checked ) { this._inputElement.nativeElement.checked = this.value; } }); }); }); } /** @ignore */ protected computeAriaDescribedBy(): string | null { const errId = this.errorMessage.length > 0 ? this._widgetKeys.errorKey : null; const hintId = this.hint.length > 0 ? this._hintId : null; if (errId && hintId) { return hintId + ' ' + errId; } else if (errId) { return errId; } else if (hintId) { return hintId; } else { return null; } } } |