Fix TypeAheadSearch.svelte, Remove Logout

Dieser Commit ist enthalten in:
Chaoscaot 2024-01-07 13:38:27 +01:00
Ursprung dd85aeca7b
Commit 076fc7046d
3 geänderte Dateien mit 5 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -23,6 +23,7 @@
export let selected: string | null = null
export let items: {name: string, value: string}[] = []
export let maxItems = 5;
export let leftText: boolean = false;
export let searchValue = items.find(item => item.value === selected)?.name || ''
let open = false
@ -36,13 +37,13 @@
}
</script>
<Button color="alternative" on:click={() => open = true}>{selected === null ? 'Auswählen' : items.find(value => value.value === selected)?.name}</Button>
<Button color="light" on:click={() => open = true}>{selected === null ? 'Auswählen' : items.find(value => value.value === selected)?.name}</Button>
<Dropdown bind:open class="w-60">
<div class="overflow-y-auto p-3 text-sm w-60" slot="header">
<Search bind:value={searchValue} on:focus={() => open = true} on:keydown={() => open = true}/>
</div>
{#each filteredItems as item (item)}
<button on:click={() => selectItem(item)} class="rounded p-2 hover:bg-gray-100 dark:hover:bg-gray-600 w-full cursor-pointer border-b border-b-gray-600">
<button on:click={() => selectItem(item)} class="rounded p-2 hover:bg-gray-100 dark:hover:bg-gray-600 w-full cursor-pointer border-b border-b-gray-600" class:text-left={leftText}>
{item.name}
</button>
{/each}

Datei anzeigen

@ -34,7 +34,7 @@
let searchValue: string = "";
let dirty = false;
let selectedPath: string = "";
let selectedPath: string | null = null;
let pathSearchValue: string = "";
$: availableBranches = $branches.map((branch) => ({
@ -121,7 +121,7 @@
<div class="border-b border-b-gray-600 pb-2 flex justify-between">
<div>
<TypeAheadSearch items={availableBranches} bind:selected={selectedBranch} bind:searchValue />
<TypeAheadSearch items={Array.from(pagesMap.keys()).map(value => ({value, name: value}))} bind:selected={selectedPath} bind:searchValue={pathSearchValue} maxItems={Number.MAX_VALUE} />
<TypeAheadSearch items={Array.from(pagesMap.keys()).map(value => ({value, name: value}))} bind:selected={selectedPath} bind:searchValue={pathSearchValue} maxItems={Number.MAX_VALUE} leftText={true} />
</div>
<div>
{#if selectedBranch !== "master"}

Datei anzeigen

@ -28,13 +28,7 @@
let events = $eventRepo.listEvents()
let showAdd = false
let showLogoutModal = false
let millis = Date.now()
function logout() {
$tokenStore = ""
replace("/login")
}
</script>
<Navbar let:hidden let:toggle class="shadow-lg border-b">
@ -47,20 +41,11 @@
<NavUl {hidden}>
<NavLi href="#/edit">Edit Pages</NavLi>
<NavLi href="#/perms">Permissions</NavLi>
<NavLi on:click={() => showLogoutModal = true} class="cursor-pointer select-none">Logout</NavLi>
</NavUl>
</Navbar>
<CreateEventModal bind:open={showAdd} on:create={() => events = $eventRepo.listEvents()}/>
<Modal bind:open={showLogoutModal} title="Logout?" outsideclose size="sm">
<p>Do you really want to logout?</p>
<svelte:fragment slot="footer">
<Button on:click={() => showLogoutModal = false} color="alternative" class="ml-auto">Cancel</Button>
<Button on:click={logout} color="red">Logout</Button>
</svelte:fragment>
</Modal>
{#await events}
<div class="h-screen w-screen grid place-items-center">
<Spinner size={16}/>