# FG Scan Modal Workflow - Visual Guide ## The Problem: Incomplete Modal Structure ### Current New App (Broken) ❌ ``` User scans with defect code 000 ↓ FORM SUBMITS ↓ Scan saved to DB ↓ MODAL APPEARS ↓ ┌──────────────────────────┐ │ Assign to Box [X] │ ├──────────────────────────┤ │ │ │ Box Number: ___________ │ │ Quantity: [1] │ │ │ │ [Cancel] [Assign] │ └──────────────────────────┘ ↓ ❌ PROBLEM: Where's the "Create Box" button? Users don't know they CAN create boxes! Button is hidden somewhere in form section ``` ### Old App (Working) ✅ ``` User scans with defect code 000 ↓ FORM SUBMITS ↓ Scan saved to DB ↓ MODAL APPEARS ↓ ┌───────────────────────────────┐ │ Assign to Box [X] │ ├───────────────────────────────┤ │ CP Code: CP-123456 │ │ │ │ ┌─────────────────────────┐ │ │ │ 📦 Quick Box Label │ │ ← OPTION 1 │ │ Creates & prints │ │ CREATE BOX │ └─────────────────────────┘ │ │ │ │ ━━━━ OR ━━━━ │ ← SEPARATOR │ │ │ Scan Box Number: ________ │ ← OPTION 2 │ │ SCAN EXISTING │ [Skip] [Assign to Box] │ ← OPTION 3 │ │ SKIP └───────────────────────────────┘ ↓ ✅ Users have CLEAR choices Create new box OR use existing one ``` --- ## Workflow Comparison ### Option 1: Create New Box #### Old App Flow (Working ✅) ``` ┌─────────────────────────────────────────────────┐ │ User fills scan form │ │ Operator: OP001 │ │ CP Code: CP-123456 │ │ OC1: OC01 │ │ OC2: OC02 │ │ Defect: 000 (GOOD) │ │ │ │ ✓ Enable "Scan to Boxes" checkbox │ │ ✓ Click Submit │ └─────────────────────────────────────────────────┘ ↓ [Scan saved to DB] ↓ ┌───────────────────────────┐ │ ASSIGN TO BOX MODAL │ ├───────────────────────────┤ │ CP Code: CP-123456 │ │ │ │ [📦 CREATE BOX] ← CLICK │ │ │ │ — OR — │ │ Scan Box: _______ │ │ [Skip] [Assign] │ └───────────────────────────┘ ↓ ✓ POST /warehouse/create_box ✓ Empty box created in DB ✓ get box_id (e.g., BOX-12345) ↓ ✓ POST /generate_box_label_pdf ✓ PDF label generated ↓ ✓ Print via QZ Tray ✓ Label prints on thermal printer ↓ ┌───────────────────────────┐ │ INPUT UPDATES │ │ "Scan printed label now" │ │ Scan Box: [FOCUS HERE] │ │ │ │ — MODAL STAYS OPEN — │ │ [Skip] [Assign] │ └───────────────────────────┘ ↓ User scans newly created box label Input gets: BOX-12345 ↓ ✓ Click [Assign to Box] ✓ POST /warehouse/assign_cp_to_box ✓ CP linked to box in DB ↓ Modal closes Page reloads ✓ Ready for next scan ``` #### New App (Current Problem ⚠️) ``` Same as above BUT: - "Create Box" button is NOT in modal - Users don't see the option - They can only enter box number - Workflow INCOMPLETE ``` --- ### Option 2: Scan Existing Box #### Both Apps (Similar) ✅ ``` ┌───────────────────────────────────┐ │ ASSIGN TO BOX MODAL │ ├───────────────────────────────────┤ │ CP Code: CP-123456 │ │ │ │ — OR — │ │ │ │ Scan Box: [FOCUS] │ │ ↓ User scans existing │ │ box label │ │ Gets: BOX-99999 │ │ │ │ [Skip] [Assign to Box] ← CLICK │ └───────────────────────────────────┘ ↓ ✓ POST /warehouse/assign_cp_to_box ✓ CP linked to existing box ↓ Modal closes Page reloads ✓ Ready for next scan ``` --- ### Option 3: Skip Box Assignment #### Both Apps (Same) ✅ ``` ┌───────────────────────────────────┐ │ ASSIGN TO BOX MODAL │ ├───────────────────────────────────┤ │ CP Code: CP-123456 │ │ │ │ [Skip] ← CLICK │ │ [Assign] │ └───────────────────────────────────┘ ↓ Modal closes Page reloads ✓ Scan is in database ✓ NO box assignment ✓ Next scan ready ``` --- ## Code Architecture Comparison ### OLD APP: Everything in Modal (Correct ✅) ``` HTML Structure: ├── Form (outside modal) │ ├── Operator Code │ ├── CP Code │ ├── OC1, OC2 │ ├── Defect Code │ └── [Submit] │ └── Modal (HIDDEN until scan) ├── CP Code display ├── [CREATE BOX BUTTON] ← HERE ├── — OR — ├── Box Number input ├── [Skip] └── [Assign] JavaScript: 1. Form submits 2. POST /scan endpoint 3. Save to DB 4. Trigger: showModal() 5. Click [CREATE] → POST /create_box → Print → Modal stays open 6. Scan box → Click [ASSIGN] → POST /assign_cp_to_box → Close 7. OR Click [SKIP] → Close ``` ### NEW APP: Button in Wrong Place (Problem ⚠️) ``` HTML Structure: ├── Form (VISIBLE ALWAYS) │ ├── Operator Code │ ├── CP Code │ ├── OC1, OC2 │ ├── Defect Code │ ├── [Submit] │ └── [QUICK BOX BUTTON] ← WRONG: Hidden in form, display: none │ └── Modal (HIDDEN until scan) ├── NO CP Code display ├── Box Number input only ├── Quantity input (unnecessary) ├── [Cancel] └── [Assign] Problem: - Create button NOT visible when modal appears - Users don't know they can create boxes - Modal shows only "Assign" workflow - Incomplete feature implementation ``` --- ## The Fix (3 Steps) ### Fix #1: Move Button into Modal HTML ```diff
CP Code: