feature/name-autocomplete #21
@ -4,7 +4,7 @@
|
||||
import AutoComplete from 'simple-svelte-autocomplete';
|
||||
|
||||
export let form: ActionData;
|
||||
|
||||
|
||||
let selectedName: String;
|
||||
let toCreate = '';
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
.map(([k, v]) => `${(size / k).toFixed(1)} ${v}B`)[0] ?? `${size} bytes`
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
async function loadNames(keyword: String) {
|
||||
const url = "./names";
|
||||
const url = './names';
|
||||
const response = await fetch(url);
|
||||
return await response.json();
|
||||
}
|
||||
@ -54,14 +54,14 @@
|
||||
<div class="field">
|
||||
<label for="name" class="label">Name</label>
|
||||
<div class="control">
|
||||
<AutoComplete
|
||||
id="name"
|
||||
name="name"
|
||||
create={true}
|
||||
bind:selectedItem={selectedName}
|
||||
bind:text={selectedName}
|
||||
createText=""
|
||||
searchFunction={loadNames}
|
||||
<AutoComplete
|
||||
id="name"
|
||||
name="name"
|
||||
create={true}
|
||||
bind:selectedItem={selectedName}
|
||||
bind:text={selectedName}
|
||||
createText=""
|
||||
searchFunction={loadNames}
|
||||
/>
|
||||
</div>
|
||||
{#if form?.field === 'name'}
|
||||
|
@ -6,7 +6,7 @@ export function GET() {
|
||||
const names = readdirSync(storagePath).filter((f) =>
|
||||
statSync(`${storagePath}/${f}`).isDirectory()
|
||||
);
|
||||
names.sort()
|
||||
names.sort();
|
||||
|
||||
return json(names);
|
||||
}
|
||||
|
Reference in New Issue
Block a user