Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

4.8 KB
Raw Blame
<div class="modal-header">
  <h4 class="modal-title">
    @switch (inputType) {
      @case ('download') {
        <svg [lucideIcon]="icons.LucideGlobe"></svg>
      }
      @case ('directory') {
        <img [src]="directoryMimeUrl" class="me-2" alt="" draggable="false" height="26" width="26" />
      }
      @case ('file') {
        <img [src]="selectedDocumentMimeUrl()" class="me-2" alt="" draggable="false" height="26" width="26" />
      }
    }
    <span l10nTranslate>{{ fileProp.title }}</span>
  </h4>
  <button (click)="layout.closeDialog()" aria-label="Close" class="btn-close btn-close-white" type="button"></button>
</div>
<div class="modal-body">
  @if (inputType !== 'download') {
    <label class="form-label d-sm-none" for="new-file-type" l10nTranslate>Type</label>
    <select
      id="new-file-type"
      class="form-select d-sm-none mb-3"
      [ngModel]="inputType === 'directory' ? 'directory' : currentDocType()"
      (ngModelChange)="onSelectMobileType($event)">
      <option value="directory">{{ 'New folder' | translate: locale.language }}</option>
      <optgroup [label]="'Document' | translate: locale.language">
        @for (item of docTypes | keyvalue: originalOrderKeyValue; track item.key) {
          <option [value]="item.key">{{ item.key | translate: locale.language }}{{ item.value ? ' (.' + item.value + ')' : '' }}</option>
        }
      </optgroup>
    </select>
    <div class="mb-3 d-none d-sm-block" role="group" [attr.aria-label]="'New' | translate: locale.language">
      <div class="row g-2">
        <div class="col-12 col-sm-6">
          <button
            (click)="onSelectDirectory()"
            [attr.aria-pressed]="inputType === 'directory'"
            [class.active]="inputType === 'directory'"
            class="btn btn-default w-100 me-0 justify-content-start"
            type="button">
            <img [src]="directoryMimeUrl" alt="" draggable="false" height="24" width="24" />
            <span l10nTranslate>New folder</span>
          </button>
        </div>
      </div>

      <div class="text-muted text-uppercase text-bold fs-xs mt-3 mb-2" l10nTranslate>Document</div>
      <div class="row g-2">
        @for (item of docTypes | keyvalue: originalOrderKeyValue; track item.key) {
          <div class="col-12 col-sm-6">
            <button
              (click)="onSelectDocType(item.key)"
              [attr.aria-pressed]="isSelectedDocType(item.key)"
              [class.active]="isSelectedDocType(item.key)"
              class="btn btn-default w-100 me-0 justify-content-start"
              type="button">
              <img [src]="documentMimeUrl(item.value)" alt="" draggable="false" height="24" width="24" />
              <span l10nTranslate>{{ item.key }}</span>
              @if (item.value) {
                <span class="ms-auto fs-xs opacity-75">.{{ item.value }}</span>
              }
            </button>
          </div>
        }
      </div>
    </div>
  }
  @if (inputType === 'download') {
    <div class="input-group my-2">
      <span class="input-group-text">
        <svg [lucideIcon]="icons.LucideGlobe"></svg>
      </span>
      <input
        [(ngModel)]="downloadProp.url"
        (keydown.control.v)="pasteUrl()"
        (keydown.meta.v)="pasteUrl()"
        (keyup.enter)="onEnter()"
        [placeholder]="downloadProp.placeholder | translate: locale.language"
        class="form-control"
        type="text"
        appAutofocus
      />
    </div>
  }
  <div class="input-group my-2">
    <span class="input-group-text">
      @if (inputType === 'directory') {
        <img [src]="directoryMimeUrl" alt="" draggable="false" height="24" width="24" />
      } @else if (inputType === 'file') {
        <img [src]="selectedDocumentMimeUrl()" alt="" draggable="false" height="24" width="24" />
      } @else {
        <svg [lucideIcon]="icons.LucideFileText"></svg>
      }
    </span>
    <input
      #InputText
      [(ngModel)]="fileProp.name"
      (keyup.enter)="onEnter()"
      [placeholder]="fileProp.placeholder | translate: locale.language"
      class="form-control"
      type="text" />
  </div>
</div>
<div class="modal-footer">
  <div class="me-auto d-flex align-items-center gap-3">
    @if (canOpenAfterCreation()) {
      <div class="form-check mb-0 ps-0">
        <label class="form-check-label ps-1">
          <input [(ngModel)]="openAfterCreate" type="checkbox" />
          <span l10nTranslate>Open after creation</span>
        </label>
      </div>
    }
    @if (error) {
      <span class="fs-sm text-danger" l10nTranslate>{{ error }}</span>
    }
  </div>
  <button (click)="layout.closeDialog()" class="btn btn-secondary" data-dismiss="modal" type="button" l10nTranslate>Cancel</button>
  <button
    (click)="onSubmit()"
    [disabled]="!fileProp.name || (inputType === 'download' && !downloadProp.url) || submitted"
    class="btn btn-primary"
    type="button"
    l10nTranslate>
    Confirm
  </button>
</div>