diff --git a/frontend/components/Item/CreateModal.vue b/frontend/components/Item/CreateModal.vue
index 36d98bc0..85672b92 100644
--- a/frontend/components/Item/CreateModal.vue
+++ b/frontend/components/Item/CreateModal.vue
@@ -17,25 +17,7 @@
:max-length="1000"
/>
-
-
-
-
-
-
-
+ (form.photos = photos)" />
-
-
-
-
-
-
![Uploaded Photo]()
-
-
-
-
-
-
-
-
- Delete photo
-
-
-
-
-
-
{{ photo.photoName }}
-
-
-
@@ -109,26 +44,16 @@
import { toast } from "@/components/ui/sonner";
import { Button, ButtonGroup } from "~/components/ui/button";
import BaseModal from "@/components/App/CreateModal.vue";
- import { Label } from "@/components/ui/label";
- import { Input } from "@/components/ui/input";
import type { ItemCreate, LocationOut } from "~~/lib/api/types/data-contracts";
import { useLabelStore } from "~~/stores/labels";
import { useLocationStore } from "~~/stores/locations";
import MdiPackageVariant from "~icons/mdi/package-variant";
import MdiPackageVariantClosed from "~icons/mdi/package-variant-closed";
- import MdiDelete from "~icons/mdi/delete";
- // import MdiStarOutline from "~icons/mdi/star-outline";
- // import MdiStar from "~icons/mdi/star";
import { AttachmentTypes } from "~~/lib/api/types/non-generated";
import { useDialog, useDialogHotkey } from "~/components/ui/dialog-provider";
import LabelSelector from "~/components/Label/Selector.vue";
-
- interface PhotoPreview {
- photoName: string;
- file: File;
- fileBase64: string;
- primary: boolean;
- }
+ import type { PhotoPreview } from "~/components/Item/ImageUpload.vue";
+ import PhotoUploader from "~/components/Item/ImageUpload.vue";
const { activeDialog, closeDialog } = useDialog();
@@ -173,40 +98,6 @@
const { shift } = useMagicKeys();
- function deleteImage(index: number) {
- form.photos.splice(index, 1);
- }
-
- // TODO: actually set the primary when adding item
-
- // function setPrimary(index: number) {
- // const primary = form.photos.findIndex(p => p.primary);
-
- // if (primary !== -1) form.photos[primary].primary = false;
- // if (primary !== index) form.photos[index].primary = true;
-
- // toast.error("Currently this does not do anything, the first photo will always be primary");
- // }
-
- function previewImage(event: Event) {
- const input = event.target as HTMLInputElement;
- if (input.files && input.files.length > 0) {
- for (const file of input.files) {
- const reader = new FileReader();
- reader.onload = e => {
- form.photos.push({
- photoName: file.name,
- fileBase64: e.target?.result as string,
- file,
- primary: form.photos.length === 0,
- });
- };
- reader.readAsDataURL(file);
- }
- input.value = "";
- }
- }
-
watch(
() => activeDialog.value,
active => {
diff --git a/frontend/components/Item/ImageUpload.vue b/frontend/components/Item/ImageUpload.vue
new file mode 100644
index 00000000..46f9423d
--- /dev/null
+++ b/frontend/components/Item/ImageUpload.vue
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
![Uploaded Photo]()
+
+
+
+
+
+
+
+
+ Delete photo
+
+
+
+
+
+
{{ photo.photoName }}
+
+
+
+
+
+
+