134 lines
5.6 KiB
Markdown
134 lines
5.6 KiB
Markdown
---
|
|
phase: 100-preset-scope-print-ux
|
|
plan: 01
|
|
subsystem: ui
|
|
tags: [shipments, print-queue, presets, polling]
|
|
|
|
requires:
|
|
- phase: 23-25-shipment-presets
|
|
provides: Preset autofill mechanics (applyPreset, selectDeliveryService)
|
|
- phase: 18-20-print-queue
|
|
provides: print_jobs table, POST /api/print/jobs, PrintJobRepository
|
|
|
|
provides:
|
|
- Presety nadpisuja wylacznie wymiary+wage paczki
|
|
- GET /api/print/jobs/status endpoint (session auth)
|
|
- Polling kolejki wydruku w orders/show.php i shipments/prepare.php
|
|
- Auto-click ostatniej etykiety po utworzeniu przesylki (?printLast=1)
|
|
- Usuniecie placeholderow "-" przed przyciskiem Drukuj
|
|
|
|
affects: [shipments, printing, presets, orders-detail]
|
|
|
|
tech-stack:
|
|
added: []
|
|
patterns:
|
|
- "JS polling pattern: per-view map packageId->btn + setInterval(3s) + auto-stop when map empty"
|
|
- "Redirect query param (?printLast=1) + history.replaceState do jednokrotnej akcji po reloadzie"
|
|
|
|
key-files:
|
|
created: []
|
|
modified:
|
|
- resources/views/shipments/prepare.php
|
|
- resources/views/orders/show.php
|
|
- src/Modules/Printing/PrintApiController.php
|
|
- src/Modules/Printing/PrintJobRepository.php
|
|
- src/Modules/Shipments/ShipmentController.php
|
|
- routes/web.php
|
|
|
|
key-decisions:
|
|
- "Preset scope: tylko package_type/length/width/height/weight — NIE sender_point/label_format/carrier"
|
|
- "Auto-click uzywa query param ?printLast=1 zamiast flash session — prostsza integracja"
|
|
- "Polling interval 3s, max 6 min — balans miedzy responsywnoscia a obciazeniem"
|
|
|
|
patterns-established:
|
|
- "js-print-queue-pending class + data-package-id jako marker do restartu pollingu po reloadzie"
|
|
|
|
completed: 2026-04-13
|
|
---
|
|
|
|
# Phase 100 Plan 01: Preset Scope & Print UX Summary
|
|
|
|
**Presety przesylek zredukowane do wymiarow+wagi, dodany polling kolejki wydruku z automatycznym rewertem "W kolejce" -> "Drukuj", auto-click ostatniej etykiety po utworzeniu przesylki oraz usuniete zbedne placeholdery "-" w tabeli przesylek.**
|
|
|
|
## Acceptance Criteria Results
|
|
|
|
| Criterion | Status | Notes |
|
|
|-----------|--------|-------|
|
|
| AC-1: Preset zmienia tylko paczke | Pass | applyPreset() zawezone do 5 pol; carrier/serwis nietykane |
|
|
| AC-2: Auto-click ostatniej etykiety | Pass | Redirect ?printLast=1 + JS `autoClickLastLabel()` z polluje do 30s za `.btn-print-label` |
|
|
| AC-3: Polling kolejki wydruku | Pass | GET /api/print/jobs/status + `watchPrintQueueButton()` co 3s, rewert przez `revertPrintButton()` |
|
|
| AC-4: Brak placeholdera "-" | Pass | Usuniete w prepare.php i show.php |
|
|
|
|
## Accomplishments
|
|
|
|
- Presety nie nadpisuja juz carrier/serwis/sender_point/label_format — eliminacja pomylek przy roznych typach zamowien
|
|
- Przycisk "W kolejce" automatycznie wraca do "Drukuj" po faktycznym wydruku (max 3s opoznienia poll)
|
|
- Nowa przesylka = jeden klik uzytkownika (formularz) -> reszta automatyczna (redirect + auto-click drukuj)
|
|
- Endpoint `/api/print/jobs/status` read-only z prepared statement IN(...), limit 100 ID, session auth
|
|
|
|
## Files Created/Modified
|
|
|
|
| File | Change | Purpose |
|
|
|------|--------|---------|
|
|
| `resources/views/shipments/prepare.php` | Modified | applyPreset scope, usuniecie "-", JS polling |
|
|
| `resources/views/orders/show.php` | Modified | usuniecie "-", JS polling, auto-click ?printLast=1 |
|
|
| `src/Modules/Printing/PrintApiController.php` | Modified | metoda `status()` |
|
|
| `src/Modules/Printing/PrintJobRepository.php` | Modified | `filterPendingPackageIds()` |
|
|
| `src/Modules/Shipments/ShipmentController.php` | Modified | redirect `?printLast=1` po sukcesie create() |
|
|
| `routes/web.php` | Modified | GET /api/print/jobs/status (authMiddleware) |
|
|
|
|
## Decisions Made
|
|
|
|
| Decision | Rationale | Impact |
|
|
|----------|-----------|--------|
|
|
| Usuniecie sender_point_id i label_format z applyPreset | Naleza do "formy dostawy" per intencja uzytkownika | Presety sa czysto "paczka", nie "dostawa" |
|
|
| ?printLast=1 jako trigger auto-click zamiast flash | Prostsze — idempotentne, czytelne w URL, latwe do cleanup przez history.replaceState | Jednorazowa akcja bez dependency na session state |
|
|
| Polling interval 3s, max 120 tickow | 3s = responsywnie; 6 min = safety bez nieskonczonej petli | Brak wyciekow timerow, rozsadne obciazenie API |
|
|
| `js-print-queue-pending` class + data-package-id | Marker do restartu polling po reloadzie strony gdy sa juz pending jobs | DRY: ten sam kod polling dzialajac dla klikow i dla reloadu |
|
|
|
|
## Deviations from Plan
|
|
|
|
### Summary
|
|
|
|
| Type | Count | Impact |
|
|
|------|-------|--------|
|
|
| Auto-fixed | 0 | — |
|
|
| Scope additions | 0 | — |
|
|
| Deferred | 0 | — |
|
|
|
|
**Total impact:** Plan wykonany dokladnie wg specyfikacji.
|
|
|
|
### Deferred Items
|
|
None — plan wykonany w calosci.
|
|
|
|
## Issues Encountered
|
|
None — wszystkie `php -l` zielone, zero retryow.
|
|
|
|
## Verification Results
|
|
|
|
```
|
|
php -l resources/views/shipments/prepare.php -> No syntax errors
|
|
php -l resources/views/orders/show.php -> No syntax errors
|
|
php -l src/Modules/Printing/PrintApiController.php -> No syntax errors
|
|
php -l src/Modules/Printing/PrintJobRepository.php -> No syntax errors
|
|
php -l src/Modules/Shipments/ShipmentController.php -> No syntax errors
|
|
php -l routes/web.php -> No syntax errors
|
|
```
|
|
|
|
Manualny UAT AC-1..AC-4 wymaga uruchomienia aplikacji — rekomendowany po commitcie.
|
|
|
|
## Next Phase Readiness
|
|
|
|
**Ready:**
|
|
- Kolejna faza v3.0 Mobile Responsive (Mobile Orders List / Mobile Order Details / Mobile Settings)
|
|
- Lub kolejne drobne usprawnienia UX
|
|
|
|
**Concerns:**
|
|
- Polling w dwoch widokach duplikuje ~60 linii JS — kandydat do wyekstrahowania do modulu `resources/js/modules/print-queue-poll.js` w przyszlej fazie
|
|
|
|
**Blockers:** None
|
|
|
|
---
|
|
*Phase: 100-preset-scope-print-ux, Plan: 01*
|
|
*Completed: 2026-04-13*
|