All files / dashboard/widgets/si-timeline-widget si-timeline-widget.component.ts

100% Statements 11/11
50% Branches 1/2
100% Functions 1/1
100% Lines 11/11

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                                                        1x             6x           6x           6x           6x             6x             6x       6x   6x 6x 6x      
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import { NgClass } from '@angular/common';
import { Component, computed, input, OnChanges } from '@angular/core';
import { SiCardComponent } from '@siemens/element-ng/card';
import { AccentLineType, MenuItem as MenuItemLegacy } from '@siemens/element-ng/common';
import { ContentActionBarMainItem } from '@siemens/element-ng/content-action-bar';
import { Link, SiLinkDirective } from '@siemens/element-ng/link';
import { MenuItem } from '@siemens/element-ng/menu';
import { SiTranslateModule, TranslatableString } from '@siemens/element-translate-ng/translate';
 
import { SiWidgetBaseComponent } from '../si-widget-base.component';
import { SiTimelineWidgetBodyComponent } from './si-timeline-widget-body.component';
import { SiTimelineWidgetItem } from './si-timeline-widget-item.component';
 
@Component({
  selector: 'si-timeline-widget',
  imports: [
    NgClass,
    SiLinkDirective,
    SiCardComponent,
    SiTranslateModule,
    SiTimelineWidgetBodyComponent
  ],
  templateUrl: './si-timeline-widget.component.html'
})
export class SiTimelineWidgetComponent
  extends SiWidgetBaseComponent<SiTimelineWidgetItem[]>
  implements OnChanges
{
  /**
   * Timeline widget header text.
   */
  readonly heading = input<TranslatableString>();
  /**
   * Input list of primary action items. Supports up to **4** actions and omits additional ones.
   *
   * @defaultValue []
   */
  readonly primaryActions = input<(MenuItemLegacy | ContentActionBarMainItem)[]>([]);
  /**
   * Input list of secondary action items.
   *
   * @defaultValue []
   */
  readonly secondaryActions = input<(MenuItemLegacy | MenuItem)[]>([]);
  /**
   * Link that leads the user to more information
   * or triggers and action. The `link.title` is displayed.
   * The title will be translated.
   */
  readonly link = input<Link>();
 
  /**
   * Number of skeleton progress indication items.
   *
   * @defaultValue 4
   */
  readonly numberOfItems = input(4);
 
  /**
   * Whether to show or hide the description row during skeleton progress indication.
   *
   * @defaultValue `true`
   */
  readonly showDescription = input(true);
  /**
   * Optional accent line
   */
  readonly accentLine = input<AccentLineType>();
 
  protected readonly accentClass = computed(() => {
    const accentLine = this.accentLine();
    return accentLine ? 'accent-' + accentLine : '';
  });
}