From 41efbe26e99d4cc9ad2822d8751f894328de0912 Mon Sep 17 00:00:00 2001 From: DevX32 Date: Sat, 12 Oct 2024 18:02:25 +0545 Subject: [PATCH] fix: menu duplication --- web/src/components/menu/Outfits.svelte | 96 ++++++++++++++------------ 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/web/src/components/menu/Outfits.svelte b/web/src/components/menu/Outfits.svelte index 5e287ed..8165ebe 100644 --- a/web/src/components/menu/Outfits.svelte +++ b/web/src/components/menu/Outfits.svelte @@ -9,22 +9,59 @@ import IconPlus from '@components/icons/IconPlus.svelte'; import IconImport from '@components/icons/IconImport.svelte'; - let renameIndex: number = -1; let renameLabel: string = ''; - let deleteIndex: number = -1; - let isAdding: boolean = false; let isJobAdding: boolean = false; let isImporting: boolean = false; let newOutfitLabel: string = ''; let newOutfitJobRank: number = 0; let importOutfitId: number; + + const handleRename = (index: number) => { + if (renameLabel.length > 0) { + $OUTFITS[index].label = renameLabel; + renameIndex = -1; + OUTFITS.edit($OUTFITS[index]); + } + }; + + const handleOutfitAction = ( + action: string, + index: number, + outfit = null, + ) => { + switch (action) { + case 'use': + OUTFITS.use(outfit); + break; + case 'share': + OUTFITS.share(index); + break; + case 'item': + OUTFITS.item(outfit, renameLabel); + break; + case 'delete': + OUTFITS.delete(index); + break; + } + }; + + const resetNewOutfitFields = () => { + isAdding = false; + isJobAdding = false; + newOutfitLabel = ''; + newOutfitJobRank = 0; + }; + + const resetImportFields = () => { + isImporting = false; + importOutfitId = null; + }; {#each $OUTFITS as { label, outfit, id, jobname }, i} - @@ -32,9 +69,7 @@ class="w-full flex items-center justify-center gap-[0.5vh] h-[3vh]" > {/if} - handleOutfitAction('delete', id)} + >{$LOCALE.CONFIRMREM_SUBTITLE} {/if} - {:else} @@ -157,17 +179,11 @@ /> {/if} - @@ -258,7 +266,6 @@
-

{$LOCALE.ADDJOBOUTFIT}

{/if} @@ -273,7 +280,6 @@
-

{$LOCALE.IMPORTOUTFIT_TITLE}

{/if}