From c1159f518cb01d35be78ebc29f04e5ce4ebc74c8 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 27 Feb 2025 10:48:33 -0500 Subject: [PATCH] Add copy buttons to IDs on image upload and fix upload by URL --- inventory-server/package-lock.json | 12 + inventory-server/package.json | 1 + .../steps/ImageUploadStep/ImageUploadStep.tsx | 257 ++++++++++++------ mountremote.command | 5 +- 4 files changed, 182 insertions(+), 93 deletions(-) diff --git a/inventory-server/package-lock.json b/inventory-server/package-lock.json index 972b969..c551954 100755 --- a/inventory-server/package-lock.json +++ b/inventory-server/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@types/diff": "^7.0.1", + "axios": "^1.8.1", "bcrypt": "^5.1.1", "cors": "^2.8.5", "csv-parse": "^5.6.0", @@ -629,6 +630,17 @@ "node": ">= 6.0.0" } }, + "node_modules/axios": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.1.tgz", + "integrity": "sha512-NN+fvwH/kV01dYUQ3PTOZns4LWtWhOFCAhQ/pHb88WQ1hNe5V/dvFwc4VJcDL11LT9xSX0QtsR8sWUuyOuOq7g==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", diff --git a/inventory-server/package.json b/inventory-server/package.json index eeba2de..ac667aa 100755 --- a/inventory-server/package.json +++ b/inventory-server/package.json @@ -19,6 +19,7 @@ "license": "ISC", "dependencies": { "@types/diff": "^7.0.1", + "axios": "^1.8.1", "bcrypt": "^5.1.1", "cors": "^2.8.5", "csv-parse": "^5.6.0", diff --git a/inventory/src/lib/react-spreadsheet-import/src/steps/ImageUploadStep/ImageUploadStep.tsx b/inventory/src/lib/react-spreadsheet-import/src/steps/ImageUploadStep/ImageUploadStep.tsx index 54dbee2..a7d1558 100644 --- a/inventory/src/lib/react-spreadsheet-import/src/steps/ImageUploadStep/ImageUploadStep.tsx +++ b/inventory/src/lib/react-spreadsheet-import/src/steps/ImageUploadStep/ImageUploadStep.tsx @@ -1,7 +1,7 @@ import { useCallback, useState, useRef, useEffect } from "react"; import { useRsi } from "../../hooks/useRsi"; import { Button } from "@/components/ui/button"; -import { Loader2, Upload, Trash2, AlertCircle, GripVertical, Maximize2, X, Link2 } from "lucide-react"; +import { Loader2, Upload, Trash2, AlertCircle, GripVertical, Maximize2, X, Link2, Copy, Check } from "lucide-react"; import { Card, CardContent } from "@/components/ui/card"; import { toast } from "sonner"; import { Input } from "@/components/ui/input"; @@ -86,6 +86,9 @@ export const ImageUploadStep = ({ const [urlInputs, setUrlInputs] = useState<{ [key: number]: string }>({}); const [processingUrls, setProcessingUrls] = useState<{ [key: number]: boolean }>({}); + // Add state for copy button feedback + const [copyState, setCopyState] = useState<{[key: string]: boolean}>({}); + // Initialize product images from data const [productImages, setProductImages] = useState(() => { // Convert existing product_images to ProductImageSortable objects @@ -873,7 +876,7 @@ export const ImageUploadStep = ({ <>

Drop images here or click to select

-

We'll automatically match images to products based on filename

+

Images dropped here will be automatically assigned to products based on filename

{unassignedImages.length > 0 && !showUnassigned && ( - -
+ { + // Prevent closing when interacting with the input + if (inputRef.current?.contains(e.target as Node)) { + e.preventDefault(); + } + }} + onOpenAutoFocus={() => { + // Focus the input field when the popover opens + setTimeout(() => inputRef.current?.focus(), 0); + }} + > +
e.stopPropagation()}>

Add image from URL

updateUrlInput(productIndex, e.target.value)} className="text-sm" + // Full prevention of event bubbling + onClick={(e) => e.stopPropagation()} + onMouseDown={(e) => e.stopPropagation()} + onPointerDown={(e) => e.stopPropagation()} + onKeyDown={(e) => { + e.stopPropagation(); + if (e.key === 'Enter' && urlInputs[productIndex]) { + e.preventDefault(); + handleAddImageFromUrl(productIndex, urlInputs[productIndex] || ''); + setIsOpen(false); + } + }} + // Important for paste operation + onPaste={(e) => { + e.stopPropagation(); + }} /> + ); + }; + + // Update the URL input value + const updateUrlInput = (productIndex: number, value: string) => { + setUrlInputs(prev => ({ ...prev, [productIndex]: value })); + }; + return (
{/* Header - fixed at top */}

Add Product Images

- Upload images for each product or add them from URLs. Drag images to reorder them or move them between products. + Drag images to reorder them or move them between products.

@@ -1422,8 +1496,11 @@ export const ImageUploadStep = ({

{product.name || `Product #${index + 1}`}

- UPC: {product.upc || 'N/A'} | - Supplier #: {product.supplier_no || 'N/A'} + UPC: {product.upc || 'N/A'} + + {' | '} + Supplier #: {product.supplier_no || 'N/A'} +
diff --git a/mountremote.command b/mountremote.command index 431976e..f1697cd 100755 --- a/mountremote.command +++ b/mountremote.command @@ -1,8 +1,7 @@ #!/bin/zsh #Clear previous mount in case it’s still there -umount '/Users/matt/Library/Mobile Documents/com~apple~CloudDocs/Dev/inventory/inventory-server' +umount '/Users/matt/Dev/inventory/inventory-server' #Mount -sshfs matt@dashboard.kent.pw:/var/www/html/inventory -p 22122 '/Users/matt/Library/Mobile Documents/com~apple~CloudDocs/Dev/inventory/inventory-server/' -sshfs matt@dashboard.kent.pw:/var/www/html/inventory -p 22122 '/Users/matt/Library/Mobile Documents/com~apple~CloudDocs/Dev/inventory/inventory-server/' \ No newline at end of file +sshfs matt@dashboard.kent.pw:/var/www/html/inventory -p 22122 '/Users/matt/Dev/inventory/inventory-server/' \ No newline at end of file