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

+3 -2
View File
@@ -161,7 +161,7 @@ class AdminController extends AdminAppController
{
if ($this->poll->current_slide_id === null && !$this->poll->isPaused()) {
$first = $this->Slides->find()
->where(['poll_id' => $this->poll->id])
->where(['poll_id' => $this->poll->id, 'is_hidden' => false])
->orderBy(['position' => 'ASC', 'id' => 'ASC'])
->first();
if ($first !== null) {
@@ -203,7 +203,8 @@ class AdminController extends AdminAppController
{
$this->request->allowMethod(['post']);
$action = (string)$this->request->getData('action');
$slides = $this->Slides->listForPoll($this->poll->id);
// Hidden slides are skipped and can not go live.
$slides = $this->Slides->listForPoll($this->poll->id, true);
$ids = array_map(fn(Slide $s) => $s->id, $slides);
$index = array_search($this->poll->current_slide_id, $ids, true);
$current = $index === false ? null : $slides[$index];
+2 -2
View File
@@ -114,14 +114,14 @@ class EmbedController extends AppController
}
/**
* The embed became visible: this slide goes live. Idempotent.
* The embed became visible: this slide goes live (unless it is hidden). Idempotent.
*
* @return \Cake\Http\Response
*/
public function activate(): Response
{
$this->request->allowMethod(['post']);
if ($this->poll->is_active) {
if ($this->poll->is_active && !$this->slide->is_hidden) {
$this->poll->showEmbeddedSlide($this->slide->id);
$this->Polls->saveOrFail($this->poll);
}
+29 -9
View File
@@ -104,15 +104,7 @@ class SlidesController extends AdminAppController
$this->request->allowMethod(['post']);
$slide = $this->loadSlide($id);
// Deleting the live (or paused) slide pauses the poll; → resumes with the slide taking its place.
$ids = $this->Slides->find()
->select(['id'])
->where(['poll_id' => $this->poll->id])
->orderBy(['position' => 'ASC', 'id' => 'ASC'])
->all()
->extract('id')
->toList();
$index = (int)array_search($slide->id, $ids, true);
$this->poll->forgetSlide($slide->id, $ids[$index + 1] ?? $ids[$index - 1] ?? null);
$this->poll->forgetSlide($slide->id, $this->Slides->replacementFor($slide));
$this->Slides->getConnection()->transactional(function () use ($slide): void {
$this->Polls->saveOrFail($this->poll);
@@ -124,6 +116,34 @@ class SlidesController extends AdminAppController
return $this->redirect($this->adminUrl());
}
/**
* Hides a slide from the presentation or shows it again. Field `hidden` (1|0) is explicit
* (not a toggle), so repeating the request changes nothing. Hiding the live (or paused)
* slide pauses the poll like deleting it.
*
* @param string $id Slide id
* @return \Cake\Http\Response|null
*/
public function visibility(string $id): ?Response
{
$this->request->allowMethod(['post']);
$slide = $this->loadSlide($id);
$hidden = filter_var($this->request->getData('hidden'), FILTER_VALIDATE_BOOLEAN);
$this->Slides->getConnection()->transactional(function () use ($slide, $hidden): void {
if ($hidden) {
$this->poll->forgetSlide($slide->id, $this->Slides->replacementFor($slide));
$this->Polls->saveOrFail($this->poll);
}
$this->Slides->updateAll(['is_hidden' => $hidden], ['id' => $slide->id]);
});
$this->Flash->success($hidden
? __('Folie „{0}“ ist ausgeblendet und wird beim Präsentieren übersprungen.', $slide->question)
: __('Folie „{0}“ ist wieder eingeblendet.', $slide->question));
return $this->redirect($this->adminUrl());
}
/**
* Copies a slide (without responses) directly behind the original and opens the copy for editing.
*