All files / copyright-notice si-copyright-notice.component.ts

100% Statements 13/13
100% Branches 10/10
100% Functions 4/4
100% Lines 13/13

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                            1x 22x                 22x   22x 22x 22x 22x     22x 22x     22x   22x     22x 22x      
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';
 
import { CopyrightDetails, SI_COPYRIGHT_DETAILS } from './si-copyright-notice';
 
@Component({
  selector: 'si-copyright-notice',
  templateUrl: './si-copyright-notice.component.html',
  styleUrl: './si-copyright-notice.component.scss',
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class SiCopyrightNoticeComponent {
  private globalCopyrightInfo: CopyrightDetails | null = inject(SI_COPYRIGHT_DETAILS, {
    optional: true
  });
  /**
   * Copyright information to be displayed.
   *
   * Note: The {@link CopyrightDetails#company} defaults to `Sample Company`,
   * only set it for other companies.
   */
  readonly copyright = input<CopyrightDetails>();
 
  protected readonly copyrightInfo = computed(() => {
    const lastYear = this.lastUpdateYear();
    const to = lastYear ? `-${lastYear}` : '';
    return `${this.startYear()}${to}`;
  });
 
  protected readonly company = computed(
    () => this.copyright()?.company ?? this.globalCopyrightInfo?.company
  );
 
  protected readonly startYear = computed(
    () =>
      this.copyright()?.startYear ?? this.globalCopyrightInfo?.startYear ?? new Date().getFullYear()
  );
 
  protected readonly lastUpdateYear = computed(
    () => this.copyright()?.lastUpdateYear ?? this.globalCopyrightInfo?.lastUpdateYear ?? undefined
  );
}