---
phase: 95-ajax-table-refresh
plan: 01
subsystem: ui
tags: [ajax, dom-replacement, inline-status, orders-list]

requires:
  - phase: 80-status-change-reload
    provides: inline status change with location.reload()
provides:
  - AJAX table refresh without full page reload
  - JSON endpoint for partial HTML fragments
affects: []

tech-stack:
  added: []
  patterns: [ajax-partial-render, json-html-fragments]

key-files:
  modified:
    - src/Modules/Orders/OrdersController.php
    - public/assets/js/modules/inline-status-change.js

key-decisions:
  - "outerHTML replacement instead of innerHTML for table container"
  - "Silent failure on refresh fetch error — status already updated optimistically"

patterns-established:
  - "X-Requested-With detection for AJAX partial rendering in controllers"

duration: ~15min
completed: 2026-04-10
---

# Phase 95 Plan 01: AJAX Table Refresh Summary

**Zamiana location.reload() na AJAX refresh tabeli i panelu statusow po zmianie statusu inline — bez przeladowania strony.**

## Acceptance Criteria Results

| Criterion | Status | Notes |
|-----------|--------|-------|
| AC-1: AJAX refresh tabeli po zmianie statusu | Pass | Tabela i paginacja odswiezaja sie bez reload, scroll zachowany |
| AC-2: AJAX refresh panelu statusow | Pass | Panel licznikow aktualizuje sie razem z tabela |
| AC-3: Obsluga bledu AJAX refresh | Pass | Badge zaktualizowany optimistic, brak crash przy bledzie fetch |

## Accomplishments

- Controller `index()` wykrywa AJAX request i zwraca JSON z `tableHtml` + `panelHtml`
- JS `inline-status-change.js` po udanej zmianie statusu pobiera fragmenty i podmienia DOM
- Scroll, filtry, paginacja zachowane po refresh

## Files Created/Modified

| File | Change | Purpose |
|------|--------|---------|
| `src/Modules/Orders/OrdersController.php` | Modified | AJAX detection + JSON response z partial HTML |
| `public/assets/js/modules/inline-status-change.js` | Modified | Fetch + DOM replacement zamiast location.reload() |

## Decisions Made

| Decision | Rationale | Impact |
|----------|-----------|--------|
| outerHTML zamiast innerHTML | Prostsza podmiana calego kontenera bez wrapper div | Eventy delegowane na document nadal dzialaja |
| Silent fail na fetch error | Zmiana statusu juz sie powiodla, refresh jest nice-to-have | UX nie przerywa pracy uzytkownika |

## Deviations from Plan

None — plan executed as written.

## Next Phase Readiness

**Ready:**
- Pattern AJAX partial render gotowy do reuse w innych miejscach
- Inline status change w pelni asynchroniczny

**Concerns:** None

**Blockers:** None

---
*Phase: 95-ajax-table-refresh, Plan: 01*
*Completed: 2026-04-10*
