Add hiding slides from the presentation
CI / Deploy / test (push) Successful in 57s
CI / Deploy / deploy (push) Skipped

Hidden slides stay prepared in the dashboard but are skipped when
presenting (start, next/prev, goto), can not go live via embed and are
left out of the PDF export. Hiding the live or paused slide pauses the
poll like deleting it and resumes with the next visible slide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-11 15:25:41 +01:00
1 parent e2f24877dd
commit 3c978e6f22
15 files changed
+333 -35

No files matched your search

+39 -6
View File
@@ -423,18 +423,51 @@ class SlidesTable extends Table
* Ordered slides of a poll including options.
*
* @param int $pollId Poll id
* @param bool $visibleOnly Only slides that are part of the presentation (not hidden)
* @return list<\App\Model\Entity\Slide>
*/
public function listForPoll(int $pollId): array
public function listForPoll(int $pollId, bool $visibleOnly = false): array
{
/** @var list<\App\Model\Entity\Slide> $slides */
$slides = $this->find()
$query = $this->find()
->where(['Slides.poll_id' => $pollId])
->contain(['SlideOptions'])
->orderBy(['Slides.position' => 'ASC', 'Slides.id' => 'ASC'])
->all()
->toList();
->orderBy(['Slides.position' => 'ASC', 'Slides.id' => 'ASC']);
if ($visibleOnly) {
$query->where(['Slides.is_hidden' => false]);
}
/** @var list<\App\Model\Entity\Slide> $slides */
$slides = $query->all()->toList();
return $slides;
}
/**
* The visible slide that takes the place of a slide leaving the presentation
* (deleted or hidden): the next visible one behind it, otherwise the one before.
*
* @param \App\Model\Entity\Slide $slide Slide leaving the presentation
* @return int|null Slide id, null if no other visible slide is left
*/
public function replacementFor(Slide $slide): ?int
{
$rows = $this->find()
->select(['id', 'is_hidden'])
->where(['poll_id' => $slide->poll_id])
->orderBy(['position' => 'ASC', 'id' => 'ASC'])
->disableHydration()
->all()
->toList();
$index = array_search($slide->id, array_column($rows, 'id'), true);
if ($index === false) {
return null;
}
$candidates = array_merge(array_slice($rows, $index + 1), array_reverse(array_slice($rows, 0, $index)));
foreach ($candidates as $row) {
if (!$row['is_hidden']) {
return (int)$row['id'];
}
}
return null;
}
}