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 | 1x 35x 35x 35x 35x 35x 35x 35x 35x 35x 41x 35x 35x 55x 35x 17x 8x 8x 9x 35x 19x 10x 10x 9x 35x 55x 2x 55x 42x 10x 32x 13x 6x 7x 7x 3x 4x 35x 10x 35x 3x 2x 35x 2x 2x 35x 35x 35x 35x 35x 35x 9x 3x 18x 18x | /** * Copyright (c) Siemens 2016 - 2025 * SPDX-License-Identifier: MIT */ import { booleanAttribute, Component, computed, ElementRef, inject, input, OnDestroy, output, signal } from '@angular/core'; import { SiCardComponent } from '@siemens/element-ng/card'; import { MenuItem } from '@siemens/element-ng/common'; import { ContentActionBarMainItem, SiContentActionBarComponent } from '@siemens/element-ng/content-action-bar'; import { SiTranslateModule, t } from '@siemens/element-translate-ng/translate'; import { SiDashboardService } from './si-dashboard.service'; @Component({ selector: 'si-dashboard-card', imports: [SiContentActionBarComponent, SiTranslateModule], templateUrl: './si-dashboard-card.component.html', styleUrl: './si-dashboard-card.component.scss', host: { '[class.elevation-2]': 'isExpanded()', '[class.expanded]': 'isExpanded()', '[class.d-none]': 'hide' } }) export class SiDashboardCardComponent extends SiCardComponent implements OnDestroy { /** * Description of cancel button & action. * * @defaultValue * ``` * t(() => $localize`:@@SI_DASHBOARD.RESTORE:Restore`) * ``` */ readonly restoreText = input(t(() => $localize`:@@SI_DASHBOARD.RESTORE:Restore`)); /** * Description of expand button & action. * * @defaultValue * ``` * t(() => $localize`:@@SI_DASHBOARD.EXPAND:Expand`) * ``` */ readonly expandText = input(t(() => $localize`:@@SI_DASHBOARD.EXPAND:Expand`)); /** * Option to enable and show the UI controls for card expand functionality. * `Expand` and `restore` action items will be added to the content action bar. * The expand resizing has to be implemented by the container of the card. * * @defaultValue false */ readonly enableExpandInteraction = input(false, { transform: booleanAttribute }); /** * Used in combination with si-dashboard to show filters when a card is expanded or not. * * @defaultValue true */ readonly showMenubar = input(true, { transform: booleanAttribute }); /** * Emitter for size state change */ readonly expandChange = output<boolean>(); /** * Whether the card is currently expanded. * * @defaultValue false */ readonly isExpanded = signal(false); /** @internal */ hide = false; /** @internal */ readonly enableExpandInteractionInternal = signal(false); readonly enableExpandInteractionComputed = computed( () => this.enableExpandInteraction() || this.enableExpandInteractionInternal() ); /** @internal */ element = inject(ElementRef); override readonly displayContentActionBar = computed( () => this.primaryActionsComputed()?.length > 0 || this.secondaryActions()?.length > 0 ); protected readonly actionBarViewTypeComputed = computed(() => { if (!this.hasContentBarActions()) { if (this.enableExpandInteractionComputed()) { return 'expanded'; } else E{ return this.actionBarViewType(); } } else { return this.actionBarViewType(); } }); protected readonly actionBarTitleComputed = computed(() => { if (!this.hasContentBarActions()) { if (this.enableExpandInteractionComputed()) { return this.expandRestoreIconTooltip(); } else E{ return this.actionBarTitle(); } } else { return this.actionBarTitle(); } }); protected readonly primaryActionsComputed = computed<(ContentActionBarMainItem | MenuItem)[]>( () => { const expandRestoreButtonActions: ContentActionBarMainItem[] = [ { type: 'action', label: this.isExpanded() ? this.restoreText() : this.expandText(), icon: this.isExpanded() ? 'element-pinch' : 'element-zoom', iconOnly: true, action: () => this.expandCard(!this.isExpanded()) } ]; if (!this.hasContentBarActions()) { if (this.enableExpandInteractionComputed()) { return expandRestoreButtonActions; } else { return []; } } else { if (!this.enableExpandInteractionComputed()) { return this.primaryActions(); } else { const action = this.isExpanded() ? this.restoreActionItem() : this.expandActionItem(); if (this.primaryActions() && this.primaryActions().length > 0) { return [...this.primaryActions(), action]; } else { return [action]; } } } } ); private readonly expandRestoreIconTooltip = computed(() => { return this.isExpanded() ? this.restoreText() : this.expandText(); }); private readonly expandActionItem = computed(() => { return { type: 'action', label: this.expandText(), icon: 'element-zoom', iconOnly: true, action: () => this.expandCard(true) } as ContentActionBarMainItem; }); private readonly restoreActionItem = computed(() => { return { type: 'action', label: this.restoreText(), icon: 'element-pinch', iconOnly: true, action: () => this.expandCard(false) } as ContentActionBarMainItem; }); private readonly hasContentBarActions = computed(() => { return this.primaryActions()?.length > 0 || this.secondaryActions()?.length > 0; }); private dashboardService = inject(SiDashboardService, { optional: true }); constructor() { super(); this.dashboardService?.register(this); } ngOnDestroy(): void { this.dashboardService?.unregister(this); } /** * Expand the dashboard card. */ expand(): void { this.expandCard(true); } /** * Restore the dashboard card to the original, non-expanded state. */ restore(): void { this.expandCard(false); } private expandCard(expand: boolean): void { this.isExpanded.set(expand); this.expandChange.emit(expand); } } |