This commit is contained in:
parent
fc0de8b7e0
commit
4b6f25656b
@ -1,8 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from '$app/forms';
|
import { enhance } from '$app/forms';
|
||||||
import type { ActionData } from './$types';
|
import type { ActionData } from './$types';
|
||||||
|
import AutoComplete from 'simple-svelte-autocomplete';
|
||||||
|
|
||||||
export let form: ActionData;
|
export let form: ActionData;
|
||||||
|
|
||||||
|
let selectedName: String;
|
||||||
|
let toCreate = '';
|
||||||
|
|
||||||
let files: FileList;
|
let files: FileList;
|
||||||
let sending = false;
|
let sending = false;
|
||||||
@ -21,6 +25,12 @@
|
|||||||
.map(([k, v]) => `${(size / k).toFixed(1)} ${v}B`)[0] ?? `${size} bytes`
|
.map(([k, v]) => `${(size / k).toFixed(1)} ${v}B`)[0] ?? `${size} bytes`
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function loadNames(keyword: String) {
|
||||||
|
const url = "./names";
|
||||||
|
const response = await fetch(url);
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
@ -44,14 +54,14 @@
|
|||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="name" class="label">Name</label>
|
<label for="name" class="label">Name</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input
|
<AutoComplete
|
||||||
id="name"
|
id="name"
|
||||||
class="input"
|
name="name"
|
||||||
type="text"
|
create={true}
|
||||||
name="name"
|
bind:selectedItem={selectedName}
|
||||||
placeholder="Name"
|
bind:text={selectedName}
|
||||||
value={form?.name ?? ''}
|
createText=""
|
||||||
required
|
searchFunction={loadNames}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if form?.field === 'name'}
|
{#if form?.field === 'name'}
|
||||||
@ -69,10 +79,10 @@
|
|||||||
<span class="file-cta">
|
<span class="file-cta">
|
||||||
<span class="file-label">Fotos auswählen...</span>
|
<span class="file-label">Fotos auswählen...</span>
|
||||||
</span>
|
</span>
|
||||||
{#if files}
|
{#if files && files?.length !== 0}
|
||||||
<span class="file-name"
|
<span class="file-name">
|
||||||
>{files.length} Bild{#if files.length > 1}er{/if} ausgewählt ({fileSize(files)})</span
|
{files.length} Bild{#if files.length > 1}er{/if} ausgewählt ({fileSize(files)})
|
||||||
>
|
</span>
|
||||||
{:else}
|
{:else}
|
||||||
<span class="file-name">Keine Bilder ausgewählt</span>
|
<span class="file-name">Keine Bilder ausgewählt</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
Reference in New Issue
Block a user