From d12c83da5f32960ce1d4f7d285b7e3eb82314be0 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Tue, 22 Feb 2022 00:26:33 +0100 Subject: [PATCH] feat: add delete option from row menu --- src/view/FileList.svelte | 45 ++++++++++++++++++++++++++++-------- src/view/FileListCell.svelte | 7 +++++- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/view/FileList.svelte b/src/view/FileList.svelte index 4c94208..b8ff791 100644 --- a/src/view/FileList.svelte +++ b/src/view/FileList.svelte @@ -47,9 +47,10 @@ let newFolderModal = false; let newFolder = ""; let deleteSelectedModal = false; + let deleteModal = false; let renameModal = false; let renameValue = ""; - let renameInode: Inode; + let menuInode: Inode; $: { listFiles(path); @@ -86,10 +87,13 @@ async function renameFile() { renameModal = false; - await fs.moveFile( - renameInode.path, - parent(renameInode.path) + renameValue - ); + await fs.moveFile(menuInode.path, parent(menuInode.path) + renameValue); + fileListUpdateIncr(); + } + + async function deleteFile() { + deleteModal = false; + await fs.deleteFile(menuInode.path); fileListUpdateIncr(); } @@ -196,11 +200,18 @@ - { - renameInode = row.inode; - renameValue = renameInode.basename; - renameModal = true; - }} /> + (menuInode = row.inode)} + on:click-rename={() => { + renameValue = menuInode.basename; + renameModal = true; + }} + on:click-delete={() => { + deleteModal = true; + }} + /> {:else} @@ -246,6 +257,20 @@

Are you sure you want to delete {checked.length} files?

+ (deleteModal = false)} + on:submit={deleteFile} +> +

Are you sure you want to delete the file {menuInode?.basename}?

+
+ diff --git a/src/view/FileListCell.svelte b/src/view/FileListCell.svelte index 7a25d10..79911ec 100644 --- a/src/view/FileListCell.svelte +++ b/src/view/FileListCell.svelte @@ -15,11 +15,16 @@ {#if cell.key === "menu"} - + dispatch("click-menu")}> dispatch("click-rename")} /> + dispatch("click-delete")} + /> {:else}