Add drag and drop sorting for slides
CI / Deploy / test (push) Successful in 43s
CI / Deploy / deploy (push) Skipped

Slides can be reordered on the dashboard by dragging the handle (mouse,
touch and pen via Pointer Events) or with the arrow keys on the focused
handle. The new order is posted as ids[] to slides/reorder, which only
applies a complete, valid order of the poll's own slides. The up/down
buttons stay as no-JS fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-07 14:44:10 +01:00
1 parent 50010484be
commit 9983d6c01b
8 files changed
+301 -8

No files matched your search

+21
View File
@@ -120,6 +120,27 @@ class SlidesController extends AdminAppController
return $this->redirect($this->adminUrl());
}
/**
* Saves a complete new slide order (drag & drop), expects `ids[]` and answers with JSON.
*
* @return \Cake\Http\Response
*/
public function reorder(): Response
{
$this->request->allowMethod(['post']);
$ids = $this->request->getData('ids');
$ids = is_array($ids) ? array_values(array_map('intval', array_filter($ids, 'is_numeric'))) : [];
if (!$this->Slides->reorder($this->poll->id, $ids)) {
return $this->json([
'ok' => false,
'message' => __('Die Reihenfolge konnte nicht gespeichert werden. Bitte lade die Seite neu.'),
], 409);
}
return $this->json(['ok' => true, 'message' => __('Reihenfolge gespeichert.')]);
}
/**
* Deletes all responses of a slide.
*