|
@@ -63,9 +63,10 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ref, computed } from "vue";
|
|
|
|
|
|
|
+import { ref, computed, onMounted, onUnmounted } from "vue";
|
|
|
import { useI18n } from "vue-i18n";
|
|
import { useI18n } from "vue-i18n";
|
|
|
import { Search, Filter, RefreshCw, Plus, Package } from "lucide-vue-next";
|
|
import { Search, Filter, RefreshCw, Plus, Package } from "lucide-vue-next";
|
|
|
|
|
+import { toast } from "vue-sonner";
|
|
|
import Button from "@/components/ui/button.vue";
|
|
import Button from "@/components/ui/button.vue";
|
|
|
import OrderCard from "./OrderCard.vue";
|
|
import OrderCard from "./OrderCard.vue";
|
|
|
|
|
|
|
@@ -131,4 +132,46 @@ const resetFilters = () => {
|
|
|
dateFrom.value = '';
|
|
dateFrom.value = '';
|
|
|
dateTo.value = '';
|
|
dateTo.value = '';
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ window.addEventListener('paste', handlePaste);
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+onUnmounted(() => {
|
|
|
|
|
+ window.removeEventListener('paste', handlePaste);
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+async function handlePaste(event: ClipboardEvent) {
|
|
|
|
|
+ const active = document.activeElement;
|
|
|
|
|
+ if (active && (active.tagName === 'INPUT' || active.tagName === 'TEXTAREA')) return;
|
|
|
|
|
+
|
|
|
|
|
+ if (!focusedOrderId.value) {
|
|
|
|
|
+ // We don't want to show a toast here because the user might just be pasting outside of an order
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!event.clipboardData || !event.clipboardData.items) {
|
|
|
|
|
+ toast.error("No clipboard data available");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let foundImage = false;
|
|
|
|
|
+ for (let i = 0; i < event.clipboardData.items.length; i++) {
|
|
|
|
|
+ const item = event.clipboardData.items[i];
|
|
|
|
|
+ if (item.type.startsWith('image/')) {
|
|
|
|
|
+ foundImage = true;
|
|
|
|
|
+ const file = item.getAsFile();
|
|
|
|
|
+ if (file) {
|
|
|
|
|
+ event.preventDefault();
|
|
|
|
|
+ toast.info("Uploading pasted image...");
|
|
|
|
|
+ emit('upload-photo', focusedOrderId.value, file);
|
|
|
|
|
+ break; // Stop after finding the first image
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!foundImage) {
|
|
|
|
|
+ toast.error("No image found in clipboard. Make sure you copied an image, not text or a file path.");
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|