mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-23 14:59:36 +02:00
Fix general category handling
This commit is contained in:
parent
ce0b82acb7
commit
adf45ff557
16 changed files with 192 additions and 126 deletions
|
@ -130,7 +130,7 @@
|
|||
</div>
|
||||
<div>
|
||||
<div class="badge badge-primary">
|
||||
{`${adventure.category.display_name} ${adventure.category.icon}`}
|
||||
{adventure.category?.display_name + ' ' + adventure.category?.icon}
|
||||
</div>
|
||||
<div class="badge badge-success">
|
||||
{adventure.is_visited ? $t('adventures.visited') : $t('adventures.planned')}
|
||||
|
|
|
@ -31,13 +31,6 @@
|
|||
selectCategory(new_category);
|
||||
}
|
||||
|
||||
// function removeCategory(categoryName: string) {
|
||||
// categories = categories.filter((category) => category.name !== categoryName);
|
||||
// if (selected_category && selected_category.name === categoryName) {
|
||||
// selected_category = null;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Close dropdown when clicking outside
|
||||
let dropdownRef: HTMLDivElement;
|
||||
|
||||
|
@ -59,7 +52,7 @@
|
|||
<button type="button" class="btn btn-outline w-full text-left" on:click={toggleDropdown}>
|
||||
{selected_category && selected_category.name
|
||||
? selected_category.display_name + ' ' + selected_category.icon
|
||||
: 'Select Category'}
|
||||
: $t('categories.select_category')}
|
||||
</button>
|
||||
|
||||
{#if isOpen}
|
||||
|
@ -69,13 +62,13 @@
|
|||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Category Name"
|
||||
placeholder={$t('categories.category_name')}
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
bind:value={new_category.display_name}
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Icon"
|
||||
placeholder={$t('categories.icon')}
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
bind:value={new_category.icon}
|
||||
/>
|
||||
|
@ -93,13 +86,6 @@
|
|||
on:click={() => selectCategory(category)}
|
||||
>
|
||||
<span>{category.display_name} {category.icon} ({category.num_adventures})</span>
|
||||
<!-- <button
|
||||
type="button"
|
||||
class="btn btn-xs btn-error"
|
||||
on:click|stopPropagation={() => removeCategory(category.name)}
|
||||
>
|
||||
{$t('adventures.remove')}
|
||||
</button> -->
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
let category_fetch = await fetch('/api/categories/categories');
|
||||
categories = await category_fetch.json();
|
||||
// remove the general category if it exists
|
||||
categories = categories.filter((c) => c.name !== 'general');
|
||||
// categories = categories.filter((c) => c.name !== 'general');
|
||||
});
|
||||
|
||||
async function saveCategory() {
|
||||
|
@ -73,7 +73,7 @@
|
|||
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||
<div class="modal-box" role="dialog" on:keydown={handleKeydown} tabindex="0">
|
||||
<h3 class="font-bold text-lg">Manage Categories</h3>
|
||||
<h3 class="font-bold text-lg">{$t('categories.manage_categories')}</h3>
|
||||
|
||||
{#each categories as category}
|
||||
<div class="flex justify-between items-center mt-2">
|
||||
|
@ -82,32 +82,36 @@
|
|||
<button on:click={() => (category_to_edit = category)} class="btn btn-primary btn-sm"
|
||||
>Edit</button
|
||||
>
|
||||
<button on:click={removeCategory(category)} class="btn btn-warning btn-sm">Remove</button>
|
||||
{#if category.name != 'general'}
|
||||
<button on:click={removeCategory(category)} class="btn btn-warning btn-sm"
|
||||
>{$t('adventures.remove')}</button
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{#if categories.length === 0}
|
||||
<p>No categories found.</p>
|
||||
<p>{$t('categories.no_categories_found')}</p>
|
||||
{/if}
|
||||
|
||||
{#if category_to_edit}
|
||||
<h2 class="text-center text-xl font-semibold mt-2 mb-2">Edit Category</h2>
|
||||
<h2 class="text-center text-xl font-semibold mt-2 mb-2">{$t('categories.edit_category')}</h2>
|
||||
<div class="flex flex-row space-x-2 form-control">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Name"
|
||||
placeholder={$t('adventures.name')}
|
||||
bind:value={category_to_edit.display_name}
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
/>
|
||||
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Icon"
|
||||
placeholder={$t('categories.icon')}
|
||||
bind:value={category_to_edit.icon}
|
||||
class="input input-bordered w-full max-w-xs"
|
||||
/>
|
||||
</div>
|
||||
<button class="btn btn-primary" on:click={saveCategory}>Save</button>
|
||||
<button class="btn btn-primary" on:click={saveCategory}>{$t('notes.save')}</button>
|
||||
{/if}
|
||||
|
||||
<button class="btn btn-primary mt-4" on:click={close}>{$t('about.close')}</button>
|
||||
|
@ -127,7 +131,7 @@
|
|||
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
||||
></path>
|
||||
</svg>
|
||||
<span>The adventure cards will be updated once you refresh the page.</span>
|
||||
<span>{$t('categories.update_after_refresh')}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import PaletteOutline from '~icons/mdi/palette-outline';
|
||||
import { page } from '$app/stores';
|
||||
import { t, locale, locales } from 'svelte-i18n';
|
||||
import { themes } from '$lib';
|
||||
|
||||
let query: string = '';
|
||||
|
||||
|
@ -214,57 +215,40 @@
|
|||
<button class="btn" on:click={() => (isAboutModalOpen = true)}>{$t('navbar.about')}</button>
|
||||
<button
|
||||
class="btn btn-sm mt-2"
|
||||
on:click={() => (window.location.href = 'https://docs.adventurelog.app/')}
|
||||
on:click={() => (window.location.href = 'https://adventurelog.app')}
|
||||
>{$t('navbar.documentation')}</button
|
||||
>
|
||||
<button
|
||||
class="btn btn-sm mt-2"
|
||||
on:click={() => (window.location.href = 'https://discord.gg/wRbQ9Egr8C')}>Discord</button
|
||||
>
|
||||
<button
|
||||
class="btn btn-sm mt-2"
|
||||
on:click={() => (window.location.href = 'https://buymeacoffee.com/seanmorley15')}
|
||||
>{$t('navbar.support')} 💖</button
|
||||
>
|
||||
<p class="font-bold m-4 text-lg text-center">{$t('navbar.language_selection')}</p>
|
||||
<form method="POST" use:enhance>
|
||||
<select
|
||||
class="select select-bordered w-full max-w-xs bg-base-100 text-base-content"
|
||||
on:change={submitLocaleChange}
|
||||
bind:value={$locale}
|
||||
>
|
||||
{#each $locales as loc}
|
||||
<option value={loc} class="text-base-content">{$t(`languages.${loc}`)}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<input type="hidden" name="locale" value={$locale} />
|
||||
</form>
|
||||
<p class="font-bold m-4 text-lg text-center">{$t('navbar.theme_selection')}</p>
|
||||
<form method="POST" use:enhance={submitUpdateTheme}>
|
||||
<li>
|
||||
<button formaction="/?/setTheme&theme=light"
|
||||
>{$t('navbar.themes.light')}<WeatherSunny class="w-6 h-6" />
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button formaction="/?/setTheme&theme=dark"
|
||||
>{$t('navbar.themes.dark')}<WeatherNight class="w-6 h-6" /></button
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<button formaction="/?/setTheme&theme=night"
|
||||
>{$t('navbar.themes.night')}<WeatherNight class="w-6 h-6" /></button
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<button formaction="/?/setTheme&theme=forest"
|
||||
>{$t('navbar.themes.forest')}<Forest class="w-6 h-6" /></button
|
||||
>
|
||||
<button formaction="/?/setTheme&theme=aestheticLight"
|
||||
>{$t('navbar.themes.aestetic-light')}<PaletteOutline class="w-6 h-6" /></button
|
||||
>
|
||||
<button formaction="/?/setTheme&theme=aestheticDark"
|
||||
>{$t('navbar.themes.aestetic-dark')}<PaletteOutline class="w-6 h-6" /></button
|
||||
>
|
||||
<button formaction="/?/setTheme&theme=aqua"
|
||||
>{$t('navbar.themes.aqua')}<Water class="w-6 h-6" /></button
|
||||
>
|
||||
</li>
|
||||
<p class="font-bold m-4 text-lg text-center">{$t('navbar.language_selection')}</p>
|
||||
<form method="POST" use:enhance>
|
||||
<select
|
||||
class="select select-bordered w-full max-w-xs bg-base-100 text-base-content"
|
||||
on:change={submitLocaleChange}
|
||||
bind:value={$locale}
|
||||
>
|
||||
{#each $locales as loc}
|
||||
<option value={loc} class="text-base-content">{$t(`languages.${loc}`)}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<input type="hidden" name="locale" value={$locale} />
|
||||
</form>
|
||||
{#each themes as theme}
|
||||
<li>
|
||||
<button formaction="/?/setTheme&theme={theme.name}"
|
||||
>{$t(`navbar.themes.${theme.name}`)}
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</form>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue