Merge pull request 'feature/name-autocomplete' (#21) from feature/name-autocomplete into main
Reviewed-on: #21
This commit is contained in:
commit
7a0c3e516d
@ -15,7 +15,7 @@
|
|||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [ nodejs ];
|
nativeBuildInputs = with pkgs; [ nodejs_latest ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
7
package-lock.json
generated
7
package-lock.json
generated
@ -22,6 +22,7 @@
|
|||||||
"prettier": "^3.1.1",
|
"prettier": "^3.1.1",
|
||||||
"prettier-plugin-svelte": "^3.1.2",
|
"prettier-plugin-svelte": "^3.1.2",
|
||||||
"sass": "^1.77.5",
|
"sass": "^1.77.5",
|
||||||
|
"simple-svelte-autocomplete": "^2.5.2",
|
||||||
"svelte": "^4.2.7",
|
"svelte": "^4.2.7",
|
||||||
"svelte-check": "^3.6.0",
|
"svelte-check": "^3.6.0",
|
||||||
"tslib": "^2.4.1",
|
"tslib": "^2.4.1",
|
||||||
@ -3945,6 +3946,12 @@
|
|||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/simple-svelte-autocomplete": {
|
||||||
|
"version": "2.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/simple-svelte-autocomplete/-/simple-svelte-autocomplete-2.5.2.tgz",
|
||||||
|
"integrity": "sha512-6+kZP3XQGb7zs0djTWoFv8tQorBZdv64YfCKrlsYIYBCFsEeikSiNsBSSYw1Om+LYmFeMEOAYSSKoEw+qpnBXQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/sirv": {
|
"node_modules/sirv": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz",
|
||||||
|
@ -19,21 +19,22 @@
|
|||||||
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
||||||
"@types/eslint": "^9.0.0",
|
"@types/eslint": "^9.0.0",
|
||||||
"@types/node": "^20.14.11",
|
"@types/node": "^20.14.11",
|
||||||
|
"bulma": "^1.0.1",
|
||||||
"eslint": "^9.0.0",
|
"eslint": "^9.0.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-svelte": "^2.36.0",
|
"eslint-plugin-svelte": "^2.36.0",
|
||||||
"globals": "^15.0.0",
|
"globals": "^15.0.0",
|
||||||
"prettier": "^3.1.1",
|
"prettier": "^3.1.1",
|
||||||
"prettier-plugin-svelte": "^3.1.2",
|
"prettier-plugin-svelte": "^3.1.2",
|
||||||
|
"sass": "^1.77.5",
|
||||||
|
"simple-svelte-autocomplete": "^2.5.2",
|
||||||
"svelte": "^4.2.7",
|
"svelte": "^4.2.7",
|
||||||
"svelte-check": "^3.6.0",
|
"svelte-check": "^3.6.0",
|
||||||
"tslib": "^2.4.1",
|
"tslib": "^2.4.1",
|
||||||
"typescript": "^5.0.0",
|
"typescript": "^5.0.0",
|
||||||
"typescript-eslint": "^8.0.0-alpha.20",
|
"typescript-eslint": "^8.0.0-alpha.20",
|
||||||
"vite": "^5.0.3",
|
"vite": "^5.0.3",
|
||||||
"vitest": "^2.0.0",
|
"vitest": "^2.0.0"
|
||||||
"bulma": "^1.0.1",
|
|
||||||
"sass": "^1.77.5"
|
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
<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';
|
||||||
|
// @ts-expect-error: package does not contain type definitions
|
||||||
|
import AutoComplete from 'simple-svelte-autocomplete';
|
||||||
|
|
||||||
export let form: ActionData;
|
export let form: ActionData;
|
||||||
|
|
||||||
|
let selectedName: string;
|
||||||
|
|
||||||
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() {
|
||||||
|
const url = './names';
|
||||||
|
const response = await fetch(url);
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
@ -44,14 +54,15 @@
|
|||||||
<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"
|
|
||||||
type="text"
|
|
||||||
name="name"
|
name="name"
|
||||||
placeholder="Name"
|
placeholder="Name"
|
||||||
value={form?.name ?? ''}
|
create={true}
|
||||||
required
|
bind:selectedItem={selectedName}
|
||||||
|
bind:text={selectedName}
|
||||||
|
createText=""
|
||||||
|
searchFunction={loadNames}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if form?.field === 'name'}
|
{#if form?.field === 'name'}
|
||||||
@ -69,10 +80,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}
|
||||||
|
@ -6,6 +6,7 @@ export function GET() {
|
|||||||
const names = readdirSync(storagePath).filter((f) =>
|
const names = readdirSync(storagePath).filter((f) =>
|
||||||
statSync(`${storagePath}/${f}`).isDirectory()
|
statSync(`${storagePath}/${f}`).isDirectory()
|
||||||
);
|
);
|
||||||
|
names.sort();
|
||||||
|
|
||||||
return json(names);
|
return json(names);
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
/* Set your brand colors */
|
/* Set your brand colors */
|
||||||
$pink: pink;
|
$pink: #d47479;
|
||||||
|
Reference in New Issue
Block a user