Skip to content

Phase 14d-2: pages edit form on FilePond + existing files listing#30

Merged
bigin merged 1 commit into
imanager-2.0from
phase-14d2-pages-uploads
May 3, 2026
Merged

Phase 14d-2: pages edit form on FilePond + existing files listing#30
bigin merged 1 commit into
imanager-2.0from
phase-14d2-pages-uploads

Conversation

@bigin
Copy link
Copy Markdown
Owner

@bigin bigin commented May 3, 2026

Summary

Picks up where 14d-1 left off: the editor pages edit form now ships a
FilePond widget that posts to /editor/api/upload, plus a server-rendered
list of files already attached to the page (FileRepository::findByItemAndField).
Migrated 1.x images (the legacy images data array) render in a separate,
collapsible "Legacy" block as display-only until 14d-3 brings them onto
the new pipeline.

PagesModule:

  • ctor takes FieldRepository + FileRepository
  • renderImagesSection rewritten:
    • existing page → <ul.image-list--uploaded> rows (thumbnail + name +
      remove button) followed by an <input.filepond> with data-* config
    • new page → "Save the page first" hint (UploadHandler requires itemId >= 1)
    • pages without an images field → friendly diagnostic
  • File-row markup carries data-file-id + CSRF/url so JS can DELETE
    without a page reload

filepond-init.js (vendored under editor/theme/scripts/):

  • registers image-preview, file-validate-type, file-validate-size plugins
    when present; tolerates a missing FilePond global
  • per <input.filepond>: configures the process URL, appends
    itemId/fieldId/CSRF to multipart, parses {"fileId":N} response
  • wires .image-list__remove buttons to fetch DELETE the upload endpoint
    and remove the row on success

Editor template loads filepond.css + filepond-image-preview.css in
<head> and the four FilePond JS files + filepond-init.js before
body close.

Test plan

  • GET /editor/pages/edit/?page=3 → 200, FilePond input + all data-*,
    legacy block, filepond-init.js loaded
  • GET /editor/pages/edit/ → 200, "Save the page first" hint
  • POST /editor/api/upload → 200; fileId returned
  • re-fetch edit form → image-list--uploaded row with thumbnail
  • DELETE /editor/api/upload → 200; files row gone
  • editor template loads all FilePond assets
  • Browser smoke against ServBay (drag-drop + thumbnail + remove)

Picks up where 14d-1 left off: the editor pages edit form now ships a
FilePond widget that posts to /editor/api/upload, plus a server-rendered
list of files already attached to the page (FileRepository::
findByItemAndField). Migrated 1.x images (the legacy `images` data
array) render in a separate, collapsible "Legacy" block as display-only
until 14d-3 brings them onto the new pipeline.

PagesModule:
  - constructor takes FieldRepository + FileRepository (DI extended in
    EditorRouter::dispatchPages).
  - renderImagesSection rewritten:
      * existing page → server-renders an <ul.image-list--uploaded>
        with thumbnail (300×300) + filename + remove button per file,
        followed by an <input.filepond> bound to the upload endpoint
        via data-* attributes (itemId, fieldId, csrf-name/value, url).
      * new page → "Save the page first" hint (UploadHandler requires
        itemId >= 1).
      * pages without an `images` field → friendly diagnostic.
  - File-row markup carries data-file-id + CSRF/url so the init script
    can DELETE existing files without a page reload.

filepond-init.js (vendored under editor/theme/scripts/):
  - Registers image-preview, file-validate-type, file-validate-size
    plugins when present; tolerates a missing FilePond global.
  - For each <input.filepond>: configures the process URL, appends
    itemId/fieldId/CSRF to multipart, parses {"fileId":N} response,
    surfaces server "error" messages on failure.
  - Wires .image-list__remove buttons to fetch DELETE the upload
    endpoint (form-encoded body) and removes the row on success.

Editor template loads filepond.css + filepond-image-preview.css in
<head> and the four FilePond JS files + filepond-init.js before the
body close.

Manual smoke (PHP built-in server, 80×80 PNG fixture):
  GET  /editor/pages/edit/?page=3   200, FilePond input present with
                                         all data-* attributes, legacy
                                         block details summary visible,
                                         filepond-init.js loaded
  GET  /editor/pages/edit/          200, "Save the page first" hint;
                                         no FilePond input
  POST /editor/api/upload (image)   200; fileId returned
  GET  /editor/pages/edit/?page=3   200, image-list--uploaded row
                                         with the new file + thumbnail
  DELETE /editor/api/upload         200; files row gone
  Editor template                   loads filepond.css, filepond.js,
                                          filepond-image-preview.{css,js},
                                          filepond-init.js
@bigin bigin merged commit 6fc0bfd into imanager-2.0 May 3, 2026
@bigin bigin deleted the phase-14d2-pages-uploads branch May 15, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant