1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2025-12-23 23:02:58 +00:00

Merge pull request #58 from koloml/feature/moving-delete-action-and-confirmation

Added confirmation for profile deletion, moved "delete" button to the profile view instead of the editor
This commit is contained in:
2024-11-26 03:11:36 +04:00
committed by GitHub
5 changed files with 49 additions and 13 deletions

1
src/app.d.ts vendored
View File

@@ -17,6 +17,7 @@ declare global {
| "globe"
| "plus"
| "file-export"
| "trash"
);
}
}

View File

@@ -57,6 +57,9 @@
<MenuItem icon="file-export" href="/features/maintenance/{profileId}/export">
Export Profile
</MenuItem>
<MenuItem icon="trash" href="/features/maintenance/{profileId}/delete">
Delete Profile
</MenuItem>
</Menu>
<style lang="scss">

View File

@@ -0,0 +1,41 @@
<script>
import { goto } from "$app/navigation";
import Menu from "$components/ui/menu/Menu.svelte";
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import { page } from "$app/stores";
import { maintenanceProfilesStore } from "$stores/maintenance-profiles-store.js";
const profileId = $page.params.id;
const targetProfile = $maintenanceProfilesStore.find(profile => profile.id===profileId);
if (!targetProfile) {
void goto('/features/maintenance');
}
async function deleteProfile() {
if (!targetProfile) {
console.warn('Attempting to delete the profile, but the profile is not loaded yet.');
return;
}
await targetProfile.delete();
await goto('/features/maintenance');
}
</script>
<Menu>
<MenuItem icon="arrow-left" href="/features/maintenance/{profileId}">Back</MenuItem>
<hr>
</Menu>
{#if targetProfile}
<p>
Do you want to remove profile "{targetProfile.settings.name}"? This action is irreversible.
</p>
<Menu>
<hr>
<MenuItem on:click={deleteProfile}>Yes</MenuItem>
<MenuItem href="/features/maintenance/{profileId}">No</MenuItem>
</Menu>
{:else}
<p>Loading...</p>
{/if}

View File

@@ -46,16 +46,6 @@
await targetProfile.save();
await goto('/features/maintenance/' + targetProfile.id);
}
async function deleteProfile() {
if (!targetProfile) {
console.warn('Attempting to delete the profile, but the profile is not loaded yet.');
return;
}
await targetProfile.delete();
await goto('/features/maintenance');
}
</script>
<Menu>
@@ -75,7 +65,4 @@
<Menu>
<hr>
<MenuItem href="#" on:click={saveProfile}>Save Profile</MenuItem>
{#if profileId !== 'new'}
<MenuItem href="#" on:click={deleteProfile}>Delete Profile</MenuItem>
{/if}
</Menu>

View File

@@ -41,3 +41,7 @@
.icon.icon-file-export {
@include insert-icon(url('@fortawesome/fontawesome-free/svgs/solid/file-export.svg'));
}
.icon.icon-trash {
@include insert-icon(url('@fortawesome/fontawesome-free/svgs/solid/trash.svg'));
}