Art: drag pieces into a new order

Each gallery tile gets a small drag handle (top-left, ✱). Grab it and
drop it anywhere among the others - the tile moves live as you drag
over neighbours, then the new order is saved automatically on drop.

- Artwork gets a `position` column; the gallery lists by position (was
  upload date). New uploads land after everything else.
- New POST /art/reorder endpoint takes an ordered list of ids (one
  shared CSRF token, "reorder-art") and rewrites positions 1..n.
- Migration backfills position from the existing upload-date order via
  ROW_NUMBER(), then drops the bootstrap default so it matches the
  Doctrine mapping.
- New Stimulus controller (art-reorder): native HTML5 drag/drop, no
  library. dragover live-reorders the DOM by comparing cursor x to the
  hovered tile's midpoint; dragend posts the resulting id order and
  shows a small "Saving order… / Order saved" status pill.

Verified: schema validate clean: a throwaway script exercised
persist+reload of a reordered set against the real DB, and a live
browser check dispatched real DragEvents through the actual Stimulus
controller and confirmed the exact POST payload it sent. phpunit 9/9.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Frank
2026-09-15 17:18:02 +02:00
co-authored by Claude Sonnet 5
parent bc0433e356
commit 8b8f67c1d0
8 changed files with 291 additions and 15 deletions
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App\Tests\Entity;
use App\Entity\Artwork;
use PHPUnit\Framework\TestCase;
class ArtworkTest extends TestCase
{
public function testPositionDefaultsToZeroAndIsSettable(): void
{
$art = new Artwork();
self::assertSame(0, $art->getPosition());
$art->setPosition(3);
self::assertSame(3, $art->getPosition());
}
}