Bildupload
This commit is contained in:
@@ -39,8 +39,6 @@
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
images.push({ preview: true, benutzer_id: null, kategorie, created_at: new Date(), updated_at: new Date(), id: "" });
|
||||
images = images;
|
||||
|
||||
if (file.type !== "image/jpeg" && file.type !== "image/png" && file.type !== "image/webp" && file.type !== "image/heif" && file.type !== "image/heic") {
|
||||
continue;
|
||||
@@ -50,6 +48,9 @@
|
||||
break;
|
||||
}
|
||||
|
||||
images.push({ preview: true, benutzer_id: null, kategorie, created_at: new Date(), updated_at: new Date(), id: "" });
|
||||
images = images;
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = async () => {
|
||||
@@ -119,14 +120,19 @@
|
||||
dismissable: true
|
||||
})
|
||||
} else {
|
||||
const placeholder = images.find((f) => f.kategorie === kategorie && f.preview === true);
|
||||
if (!placeholder) {
|
||||
return;
|
||||
const index = images.findIndex((img) => img.preview === true);
|
||||
|
||||
if (index !== -1) {
|
||||
delete images[index];
|
||||
images = images.filter((img) => img);
|
||||
}
|
||||
placeholder!.preview = false;
|
||||
placeholder!.id = result.id;
|
||||
placeholder!.benutzer_id = ausweis.benutzer_id;
|
||||
images = images;
|
||||
images = [...images, {
|
||||
benutzer_id: null,
|
||||
created_at: new Date(),
|
||||
updated_at: new Date(),
|
||||
id: result.id,
|
||||
kategorie
|
||||
}];
|
||||
|
||||
if (i == Math.min(files.length, max) - 1) {
|
||||
this.value = "";
|
||||
|
||||
Reference in New Issue
Block a user