mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-14 22:08:45 +00:00
카테고리 페이지에서, 하위 카테고리에만 등록된 파일인 경우 삭제 버튼을 표시하지 않도록 변경
This commit is contained in:
@@ -30,13 +30,16 @@
|
|||||||
isFileRecursive = $bindable(),
|
isFileRecursive = $bindable(),
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
let files: Writable<FileInfo | null>[] = $state([]);
|
let files: { info: Writable<FileInfo | null>; isRecursive: boolean }[] = $state([]);
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
files =
|
files =
|
||||||
info.files
|
info.files
|
||||||
?.filter(({ isRecursive }) => isFileRecursive || !isRecursive)
|
?.filter(({ isRecursive }) => isFileRecursive || !isRecursive)
|
||||||
.map(({ id }) => getFileInfo(id, $masterKeyStore?.get(1)?.key!)) ?? [];
|
.map(({ id, isRecursive }) => ({
|
||||||
|
info: getFileInfo(id, $masterKeyStore?.get(1)?.key!),
|
||||||
|
isRecursive,
|
||||||
|
})) ?? [];
|
||||||
|
|
||||||
// TODO: Sorting
|
// TODO: Sorting
|
||||||
});
|
});
|
||||||
@@ -65,10 +68,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
{#key info}
|
{#key info}
|
||||||
{#each files as file}
|
{#each files as { info, isRecursive }}
|
||||||
<File info={file} onclick={onFileClick} onRemoveClick={onFileRemoveClick} />
|
<File
|
||||||
|
{info}
|
||||||
|
onclick={onFileClick}
|
||||||
|
onRemoveClick={!isRecursive ? onFileRemoveClick : undefined}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<p>이 카테고리에 추가된 파일이 없어요.</p>
|
<p class="text-gray-500 text-center">이 카테고리에 추가된 파일이 없어요.</p>
|
||||||
{/each}
|
{/each}
|
||||||
{/key}
|
{/key}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
interface Props {
|
interface Props {
|
||||||
info: Writable<FileInfo | null>;
|
info: Writable<FileInfo | null>;
|
||||||
onclick: (selectedFile: SelectedFile) => void;
|
onclick: (selectedFile: SelectedFile) => void;
|
||||||
onRemoveClick: (selectedFile: SelectedFile) => void;
|
onRemoveClick?: (selectedFile: SelectedFile) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { info, onclick, onRemoveClick }: Props = $props();
|
let { info, onclick, onRemoveClick }: Props = $props();
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
if (!dataKey || !dataKeyVersion) return; // TODO: Error handling
|
if (!dataKey || !dataKeyVersion) return; // TODO: Error handling
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
onRemoveClick({ id, dataKey, dataKeyVersion, name });
|
onRemoveClick!({ id, dataKey, dataKeyVersion, name });
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -46,13 +46,15 @@
|
|||||||
<p title={$info.name} class="flex-grow truncate font-medium">
|
<p title={$info.name} class="flex-grow truncate font-medium">
|
||||||
{$info.name}
|
{$info.name}
|
||||||
</p>
|
</p>
|
||||||
<button
|
{#if onRemoveClick}
|
||||||
id="remove-file"
|
<button
|
||||||
onclick={removeFile}
|
id="remove-file"
|
||||||
class="flex-shrink-0 rounded-full p-1 active:bg-gray-100"
|
onclick={removeFile}
|
||||||
>
|
class="flex-shrink-0 rounded-full p-1 active:bg-gray-100"
|
||||||
<IconClose class="text-lg" />
|
>
|
||||||
</button>
|
<IconClose class="text-lg" />
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user