Add autosave draft system for partage form with HTMX-based session persistence

- New fragment endpoint POST/GET /partage/fragments/draft.php:
  saves all form fields to PHP session, excludes file/csrf/slug fields
  GET returns JSON for JS hydration on page load
  rotates both global CSRF and share CSRF tokens in sync

- form.php accepts optional $formExtraAttrs and $showAutosaveStatus:
  allows injecting HTMX attributes and 'Brouillon enregistré' indicator

- renderShareLinkForm adds hx-post with change/input debounce trigger,
  loads autosave-handler.js, hydrate fields from draft on page load

- Draft cleared on successful form submission in handleShareLinkSubmission

- autosave-handler.js now also updates share_link_token hidden input
  when rotating CSRF token (partage form uses both csrf_token and share_link_token)

- Added .autosave-status CSS to form.css (was admin.css-only)

- Updated fragment routing to accept GET requests (needed for draft hydration)
This commit is contained in:
Pontoporeia
2026-06-11 10:32:53 +02:00
parent 4b37a05be3
commit 99125cc8e3
33 changed files with 1388 additions and 806 deletions

View File

@@ -87,6 +87,7 @@ CREATE TABLE IF NOT EXISTS theses (
finality_id INTEGER,
synopsis TEXT,
context_note TEXT,
contact_visible TEXT DEFAULT NULL,
remarks TEXT,
access_type_id INTEGER,
license_id INTEGER,
@@ -407,6 +408,7 @@ SELECT
ft.name as finality_type,
t.synopsis,
t.context_note,
t.contact_visible,
at.name as access_type,
lt.name as license_type,
t.license_id,