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 | 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 7827x 7827x 7827x 1x 1x 30x 23x 23x 23x 30x 30x 30x 30x 30x 30x 30x 30x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x 10x 10x 10x 10x 10x 10x 10x 1x 1x 1x 1x 1x 1x 1x 1x 1122x 1122x 1x 1x 1x 2244x 2244x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2244x 2244x 1x 1x 1x 1x 1x 117x 117x 1x 1x 1x 1x 1x 117x 117x 1x 1x 1x 15x 1x 1x 1x 1x 15x 1x 1x 1x 160x 160x 1x 1x 1x 1x 1x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 358x 358x 358x 358x 358x 358x 358x 358x 358x 358x 346x 346x 12x 12x 358x 358x 41x 41x 41x 1x | /******************************************************************************* * Copyright bei * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa * *******************************************************************************/ import { Component, ElementRef, Input, NgZone, OnDestroy, QueryList, ViewChild, ViewChildren, } from '@angular/core'; import { LinkEvent } from '../utils/event.types'; import { observeElementSize } from '../utils/internal-utils'; import { Callback, Consumer, LinkItem } from '../utils/util.types'; import { itemTrack } from '../utils/utilities'; /** * Breadcrumbs component is a graphical control element used as a navigational aid on a web page. */ @Component({ selector: 'gc-breadcrumbs', templateUrl: './breadcrumbs.component.html', styleUrls: ['./breadcrumbs.component.css'], standalone: false, }) export class BreadcrumbsComponent implements OnDestroy { /** * Optional handler to customize handling of navigation requests */ @Input() public linkHandler?: Consumer<LinkEvent<LinkItem>>; /** @ignore */ @ViewChild('collapsedMenuItem') private menuItem!: ElementRef<HTMLElement>; /** * @ignore */ @ViewChildren('breadcrumbItem') private renderedItems?: QueryList<ElementRef<HTMLElement>>; /** * Items that will be rendered as breadcrumbs. */ @Input() public get items(): readonly LinkItem[] { return this._items; } public set items(items: readonly LinkItem[]) { if (this._items.length === this._visibleItems.size) { // avoid immediate change of the visibility of the 'collapsedMenuItem' to avoid visible layout jumps // in case the following full recalculation determines no change is needed this._visibleItems = new Set(items.map(i => i.key)); } this._items = items; setTimeout(() => { this.computeVisibleItems(); }); } /** * @ignore */ public _visibleItems: ReadonlySet<string> = new Set(); /** * @ignore */ private resizeObserver: Callback; /** @ignore */ private _items: readonly LinkItem[] = []; constructor( private el: ElementRef<HTMLElement>, zone: NgZone, ) { this.resizeObserver = observeElementSize( el.nativeElement, zone, this.computeVisibleItems.bind(this), ); } /** * @ignore */ ngOnDestroy(): void { this.resizeObserver(); } /** @ignore */ public _isFirstItem(item: LinkItem): boolean { return this.items[0]?.key === item.key; } /** @ignore */ public _isLastItem(item: LinkItem): boolean { return this.items[this.items.length - 1]?.key === item.key; } /** @ignore */ public _onMenuAction(item: LinkItem): void { if (this.linkHandler) { this.linkHandler({ linkInfo: item, replace: true }); } else { window.open(item.link, '_self'); } } /** @ignore */ public _isItemVisible(item: LinkItem): boolean { return this._visibleItems.has(item.key); } /** * @ignore */ _getPoppedItems(): LinkItem[] { return this.items.filter(i => !this._isItemVisible(i)); } /** * @ignore */ protected _computeLastItemText(): string { return this.items[this.items.length - 1]?.label ?? ''; } /** @ignore */ protected _createLinkHandler(item: LinkItem): Consumer<LinkEvent> { return evt => { if (this.linkHandler) { this.linkHandler({ linkInfo: item, replace: evt.replace }); } }; } /** @ignore */ protected _itemTrackBy(item: LinkItem): string { return itemTrack(item); } /** * @ignore */ private computeVisibleItems(): void { if (this.items.length === 0 || this.renderedItems === undefined) { this._visibleItems = new Set(); return; } const hostBounds = this.el.nativeElement.getBoundingClientRect(); const collapsedMenuItemWidth = this.menuItem.nativeElement.getBoundingClientRect().width; let availableWidth = hostBounds.width; // last item is always visible const visibleItems = new Set([this.items[this.items.length - 1].key]); availableWidth -= this.renderedItems.last.nativeElement.getBoundingClientRect().width; // add remaining items until no space is left for (let i = this.items.length - 2; i >= 0 && availableWidth > 0; i--) { const itemWidth = this.renderedItems .get(i) ?.nativeElement.getBoundingClientRect().width; if (itemWidth === undefined) { console.warn('failed to find rendered item for item index', i); break; } // include the width of the collapsed menu item in the calculation, as it needs to also fit // in front of the current item when it'd be the last one to show const requiredWidth = itemWidth + (i > 0 ? collapsedMenuItemWidth : 0); if (availableWidth >= requiredWidth) { visibleItems.add(this.items[i].key); availableWidth -= itemWidth; } else { availableWidth = 0; } } this._visibleItems = visibleItems; } } |