Add admin menu drawer and poll cloning, drop participant screen tools
- Remove fullscreen and wake lock buttons from the participant view. - Turn the admin sidebar into a drawer below 900px, opened from a header menu button next to the theme switch (progressive enhancement). - Add "Umfrage kopieren": clone a poll with all slides, options and images but without responses, with its own join code and admin link. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0f91377de3
commit
bd57f23be6
15 files changed
+374
-138
No files matched your search
@@ -257,6 +257,37 @@ class PollsTable extends Table
|
||||
return [$poll, $token];
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a poll: new poll (same e-mail, new admin token and join code) with a copy of all slides,
|
||||
* but without any responses, and not started. Nothing is left behind if copying fails.
|
||||
*
|
||||
* @param \App\Model\Entity\Poll $poll Original
|
||||
* @param list<\App\Model\Entity\Slide> $slides Slides of the original incl. slide_options, in order
|
||||
* @return array{0: \App\Model\Entity\Poll, 1: string|null} The new poll and its plain token (null on failure)
|
||||
*/
|
||||
public function clonePoll(Poll $poll, array $slides): array
|
||||
{
|
||||
$copy = $this->newPoll([
|
||||
'title' => mb_substr(__('{0} (Kopie)', $poll->title), 0, 200),
|
||||
'email' => $poll->email,
|
||||
]);
|
||||
if ($copy->hasErrors()) {
|
||||
return [$copy, null];
|
||||
}
|
||||
$copy->set('comment_speed', $poll->comment_speed);
|
||||
|
||||
$token = null;
|
||||
$this->getConnection()->transactional(function () use ($copy, $slides, &$token): void {
|
||||
[, $token] = $this->insertPoll($copy);
|
||||
if ($token === null) {
|
||||
throw new RuntimeException('Poll could not be saved');
|
||||
}
|
||||
$this->Slides->copyAllToPoll($slides, $copy->id);
|
||||
});
|
||||
|
||||
return [$copy, $token];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Cake\ORM\Query\SelectQuery $query Query
|
||||
* @param string $token Plain admin token
|
||||
|
||||
Reference in new issue
Block a user