}
</script>
-{#each files as file, index (file.uuid_filename)}
- <!-- svelte-ignore a11y_no_static_element_interactions -->
- <div
- class="btn-group file mt-2 {dragOverIndex === index ? 'drag-over' : ''}"
- transition:slide
- draggable="false"
- ondragover={(e) => handleDragOver(e, index)}
- ondragleave={handleDragLeave}
- ondrop={(e) => handleDrop(e, index)}
- >
- <!-- svelte-ignore a11y_no_static_element_interactions -->
- {#if editable && files.length > 1}
- <div
- class="drag-handle d-flex align-items-center px-2"
- draggable="true"
- ondragstart={(e) => {
- e.stopPropagation();
- handleDragStart(e, index);
- }}
- ondragend={(e) => {
- e.stopPropagation();
- handleDragEnd(e);
- }}
- >
- <Fa icon={faGripVertical} class="text-muted" />
- </div>
- {/if}
- <button
- onclick={() => downloadFile(file.uuid_filename)}
- class="p-2 fileBtn d-flex flex-column flex-fill"
- >
- <div class="d-flex flex-row align-items-center">
- <div class="filename filenameWeight">{file.filename}</div>
- <span class="filesize">({formatBytes(file.size)})</span>
- </div>
- {#if file.downloadProgress >= 0}
+{#if files.length > 0}
+ <div class="file-list">
+ {#each files as file, index (file.uuid_filename)}
+ <div class="file-row" transition:slide|global>
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
<div
- class="progress"
- role="progressbar"
- aria-label="Download progress"
- aria-valuemin="0"
- aria-valuemax="100"
+ class="btn-group file {dragOverIndex === index ? 'drag-over' : ''}"
+ draggable="false"
+ ondragover={(e) => handleDragOver(e, index)}
+ ondragleave={handleDragLeave}
+ ondrop={(e) => handleDrop(e, index)}
>
- <div
- class="progress-bar overflow-visible bg-info {file.downloadProgress === 0
- ? 'progress-bar-striped progress-bar-animated'
- : ''}"
- style:width={file.downloadProgress + '%'}
- aria-valuenow={file.downloadProgress}
- aria-valuemax="100"
+ {#if editable && files.length > 1}
+ <div
+ class="drag-handle d-flex align-items-center px-2"
+ draggable="true"
+ ondragstart={(e) => {
+ e.stopPropagation();
+ handleDragStart(e, index);
+ }}
+ ondragend={(e) => {
+ e.stopPropagation();
+ handleDragEnd(e);
+ }}
+ >
+ <Fa icon={faGripVertical} class="text-muted" />
+ </div>
+ {/if}
+ <button
+ onclick={() => downloadFile(file.uuid_filename)}
+ class="p-2 fileBtn d-flex flex-column flex-fill"
>
- {#if file.downloadProgress === 0}
- <span class="text-dark">
- {$t('files.decrypting')}
- </span>
- {:else}
- <span class="text-dark">{$t('files.download')}: {file.downloadProgress}%</span>
+ <div class="d-flex flex-row align-items-center">
+ <div class="filename filenameWeight">{file.filename}</div>
+ <span class="filesize">({formatBytes(file.size)})</span>
+ </div>
+ {#if file.downloadProgress >= 0}
+ <div
+ class="progress"
+ role="progressbar"
+ aria-label="Download progress"
+ aria-valuemin="0"
+ aria-valuemax="100"
+ >
+ <div
+ class="progress-bar overflow-visible bg-info {file.downloadProgress === 0
+ ? 'progress-bar-striped progress-bar-animated'
+ : ''}"
+ style:width={file.downloadProgress + '%'}
+ aria-valuenow={file.downloadProgress}
+ aria-valuemax="100"
+ >
+ {#if file.downloadProgress === 0}
+ <span class="text-dark">{$t('files.decrypting')}</span>
+ {:else}
+ <span class="text-dark">{$t('files.download')}: {file.downloadProgress}%</span>
+ {/if}
+ </div>
+ </div>
{/if}
- </div>
+ </button>
+ {#if editable}
+ <button
+ class="p-2 fileBtn optionsBtn"
+ onclick={() => {
+ if (openOptionsMenu === file.uuid_filename) {
+ openOptionsMenu = null;
+ editingFilename = null;
+ } else {
+ openOptionsMenu = file.uuid_filename;
+ editingFilename = null;
+ }
+ }}
+ >
+ <Fa icon={faWrench} fw />
+ </button>
+ {/if}
</div>
- {/if}
- </button>
- {#if editable}
- <button
- class="p-2 fileBtn optionsBtn"
- onclick={() => {
- if (openOptionsMenu === file.uuid_filename) {
- openOptionsMenu = null;
- editingFilename = null;
- } else {
- openOptionsMenu = file.uuid_filename;
- editingFilename = null;
- }
- }}
- >
- <Fa icon={faWrench} fw />
- </button>
- {/if}
- </div>
+ </div>
- {#if editable && openOptionsMenu === file.uuid_filename}
- <div transition:slide>
- <div class="options-menu p-3 mt-1">
- <div class="mb-3">
- <!-- svelte-ignore a11y_label_has_associated_control -->
- <label class="form-label small fw-bold">{$t('fileList.change_filename')}:</label>
- <div class="d-flex gap-2">
- {#if editingFilename === file.uuid_filename}
- <input
- type="text"
- class="form-control form-control-sm"
- id="newFilename-{file.uuid_filename}"
- bind:value={newFilename}
- onkeydown={(e) => {
- if (e.key === 'Enter') {
- if (renameFile) {
- renameFile(file.uuid_filename, newFilename);
+ {#if editable && openOptionsMenu === file.uuid_filename}
+ <div in:slide|global out:slide|global>
+ <div class="card options-menu p-3 mt-1">
+ <!-- svelte-ignore a11y_label_has_associated_control -->
+ <label class="form-label small fw-bold">{$t('fileList.change_filename')}:</label>
+ <div class="d-flex gap-2">
+ {#if editingFilename === file.uuid_filename}
+ <input
+ type="text"
+ class="form-control form-control-sm"
+ id="newFilename-{file.uuid_filename}"
+ bind:value={newFilename}
+ onkeydown={(e) => {
+ if (e.key === 'Enter') {
+ if (renameFile) renameFile(file.uuid_filename, newFilename);
+ editingFilename = null;
+ openOptionsMenu = null;
+ } else if (e.key === 'Escape') {
+ editingFilename = null;
}
+ }}
+ />
+ <button
+ class="btn btn-sm btn-success"
+ onclick={() => {
+ if (renameFile) renameFile(file.uuid_filename, newFilename);
editingFilename = null;
openOptionsMenu = null;
- } else if (e.key === 'Escape') {
+ }}
+ >
+ <Fa icon={faSave} fw />
+ </button>
+ <button
+ class="btn btn-sm btn-secondary"
+ onclick={() => {
editingFilename = null;
- }
- }}
- />
+ }}
+ >
+ <Fa icon={faTimes} fw />
+ </button>
+ {:else}
+ <input
+ type="text"
+ class="form-control form-control-sm"
+ value={file.filename}
+ disabled
+ />
+ <button
+ class="btn btn-sm btn-primary"
+ onclick={() => {
+ editingFilename = file.uuid_filename;
+ newFilename = file.filename;
+ }}
+ >
+ <Fa icon={faEdit} fw />
+ </button>
+ {/if}
+ </div>
+ <hr style="color: black;" />
+ <div>
<button
- class="btn btn-sm btn-success"
+ class="btn btn-sm btn-danger w-100"
onclick={() => {
- if (renameFile) {
- renameFile(file.uuid_filename, newFilename);
- }
- editingFilename = null;
+ askDeleteFile(file.uuid_filename, file.filename);
openOptionsMenu = null;
}}
>
- <Fa icon={faSave} fw />
+ <Fa icon={faTrash} fw class="me-2" />
+ {$t('fileList.delete_file')}
</button>
- <button
- class="btn btn-sm btn-secondary"
- onclick={() => {
- editingFilename = null;
- }}
- >
- <Fa icon={faTimes} fw />
- </button>
- {:else}
- <input
- type="text"
- class="form-control form-control-sm"
- value={file.filename}
- disabled
- />
- <button
- class="btn btn-sm btn-primary"
- onclick={() => {
- editingFilename = file.uuid_filename;
- newFilename = file.filename;
- }}
- >
- <Fa icon={faEdit} fw />
- </button>
- {/if}
+ </div>
</div>
</div>
-
- <hr style="color: black;" />
-
- <div>
- <button
- class="btn btn-sm btn-danger w-100"
- onclick={() => {
- askDeleteFile(file.uuid_filename, file.filename);
- openOptionsMenu = null;
- }}
- >
- <Fa icon={faTrash} fw class="me-2" />
- {$t('fileList.delete_file')}
- </button>
- </div>
- </div>
- </div>
- {/if}
-{/each}
+ {/if}
+ {/each}
+ </div>
+{/if}
<style>
.filename {
}
.options-menu {
- background-color: rgba(248, 249, 250, 0.95);
border: 1px solid rgba(0, 0, 0, 0.125);
border-radius: 5px;
backdrop-filter: blur(5px);
border: 2px dashed #007bff;
background-color: rgba(0, 123, 255, 0.1);
}
+
+ .file-list {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ }
</style>