Remove up/down buttons for slides
Drag and drop (including arrow keys on the handle) replaces them, so the move route, action and table method are gone as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4034a65498
commit
60fb2cb029
7 files changed
+4
-60
No files matched your search
@@ -262,38 +262,6 @@ class SlidesTable extends Table
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the slide with its neighbour.
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Slide to move
|
||||
* @param string $direction 'up' or 'down'
|
||||
* @return bool Whether something changed
|
||||
*/
|
||||
public function move(Slide $slide, string $direction): bool
|
||||
{
|
||||
$this->normalizePositions($slide->poll_id);
|
||||
$slide = $this->get($slide->id);
|
||||
|
||||
$neighbour = $this->find()
|
||||
->where([
|
||||
'poll_id' => $slide->poll_id,
|
||||
'position' . ($direction === 'up' ? ' <' : ' >') => $slide->position,
|
||||
])
|
||||
->orderBy(['position' => $direction === 'up' ? 'DESC' : 'ASC'])
|
||||
->first();
|
||||
if ($neighbour === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool)$this->getConnection()->transactional(function () use ($slide, $neighbour): bool {
|
||||
$position = $slide->position;
|
||||
$slide->position = $neighbour->position;
|
||||
$neighbour->position = $position;
|
||||
|
||||
return $this->save($slide) && $this->save($neighbour);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a complete new order (e.g. from drag & drop).
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user