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 | 4x 4x 4x 6x 6x 11x 5x 5x | import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { BasketView } from 'ish-core/models/basket/basket.model'; @Component({ selector: 'ish-basket-items-summary', templateUrl: './basket-items-summary.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) export class BasketItemsSummaryComponent { @Input({ required: true }) basket: BasketView; // visible-for-testing isCollapsed = true; private collapsedItemsCount = 3; toggleCollapse() { this.isCollapsed = !this.isCollapsed; } /** * the first (collapsedItemsCount) items are always visible, the other ones only if the summary list is expanded */ isItemVisible(index: number): boolean { return index < this.collapsedItemsCount || !this.isCollapsed; } /** * the show all link is visible if the list is collapsed and there are more items to show */ isShowAllLinkVisible(): boolean { return this.basket.lineItems.length > this.collapsedItemsCount && this.isCollapsed; } /** * the hide link is visible if the list is expanded and there are more items than collapsedItemsCount */ isHideLinkVisible(): boolean { return this.basket.lineItems.length > this.collapsedItemsCount && !this.isCollapsed; } } |