All files / landing-page/explicit-legal-acknowledge si-explicit-legal-acknowledge.component.ts

100% Statements 15/15
100% Branches 0/0
100% Functions 6/6
100% Lines 14/14

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                                                                                                  1x       4x       4x                 4x 4x                   4x           4x       4x       4x       4x     1x       1x       4x       4x      
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import {
  Component,
  inject,
  input,
  OnInit,
  output,
  OnDestroy,
  ChangeDetectionStrategy
} from '@angular/core';
import { SiTranslatePipe, t, TranslatableString } from '@siemens/element-translate-ng/translate';
 
import { SiLandingPageComponent } from '../si-landing-page.component';
 
/**
 * A component for displaying legal agreements that require explicit user acknowledgment.
 *
 * This component provides a standardized interface for presenting legal documents,
 * terms of service, privacy policies, or other agreements that users must
 * explicitly accept before proceeding.
 *
 * @example
 * ```html
 * <si-explicit-legal-acknowledge
 *   [heading]="agreementTitle"
 *   [subheading]="agreementDescription"
 *   [disableAcceptance]="isProcessing"
 *   (accept)="handleAcceptance()"
 *   (back)="handleBack()">
 *   <div>
 *     <h3>Terms of Service</h3>
 *     <p>Please read and accept our terms before continuing.</p>
 *     <ul>
 *       <li>Term 1: You agree to ...</li>
 *       <li>Term 2: You acknowledge ...</li>
 *     </ul>
 *   </div>
 * </si-explicit-legal-acknowledge>
 * ```
 */
@Component({
  selector: 'si-explicit-legal-acknowledge',
  imports: [SiTranslatePipe],
  templateUrl: './si-explicit-legal-acknowledge.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class SiExplicitLegalAcknowledgeComponent implements OnInit, OnDestroy {
  /**
   * Heading of the agreement.
   */
  readonly heading = input.required<TranslatableString>();
  /**
   * Short description of the agreement.
   */
  readonly subheading = input.required<TranslatableString>();
  /**
   * Label for accept button.
   *
   * @defaultValue
   * ```
   * t(() => $localize`:@@SI_EXPLICIT_LEGAL_ACKNOWLEDGE.ACCEPT:Accept`)
   * ```
   */
  readonly acceptButtonLabel = input(
    t(() => $localize`:@@SI_EXPLICIT_LEGAL_ACKNOWLEDGE.ACCEPT:Accept`)
  );
  /**
   * Description of back button.
   *
   * @defaultValue
   * ```
   * t(() => $localize`:@@SI_EXPLICIT_LEGAL_ACKNOWLEDGE.BACK:Back`)
   * ```
   */
  readonly backButtonLabel = input(t(() => $localize`:@@SI_EXPLICIT_LEGAL_ACKNOWLEDGE.BACK:Back`));
  /**
   * Disables the acceptance button.
   *
   * @defaultValue false
   */
  readonly disableAcceptance = input(false);
  /**
   * Emits end user license agreement on acceptance event.
   */
  readonly accept = output<void>();
  /**
   * Emits on back click.
   */
  readonly back = output<void>();
  /**
   * Reference to the landing page parent component.
   */
  protected landingPage = inject(SiLandingPageComponent, { skipSelf: true, optional: true });
 
  protected handleBack(): void {
    this.back.emit();
  }
 
  protected handleAccept(): void {
    this.accept.emit();
  }
 
  ngOnInit(): void {
    this.landingPage?.isFullHeightSection.set(true);
  }
 
  ngOnDestroy(): void {
    this.landingPage?.isFullHeightSection.set(false);
  }
}