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 | 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 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 11x 11x 11x 11x 11x 11x 11x 13x 11x 11x 11x 11x 11x 11x 11x 11x 23x 23x 23x 23x 28x 28x 28x 28x 28x 23x 23x 23x 70x 70x 70x 70x 70x 70x 23x 23x 23x 70x 70x 70x 23x 23x 3x 3x 23x 23x 23x 23x 23x 23x 31x 31x 4x 31x 31x 8x 31x 31x 23x 8x 8x 31x 23x 23x 25x 17x 8x 1x 1x | /* eslint-disable @typescript-eslint/member-ordering */
/*******************************************************************************
* Copyright bei
* Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
*
*******************************************************************************/
import {
ChangeDetectionStrategy,
Component,
ElementRef,
NgZone,
TemplateRef,
afterRenderEffect,
computed,
inject,
input,
output,
viewChild,
} from '@angular/core';
import { ActionEvent } from '../utils/event.types';
import { badgeListAsString } from '../utils/internal-utils';
import { BadgeItem, FocusableElementOwner } from '../utils/util.types';
import { BadgeItemTemplateContext } from '../badge-list/badge-list.component';
import { ButtonComponent } from '../button/button.component';
import {
DynamicHeadingLevelPassthroughService,
DynamicHeadingLevelService,
} from '../dynamic-heading/dynamic-heading-level.service';
import { CardLayoutComponent } from './card-layout.component';
/**
* `gc-card` is used in forms to summarize data from subforms.
*/
@Component({
selector: 'gc-card',
templateUrl: './card.component.html',
styleUrls: ['../utils/styles/reset-form.css', './card.component.css'],
providers: [DynamicHeadingLevelService],
viewProviders: [
{
provide: DynamicHeadingLevelService,
useClass: DynamicHeadingLevelPassthroughService,
},
],
changeDetection: ChangeDetectionStrategy.Eager,
standalone: false,
})
export class CardComponent implements FocusableElementOwner {
/**
* Label of the card.
*/
public readonly label = input.required<string>();
/**
* Badge items to display in the header
*/
public readonly badgeItems = input<readonly BadgeItem[]>([]);
/**
* Icon provider for badge
*/
public readonly badgeIconProvider =
input<TemplateRef<BadgeItemTemplateContext>>();
/**
* State of button
*/
public readonly state = input<'edit' | 'view' | 'inactive'>('edit');
/**
* Card shows error icon
*/
public readonly hasError = input<boolean>(false);
/**
* The method that gets fired when the edit button is pressed.
*/
public readonly onAction = output<ActionEvent>();
/** @ignore */
private readonly statusButton = viewChild.required('statusButton', {
read: ButtonComponent,
});
/** @ignore */
private readonly headerTitleElement =
viewChild.required<ElementRef<HTMLDivElement>>('headerTitle');
private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
constructor() {
const cardLayout = inject<CardLayoutComponent | null>(CardLayoutComponent, {
optional: true,
});
if (cardLayout) {
const zone = inject(NgZone);
afterRenderEffect({
read: () => {
const headerTitleElement = this.headerTitleElement();
const sizeObserver = zone.runOutsideAngular(() => {
const s = new ResizeObserver(() => {
cardLayout._recomputeHeaders();
});
s.observe(headerTitleElement.nativeElement);
return s;
});
return () => {
sizeObserver.disconnect();
};
},
});
}
}
/** @ignore */
public _updateColumnConfig(startColumn: number, endColumn: number): void {
this.elementRef.nativeElement.style.setProperty(
'--gc-card-layout-column',
`${startColumn.toFixed(0)}/${endColumn.toFixed(0)}`,
);
}
/** @ignore */
public _updateMinTitleHeight(minHeight: number): void {
if (minHeight <= 56) {
this.elementRef.nativeElement.style.removeProperty(
'--gc-card-header-height',
);
} else {
this.elementRef.nativeElement.style.setProperty(
'--gc-card-header-height',
`${minHeight.toFixed(0)}px`,
);
}
}
/** @ignore */
public _headerTitleHeight(): number {
const headerTitleElement = this.headerTitleElement();
return headerTitleElement.nativeElement.clientHeight;
}
public focusChild(): boolean {
return this.statusButton().focusChild();
}
/** @ignore */
protected onButtonPress(event: ActionEvent): void {
this.onAction.emit(event);
}
/** @ignore */
protected readonly additionalLegendText = computed(() => {
const result = [];
if (this.hasError()) {
result.push('Fehlerhaft');
}
if (this.badgeItems().length > 0) {
result.push(badgeListAsString(this.badgeItems()));
}
if (result.length === 0) {
return '';
}
return '– ' + result.join(' – ');
});
protected readonly computeLabel = computed(() => {
return this.state() === 'edit'
? this.label() + ' bearbeiten'
: this.label() + ' anzeigen';
});
}
|