Skip to content
Snippets Groups Projects
Select Git revision
  • 6166ace983f58368e358391b0d2a2e198789e607
  • main default protected
  • OZG-6978-prevent-other-pages-from-being-called
  • OZG-8378-ods-heading
  • OZG-7986-mandat-anfragen
  • optimize-storybook
  • OZG-8405-Alfa-Bearbeiter-auswählen-und-entfernen-Design
  • OZG-8314-Alfa-Vorgang-Bearbeiter-Zuweisung-entfernen
  • testing-imports
  • storybook-improvements
  • OZG-7287-forward-saml-token
  • release-administration
  • OZG-8422-BenutzerSpeichern
  • release-info
  • release
  • OZG-7856_schadcode-scanner-e2e
  • OZG-7985-fix-sorting
  • OZG-8305-Create-webpack-sbom
  • tooltip-improvements
  • OZG-7714-UpgradeKeycloakDependencyTo25
  • OZG-8086-Admin-Datenanfrage-erstellen
  • 1.12.1-administration
  • 1.12.0-administration
  • 1.12.0-info
  • 2.27.0-alfa
  • 1.11.0-info
  • 1.11.0-administration
  • 2.26.0-alfa
  • 1.10.0-info
  • 1.10.0-administration
  • 2.25.0-alfa
  • 1.9.0-info
  • 1.9.0-administration
  • 2.24.0-alfa
  • 1.8.0-info
  • 1.8.0-administration
  • 2.23.0-alfa
  • 1.7.0-info
  • 1.7.0-administration
  • 2.22.0-alfa
  • 1.6.0-info
41 results

attachment.component.ts

Blame
  • user avatar
    OZGCloud authored
    6166ace9
    History
    attachment.component.ts 2.28 KiB
    import { CommonModule } from '@angular/common';
    import { Component, Input } from '@angular/core';
    
    import { ApiError, EMPTY_STRING, Issue, getMessageForIssue } from '@alfa-client/tech-shared';
    import { isNil } from 'lodash-es';
    import { FileIconComponent } from '../icons/file-icon/file-icon.component';
    import { SpinnerIconComponent } from '../icons/spinner-icon/spinner-icon.component';
    
    @Component({
      selector: 'ods-attachment',
      standalone: true,
      imports: [CommonModule, SpinnerIconComponent, FileIconComponent],
      styles: [':host {@apply flex}'],
      template: `<button
        class="relative flex w-full items-start gap-3 border-b border-b-grayborder bg-background-100 px-3 py-2 hover:bg-background-200"
      >
        <div class="flex-shrink">
          <ods-file-icon
            *ngIf="fileType && !isLoading && !isError"
            [fileType]="fileType"
            size="large"
          />
          <ods-file-icon *ngIf="!isLoading && isError" fileType="exclamation" size="large" />
          <ods-spinner-icon *ngIf="isLoading && !isError" size="large" />
        </div>
        <div class="flex grow flex-col items-start break-all text-start text-text">
          <p *ngIf="!isError && !isLoading && caption" class="text-sm">
            {{ caption }}
          </p>
          <p *ngIf="isError && errorCaption" class="text-sm text-error">
            {{ errorCaption }}
          </p>
          <p *ngIf="isLoading && loadingCaption" class="text-sm">
            {{ loadingCaption }}
          </p>
          <p *ngIf="description && !isError" class="text-xs text-text/65">
            {{ description }}
          </p>
          <p *ngFor="let error of errorList" class="text-xs text-text/65">
            {{ error }}
          </p>
        </div>
        <ng-content select="[close]" *ngIf="!isLoading"></ng-content>
      </button>`,
    })
    export class AttachmentComponent {
      @Input() caption: string = '';
      @Input() errorCaption: string = '';
      @Input() loadingCaption: string = '';
      @Input() fileType: string = '';
      @Input() description = '';
      @Input() isLoading: boolean = false;
      @Input() set error(error: ApiError) {
        if (isNil(error)) {
          this.errorList = [];
          return;
        }
        error.issues.forEach((issue: Issue) =>
          this.errorList.push(getMessageForIssue(EMPTY_STRING, issue)),
        );
      }
    
      protected get isError() {
        return this.errorList.length > 0;
      }
    
      public errorList: string[] = [];
    }