3 Commits

Author SHA1 Message Date
810b020d7d Merge pull request 'b999_chrome_file_upload' (#47) from b999_chrome_file_upload into development
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
Reviewed-on: #47
2025-12-16 13:24:37 +01:00
5be89f83fd add .GLD file verification for drag and drop 2025-12-16 13:20:18 +01:00
2a7783004a fix chrome issue: selecting the same file does not work properly 2025-12-16 12:54:28 +01:00

View File

@@ -42,6 +42,7 @@
let formErrors: Record<string, any> | null = $state(null); let formErrors: Record<string, any> | null = $state(null);
let etag: string | null = $state(null); let etag: string | null = $state(null);
let files: FileList | null = $state(null); let files: FileList | null = $state(null);
let fileInput = $state(null);
// Model Variablen für Upload // Model Variablen für Upload
let openUL = $state(false); let openUL = $state(false);
@@ -102,6 +103,7 @@
openUL = false; openUL = false;
name = ''; name = '';
files = null; files = null;
fileInput.value = "";
await invalidateAll(); await invalidateAll();
crimesList = data.crimesList; crimesList = data.crimesList;
} }
@@ -291,13 +293,21 @@ Mit freundlichen Grüßen,
// drag and drop functionality // drag and drop functionality
let isDragging = $state(false); let isDragging = $state(false);
function handleDrop(event) { async function handleDrop(event) {
event.preventDefault(); event.preventDefault();
isDragging = false; isDragging = false;
if (event.dataTransfer?.files?.length) { if (event.dataTransfer?.files?.length) {
files = event.dataTransfer.files; files = event.dataTransfer.files;
} }
if (!(await check_valid_glb_file())) {
formErrors = { file: 'Keine gültige .GLD-Datei' }
// reset form fields etc.
files = null;
fileInput.value = '';
} else {
formErrors = { ...formErrors, file: ''}
};
} }
</script> </script>
@@ -449,7 +459,7 @@ Mit freundlichen Grüßen,
class="relative cursor-pointer rounded-md bg-white font-semibold text-indigo-600 focus-within:outline-none focus-within:ring-2 focus-within:ring-indigo-600 focus-within:ring-offset-2 hover:text-indigo-500" class="relative cursor-pointer rounded-md bg-white font-semibold text-indigo-600 focus-within:outline-none focus-within:ring-2 focus-within:ring-indigo-600 focus-within:ring-offset-2 hover:text-indigo-500"
> >
<span>Wähle eine Datei aus</span> <span>Wähle eine Datei aus</span>
<input id="file" bind:files name="file" type="file" class="sr-only" /> <input id="file" bind:this={fileInput} bind:files name="file" type="file" class="sr-only" />
</label> </label>
<p class="pl-1">oder ziehe sie ins Feld</p> <p class="pl-1">oder ziehe sie ins Feld</p>
</div> </div>