<form #form (ngSubmit)="submit()" [appApiAction]="formPromise">
  <header>
    <div class="left">
      <button type="button" (click)="close()" *ngIf="openedAttachmentsInPopup">
        {{ "close" | i18n }}
      </button>
      <button type="button" (click)="back()" *ngIf="!openedAttachmentsInPopup">
        <span class="header-icon"><i class="bwi bwi-angle-left" aria-hidden="true"></i></span>
        <span>{{ "back" | i18n }}</span>
      </button>
    </div>
    <h1 class="center">
      <span class="title">{{ "attachments" | i18n }}</span>
    </h1>
    <div class="right">
      <button type="submit" [disabled]="form.loading">
        <span [hidden]="form.loading">{{ "save" | i18n }}</span>
        <i class="bwi bwi-spinner bwi-lg bwi-spin" [hidden]="!form.loading" aria-hidden="true"></i>
      </button>
    </div>
  </header>
  <main tabindex="-1">
    <div class="box" *ngIf="cipher && cipher.hasAttachments">
      <div class="box-content no-hover single-line">
        <div class="box-content-row box-content-row-flex" *ngFor="let a of cipher.attachments">
          <div class="row-main">
            {{ a.fileName }}
          </div>
          <small class="row-sub-label">{{ a.sizeName }}</small>
          <div class="action-buttons no-pad">
            <button
              type="button"
              class="row-btn btn"
              type="button"
              appStopClick
              appA11yTitle="{{ 'deleteAttachment' | i18n }}"
              (click)="delete(a)"
              #deleteBtn
              [appApiAction]="deletePromises[a.id]"
              [disabled]="$any(deleteBtn).loading"
            >
              <i
                class="bwi bwi-trash bwi-lg bwi-fw"
                [hidden]="$any(deleteBtn).loading"
                aria-hidden="true"
              ></i>
              <i
                class="bwi bwi-spinner bwi-spin bwi-lg bwi-fw"
                [hidden]="!$any(deleteBtn).loading"
                aria-hidden="true"
              ></i>
            </button>
          </div>
        </div>
      </div>
    </div>
    <div class="box">
      <h2 class="box-header">
        {{ "newAttachment" | i18n }}
      </h2>
      <div class="box-content no-hover">
        <div class="box-content-row">
          <label for="file">{{ "file" | i18n }}</label>
          <input type="file" id="file" name="file" aria-describedby="fileHelp" required />
        </div>
      </div>
      <div id="fileHelp" class="box-footer">
        {{ "maxFileSize" | i18n }}
      </div>
    </div>
  </main>
</form>
