Add admin menu drawer and poll cloning, drop participant screen tools #114
No files matched your search
@@ -53,7 +53,7 @@ passende Dokument und pflegt es danach** (Details zu Verhalten, Settings, Tests
|
||||
| Verzeichnisstruktur, Klassen, Tabellen | [docs/architecture.md](docs/architecture.md) |
|
||||
| Folientypen (Wortwolke, Quiz, Q&A, Reihenfolge, YouTube, Skala/Sterne, Kommentare), Checkliste „Neuen Folientyp hinzufügen“ | [docs/slide-types.md](docs/slide-types.md) |
|
||||
| Folienbilder (Upload, Ablage, Löschen) | [docs/images.md](docs/images.md) |
|
||||
| Live-Schaltung, Referentenansicht, Pause, Ausblenden, Zurücksetzen, Duplizieren, Einbettung, internes Feedback | [docs/presenter.md](docs/presenter.md) |
|
||||
| Live-Schaltung, Referentenansicht, Pause, Ausblenden, Zurücksetzen, Duplizieren, Umfrage kopieren, Einbettung, internes Feedback | [docs/presenter.md](docs/presenter.md) |
|
||||
| Dashboard-Fragmente, Farbschema, Textformatierung, Vollbild | [docs/frontend.md](docs/frontend.md) |
|
||||
| PDF-Export | [docs/pdf-export.md](docs/pdf-export.md) |
|
||||
| Ablauf/Cleanup von Umfragen, CI/Deploy, Releases, Docker, Renovate | [docs/operations.md](docs/operations.md) |
|
||||
|
||||
@@ -73,6 +73,8 @@ return function (RouteBuilder $routes): void {
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/reset', 'Admin::reset', ['_name' => 'admin:reset'])
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/clone', 'Admin::cloneAll', ['_name' => 'admin:clone'])
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/delete', 'Admin::delete', ['_name' => 'admin:delete'])
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/present', 'Admin::present', ['_name' => 'admin:present'])->setPatterns($token);
|
||||
|
||||
@@ -17,7 +17,7 @@ src/
|
||||
`protect()` (no-referrer/noindex/no-store für Seiten mit Geheimnis in der URL: Admin, Embed)
|
||||
HomeController Startseite, Anlegen (/create), Bestätigung, Join, Recover
|
||||
AdminAppController Basis für /admin/{token}: löst Poll über Token-Hash auf (404 sonst), setzt Privacy-Header (no-referrer, no-store)
|
||||
AdminController Dashboard, Settings, Present, State-JSON, Control, QR, PDF-Export, Token rotieren, Zurücksetzen, Löschen
|
||||
AdminController Dashboard, Settings, Present, State-JSON, Control, QR, PDF-Export, Token rotieren, Zurücksetzen, Kopieren (`cloneAll`), Löschen
|
||||
SlidesController Folien-CRUD, Ein-/Ausblenden (`visibility`), Duplizieren (`duplicate` → `SlidesTable::duplicate()`, Kopie direkt dahinter, öffnet das Formular der Kopie), Antworten offener Fragen bzw. Skala-Auswertung (`answers`), Sortieren (Drag & Drop/Pfeiltasten via `reorder`, JSON; erfordert JS), Antworten zurücksetzen,
|
||||
YouTube-Link prüfen (`youtubeCheck`, JSON)
|
||||
ParticipateController /p/{code}: Ansicht, State-JSON, Abstimmen, eigene Antwort/Kommentar bearbeiten; anonymes Cookie plenario_pid
|
||||
|
||||
+6
-6
@@ -37,13 +37,13 @@ Neue Farben als Token in beiden Dark-Blöcken von `plenario.css` pflegen; auf de
|
||||
(Presenter/Embed; baut DOM-Knoten, kein `innerHTML`). Regeln in beiden gleich halten (Regex `INLINE`/`LIST_ITEM`),
|
||||
Tests: `FormatHelperTest.php`.
|
||||
|
||||
## Vollbild & Display anlassen
|
||||
## Verwaltung: Menü-Drawer
|
||||
|
||||
- **Vollbild & Display anlassen** (Teilnehmeransicht, `initScreenTools` in `plenario.js`): zwei optionale Icon-Buttons im Header neben dem Farbschema-Schalter (Layout-Block `headerTools`)
|
||||
(`data-fullscreen-toggle`, `data-wakelock-toggle`), bleiben ohne Browser-Unterstützung versteckt (iPhone-Safari kennt kein Vollbild).
|
||||
Der Wake Lock ist standardmäßig an (braucht keine Nutzergeste); nur ein bewusstes Ausschalten wird gemerkt.
|
||||
Die Seite lädt bei Folienwechsel neu: der Wake Lock wird per `sessionStorage` (`plenario-wakelock`) wieder angefordert,
|
||||
Vollbild braucht eine Nutzergeste und muss nach dem Wechsel ggf. neu gewählt werden.
|
||||
- Die Seitenleiste der Verwaltung (Teilnahme, Einstellungen, PDF, Einbetten, Kopieren, Sicherheit) wird unter 900 px zu einem Drawer von rechts.
|
||||
Der Menü-Button (`data-drawer-toggle`, Layout-Block `headerMenu`) sitzt im Header rechts neben dem Farbschema-Schalter.
|
||||
`initDrawer` in `plenario.js` fügt dem `<aside>` die Klasse `sidebar--drawer` hinzu und zeigt den Button; ohne JS bleibt die
|
||||
Leiste ein normaler Block unter den Folien. Schließen: ✕, Klick auf den Hintergrund, Esc oder Anker-Link in der Leiste (`#export`, `#embed`).
|
||||
- Teilnehmeransicht: kein Vollbild- und kein Display-anlassen-Schalter (bewusst entfernt).
|
||||
|
||||
## Favicon
|
||||
|
||||
|
||||
@@ -56,6 +56,14 @@ Kein WebSocket: Presenter (`/admin/{token}/state`) und Teilnehmende (`/p/{code}/
|
||||
(`Slide::startFresh()`: Quiz `ready`, Q&A `collect`, sonst offen) – auch `add()` nutzt `startFresh()`.
|
||||
Tests: `DuplicateSlideTest.php`.
|
||||
|
||||
## Ganze Umfrage kopieren
|
||||
|
||||
- **Umfrage kopieren** (`admin:clone`, POST, Karte in der Verwaltung; `PollsTable::clonePoll()` + `SlidesTable::copyAllToPoll()`):
|
||||
neue Umfrage „… (Kopie)“ mit gleicher E-Mail, `comment_speed`, allen Folien (Einstellungen, Optionen inkl. richtiger Antworten,
|
||||
Ausblenden-Flag, Bilder als eigene Dateien) – **ohne Antworten**, nicht gestartet, mit neuem Code und neuem Admin-Link.
|
||||
Der Link geht wie beim Anlegen per Mail an den Besitzer, danach Weiterleitung zur Verwaltung der Kopie. Alles in einer Transaktion,
|
||||
bei Fehlern werden kopierte Bilddateien wieder gelöscht. Nutzt das Throttle-Bucket `create`.
|
||||
|
||||
## Einbettung
|
||||
|
||||
- **Einbettung** (`/e/{key}/{id}`, `EmbedController`): eigener `embed_key` statt Admin-Token (darf nur diese Folie zeigen,
|
||||
|
||||
@@ -20,6 +20,7 @@ use Cake\Routing\Router;
|
||||
use chillerlan\QRCode\Output\QRMarkupSVG;
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use chillerlan\QRCode\QROptions;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Poll level admin actions: dashboard, settings, presenter mode, export.
|
||||
@@ -141,6 +142,43 @@ class AdminController extends AdminAppController
|
||||
return $this->redirect($this->adminUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the whole presentation (slides, settings, images) without any responses into a new poll with
|
||||
* its own admin link, which is mailed to the owner like after creating a poll.
|
||||
*
|
||||
* @return \Cake\Http\Response|null
|
||||
*/
|
||||
public function cloneAll(): ?Response
|
||||
{
|
||||
$this->request->allowMethod(['post']);
|
||||
if (!$this->throttle('create', 'Plenario.throttle.createPerHour')) {
|
||||
$this->Flash->error(__('Zu viele Umfragen in kurzer Zeit. Bitte versuche es später noch einmal.'));
|
||||
|
||||
return $this->redirect($this->adminUrl());
|
||||
}
|
||||
|
||||
try {
|
||||
[$copy, $token] = $this->Polls->clonePoll($this->poll, $this->Slides->listForPoll($this->poll->id));
|
||||
} catch (Throwable) {
|
||||
$token = null;
|
||||
}
|
||||
if ($token === null) {
|
||||
$this->Flash->error(__('Die Umfrage konnte nicht kopiert werden.'));
|
||||
|
||||
return $this->redirect($this->adminUrl());
|
||||
}
|
||||
|
||||
$adminUrl = $this->adminUrlFor($token);
|
||||
$sent = (new PollMailer())->sendSafely('adminLink', [$copy, $adminUrl, $this->joinUrl($copy)]);
|
||||
if ($sent) {
|
||||
$this->Flash->success(__('Kopie angelegt, ohne Antworten. Der Admin-Link der Kopie wurde per E-Mail verschickt – speichere dir diese Seite als Lesezeichen.'));
|
||||
} else {
|
||||
$this->Flash->warning(__('Kopie angelegt, ohne Antworten. Die E-Mail mit dem Admin-Link konnte nicht verschickt werden – speichere dir diese Seite unbedingt als Lesezeichen!'));
|
||||
}
|
||||
|
||||
return $this->redirect($this->adminUrlFor($token));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the whole poll incl. slides and responses.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -353,18 +353,75 @@ class SlidesTable extends Table
|
||||
*/
|
||||
public function duplicate(Slide $slide): Slide
|
||||
{
|
||||
$copy = $this->newEmptyEntity();
|
||||
$copy->poll_id = $slide->poll_id;
|
||||
$copy->type = $slide->type;
|
||||
$images = new ImageService();
|
||||
$copy = $this->prepareCopy($slide, $slide->poll_id, $slide->position + 1, $images);
|
||||
$copy->question = mb_substr(__('{0} (Kopie)', $slide->question), 0, 500);
|
||||
|
||||
try {
|
||||
return $this->persistCopy($slide, $copy);
|
||||
} catch (Throwable $e) {
|
||||
// Rolled back: the copied file belongs to no slide.
|
||||
$images->delete($slide->poll_id, $copy->image);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies all slides of a poll (settings, options, correct answers, images, hidden flag) into another poll,
|
||||
* in the same order. Responses are not copied. All or nothing: on failure no slide and no image file remains.
|
||||
*
|
||||
* @param list<\App\Model\Entity\Slide> $slides Original slides incl. slide_options, in order
|
||||
* @param int $targetPollId Poll that receives the copies
|
||||
* @return void
|
||||
*/
|
||||
public function copyAllToPoll(array $slides, int $targetPollId): void
|
||||
{
|
||||
$images = new ImageService();
|
||||
$files = [];
|
||||
try {
|
||||
$this->getConnection()->transactional(function () use ($slides, $targetPollId, $images, &$files): void {
|
||||
foreach ($slides as $index => $slide) {
|
||||
$copy = $this->prepareCopy($slide, $targetPollId, $index + 1, $images);
|
||||
if ($copy->image !== null) {
|
||||
$files[] = $copy->image;
|
||||
}
|
||||
$copy->is_hidden = $slide->is_hidden;
|
||||
$this->saveOrFail($copy);
|
||||
$this->copyOptions($slide, $copy);
|
||||
}
|
||||
});
|
||||
} catch (Throwable $e) {
|
||||
foreach ($files as $file) {
|
||||
$images->delete($targetPollId, $file);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an unsaved copy of a slide for a poll; a fresh slide (nothing started) with its own image file.
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Original
|
||||
* @param int $pollId Poll of the copy
|
||||
* @param int $position Position of the copy
|
||||
* @param \App\Service\ImageService $images Image storage
|
||||
* @return \App\Model\Entity\Slide
|
||||
*/
|
||||
protected function prepareCopy(Slide $slide, int $pollId, int $position, ImageService $images): Slide
|
||||
{
|
||||
$copy = $this->newEmptyEntity();
|
||||
$copy->poll_id = $pollId;
|
||||
$copy->type = $slide->type;
|
||||
$copy->question = $slide->question;
|
||||
$copy->description = $slide->description;
|
||||
$copy->settings = $slide->settings;
|
||||
$copy->position = $slide->position + 1;
|
||||
$copy->position = $position;
|
||||
$copy->startFresh();
|
||||
|
||||
// The copy gets its own file, so deleting one slide never takes the image of the other.
|
||||
$images = new ImageService();
|
||||
$imageCopy = $slide->hasImage() ? $images->copy($slide->poll_id, (string)$slide->image) : null;
|
||||
$imageCopy = $slide->hasImage() ? $images->copy($pollId, (string)$slide->image, $slide->poll_id) : null;
|
||||
if ($imageCopy !== null) {
|
||||
$copy->image = $imageCopy;
|
||||
$copy->image_alt = $slide->image_alt;
|
||||
@@ -373,13 +430,26 @@ class SlidesTable extends Table
|
||||
$copy->image_height = $slide->image_height;
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->persistCopy($slide, $copy);
|
||||
} catch (Throwable $e) {
|
||||
// Rolled back: the copied file belongs to no slide.
|
||||
$images->delete($slide->poll_id, $imageCopy);
|
||||
return $copy;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
/**
|
||||
* Copies the options (with the correct answers) of a slide to its saved copy.
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Original incl. slide_options
|
||||
* @param \App\Model\Entity\Slide $copy Saved copy
|
||||
* @return void
|
||||
*/
|
||||
protected function copyOptions(Slide $slide, Slide $copy): void
|
||||
{
|
||||
foreach ($slide->slide_options ?? [] as $option) {
|
||||
$newOption = $this->SlideOptions->newEntity([
|
||||
'label' => $option->label,
|
||||
'position' => $option->position,
|
||||
]);
|
||||
$newOption->set('slide_id', $copy->id);
|
||||
$newOption->set('is_correct', $option->is_correct);
|
||||
$this->SlideOptions->saveOrFail($newOption);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,15 +468,7 @@ class SlidesTable extends Table
|
||||
['poll_id' => $slide->poll_id, 'position >' => $slide->position],
|
||||
);
|
||||
$this->saveOrFail($copy);
|
||||
foreach ($slide->slide_options ?? [] as $option) {
|
||||
$newOption = $this->SlideOptions->newEntity([
|
||||
'label' => $option->label,
|
||||
'position' => $option->position,
|
||||
]);
|
||||
$newOption->set('slide_id', $copy->id);
|
||||
$newOption->set('is_correct', $option->is_correct);
|
||||
$this->SlideOptions->saveOrFail($newOption);
|
||||
}
|
||||
$this->copyOptions($slide, $copy);
|
||||
$this->normalizePositions($slide->poll_id);
|
||||
|
||||
return $this->get($copy->id, contain: ['SlideOptions']);
|
||||
|
||||
@@ -119,19 +119,24 @@ class ImageService
|
||||
/**
|
||||
* Copies a stored image (duplicated slides get their own file, so deleting one never affects the other).
|
||||
*
|
||||
* @param int $pollId Poll id
|
||||
* @param int $pollId Poll id that receives the copy
|
||||
* @param string $name Source file name
|
||||
* @return string|null Name of the copy, null if the source file is gone
|
||||
* @param int|null $sourcePollId Poll id of the source file (default: the same poll)
|
||||
* @return string|null Name of the copy, null if the source file is gone or the copy failed
|
||||
*/
|
||||
public function copy(int $pollId, string $name): ?string
|
||||
public function copy(int $pollId, string $name, ?int $sourcePollId = null): ?string
|
||||
{
|
||||
$source = $this->path($pollId, $name);
|
||||
$source = $this->path($sourcePollId ?? $pollId, $name);
|
||||
if ($source === null) {
|
||||
return null;
|
||||
}
|
||||
$directory = $this->directory($pollId);
|
||||
if (!is_dir($directory) && !@mkdir($directory, 0775, true) && !is_dir($directory)) {
|
||||
return null;
|
||||
}
|
||||
$copy = bin2hex(random_bytes(12)) . '.webp';
|
||||
|
||||
return @copy($source, $this->directory($pollId) . DS . $copy) ? $copy : null;
|
||||
return @copy($source, $directory . DS . $copy) ? $copy : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,16 @@ $this->assign('noindex', '1');
|
||||
$url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $adminToken] + $params;
|
||||
$hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide->isInteractive() && $slide->isPrivate()) !== [];
|
||||
?>
|
||||
<?php // Phone/tablet: the sidebar (participation, settings, …) becomes a menu drawer opened from the header, right of the colour scheme switch. ?>
|
||||
<?php $this->start('headerMenu'); ?>
|
||||
<button type="button" class="theme-switch menu-toggle" data-drawer-toggle hidden aria-expanded="false" aria-controls="admin-menu"
|
||||
aria-label="<?= h(__('Menü: Teilnahme, Einstellungen und mehr')) ?>" title="<?= h(__('Menü')) ?>">
|
||||
<svg class="theme-switch__icon" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<path d="M4 6h16M4 12h16M4 18h16"/>
|
||||
</svg>
|
||||
</button>
|
||||
<?php $this->end(); ?>
|
||||
<div class="admin-head" data-refresh="head" data-live>
|
||||
<div>
|
||||
<p class="eyebrow"><?= __('Verwaltung') ?></p>
|
||||
@@ -226,7 +236,12 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<aside class="sidebar">
|
||||
<aside class="sidebar" id="admin-menu" aria-label="<?= h(__('Menü')) ?>">
|
||||
<div class="sidebar__bar" data-drawer-bar>
|
||||
<strong><?= __('Menü') ?></strong>
|
||||
<button type="button" class="modal__close sidebar__close" data-drawer-close
|
||||
aria-label="<?= h(__('Menü schließen')) ?>" title="<?= h(__('Schließen (Esc)')) ?>">✕</button>
|
||||
</div>
|
||||
<details class="card collapsible" open>
|
||||
<summary><h2><?= __('Teilnahme') ?></h2></summary>
|
||||
<p class="join-code"><?= h($poll->formattedJoinCode()) ?></p>
|
||||
@@ -305,6 +320,15 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
|
||||
]) ?>
|
||||
</details>
|
||||
|
||||
<details class="card collapsible" id="clone">
|
||||
<summary><h2><?= __('Umfrage kopieren') ?></h2></summary>
|
||||
<p class="hint"><?= __('Legt eine neue Umfrage mit allen Folien, Einstellungen und Bildern an – ohne Antworten und noch nicht gestartet. Die Kopie bekommt einen eigenen Teilnahme-Code und Admin-Link, der an dieselbe E-Mail-Adresse geschickt wird.') ?></p>
|
||||
<?= $this->Form->postButton(__('Umfrage kopieren'), $url('admin:clone'), [
|
||||
'class' => 'button button--small',
|
||||
'data-confirm' => __('Die Umfrage mit allen Folien (ohne Antworten) kopieren?'),
|
||||
]) ?>
|
||||
</details>
|
||||
|
||||
<details class="card card--danger collapsible">
|
||||
<summary><h2><?= __('Sicherheit') ?></h2></summary>
|
||||
<?php if ($poll->expiresAt() !== null) : ?>
|
||||
@@ -354,6 +378,8 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="drawer-backdrop" data-drawer-close aria-hidden="true"></div>
|
||||
|
||||
<?php // Slide form in a dialog (loaded via fetch, see [data-modal] in plenario.js); without JS the links open the full page. ?>
|
||||
<dialog class="modal" data-modal-dialog aria-labelledby="modal-title">
|
||||
<button type="button" class="modal__close" data-modal-close
|
||||
|
||||
@@ -40,27 +40,6 @@ $countdown = function (?int $remaining): string {
|
||||
|
||||
<p class="eyebrow eyebrow--poll center"><?= h($poll->title) ?></p>
|
||||
|
||||
<?php // Icon buttons in the header, next to the theme switch. Hidden unless the browser supports the API (no fullscreen on iPhone). ?>
|
||||
<?php $this->start('headerTools'); ?>
|
||||
<button type="button" class="theme-switch" data-fullscreen-toggle hidden aria-pressed="false"
|
||||
data-label-on="<?= h(__('Vollbild beenden')) ?>" data-label-off="<?= h(__('Vollbild')) ?>"
|
||||
aria-label="<?= h(__('Vollbild')) ?>" title="<?= h(__('Vollbild')) ?>">
|
||||
<svg class="theme-switch__icon" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button type="button" class="theme-switch" data-wakelock-toggle hidden aria-pressed="false"
|
||||
data-label-on="<?= h(__('Display bleibt an – tippen zum Ausschalten')) ?>"
|
||||
data-label-off="<?= h(__('Display bleibt nicht an – tippen zum Anlassen')) ?>"
|
||||
aria-label="<?= h(__('Display anlassen')) ?>" title="<?= h(__('Display anlassen')) ?>">
|
||||
<svg class="theme-switch__icon" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<path d="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>
|
||||
</svg>
|
||||
</button>
|
||||
<?php $this->end(); ?>
|
||||
|
||||
<?php if (!$poll->is_active) : ?>
|
||||
<section class="card center">
|
||||
<h1><?= __('Diese Umfrage ist geschlossen.') ?></h1>
|
||||
|
||||
@@ -33,8 +33,8 @@ $title = $this->fetch('title');
|
||||
<a href="<?= $this->Url->build(['_name' => 'recover']) ?>"><?= __('Admin-Link verloren?') ?></a>
|
||||
</nav>
|
||||
<div class="header-tools">
|
||||
<?= $this->fetch('headerTools') ?>
|
||||
<?= $this->element('theme_switch') ?>
|
||||
<?= $this->fetch('headerMenu') ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Test\TestCase\Controller;
|
||||
|
||||
use App\Model\Entity\Slide;
|
||||
use App\Service\VoteService;
|
||||
use App\Test\TestCase\PlenarioTestTrait;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
|
||||
/**
|
||||
* Cloning a whole poll without responses (admin:clone).
|
||||
*/
|
||||
class ClonePollTest extends TestCase
|
||||
{
|
||||
use IntegrationTestTrait;
|
||||
use PlenarioTestTrait;
|
||||
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->enableCsrfToken();
|
||||
}
|
||||
|
||||
public function testCopiesSlidesButNoResponses(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
$first = $this->createSlide($poll, Slide::TYPE_CHOICE, ['description' => '*Wichtig*'], ['Rot', 'Grün']);
|
||||
$quiz = $this->createSlide($poll, Slide::TYPE_QUIZ, [], ['Richtig', 'Falsch']);
|
||||
$hidden = $this->createSlide($poll, Slide::TYPE_OPEN);
|
||||
$hidden->is_hidden = true;
|
||||
$this->slidesTable()->saveOrFail($hidden);
|
||||
$poll = $this->goLive($poll, $first);
|
||||
(new VoteService())->submit($poll, $first, VoteService::participantHash(str_repeat('a', 32), $poll->id), [
|
||||
'option_id' => $first->slide_options[0]->id,
|
||||
]);
|
||||
|
||||
$this->post("/admin/$token/clone");
|
||||
|
||||
$polls = $this->pollsTable()->find()->orderBy(['id' => 'ASC'])->all()->toList();
|
||||
$this->assertCount(2, $polls);
|
||||
$copy = $polls[1];
|
||||
$this->assertNotSame($poll->join_code, $copy->join_code);
|
||||
$this->assertSame($poll->email, $copy->email);
|
||||
$this->assertStringEndsWith('(Kopie)', $copy->title);
|
||||
$this->assertNull($copy->current_slide_id, 'copy is not started');
|
||||
$this->assertSame($first->id, $this->pollsTable()->get($poll->id)->current_slide_id, 'original stays live');
|
||||
|
||||
$slides = $this->slidesTable()->listForPoll($copy->id);
|
||||
$this->assertSame([1, 2, 3], array_map(fn($s) => $s->position, $slides));
|
||||
$this->assertSame(
|
||||
[$first->question, $quiz->question, $hidden->question],
|
||||
array_map(fn($s) => $s->question, $slides),
|
||||
);
|
||||
$this->assertSame('*Wichtig*', $slides[0]->description);
|
||||
$this->assertSame(['Rot', 'Grün'], array_map(fn($o) => $o->label, $slides[0]->slide_options));
|
||||
$this->assertSame([true, false], array_map(fn($o) => $o->is_correct, $slides[1]->slide_options));
|
||||
$this->assertTrue($slides[2]->is_hidden);
|
||||
$this->assertSame(Slide::QUIZ_READY, $slides[1]->quizPhase());
|
||||
|
||||
$responses = TableRegistry::getTableLocator()->get('Responses');
|
||||
$this->assertSame(0, $responses->find()->matching('Slides', fn($q) => $q->where(['Slides.poll_id' => $copy->id]))->count());
|
||||
$this->assertSame(1, $responses->find()->where(['slide_id' => $first->id])->count(), 'original keeps its votes');
|
||||
$this->assertCount(3, $this->slidesTable()->listForPoll($poll->id));
|
||||
}
|
||||
|
||||
public function testRedirectsToAdminOfTheCopyOnlyViaPost(): void
|
||||
{
|
||||
[, $token] = $this->createPoll();
|
||||
|
||||
$this->get("/admin/$token/clone");
|
||||
$this->assertResponseCode(404);
|
||||
|
||||
$this->post("/admin/$token/clone");
|
||||
$this->assertResponseCode(302);
|
||||
$this->assertRedirectContains('/admin/');
|
||||
$this->assertHeaderNotContains('Location', $token);
|
||||
}
|
||||
|
||||
public function testDashboardOffersCloneAndMenu(): void
|
||||
{
|
||||
[, $token] = $this->createPoll();
|
||||
$this->get("/admin/$token");
|
||||
$this->assertResponseContains("/admin/$token/clone");
|
||||
$this->assertResponseContains('data-drawer-toggle');
|
||||
}
|
||||
}
|
||||
@@ -140,6 +140,32 @@ h3 { font-size: 1.05rem; margin-top: 1.6em; }
|
||||
.grid--sidebar { grid-template-columns: 1fr; }
|
||||
}
|
||||
|
||||
/* Sidebar as menu drawer (JS adds .sidebar--drawer; without JS the sidebar stays below the slides). */
|
||||
.menu-toggle { display: none; }
|
||||
.sidebar__bar { display: none; }
|
||||
.drawer-backdrop { display: none; }
|
||||
@media (max-width: 900px) {
|
||||
.menu-toggle:not([hidden]) { display: inline-flex; }
|
||||
.sidebar--drawer {
|
||||
position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
|
||||
width: min(92vw, 400px); padding: 0 16px 24px; overflow-y: auto; overscroll-behavior: contain;
|
||||
background: var(--bg); box-shadow: -8px 0 32px rgba(20, 22, 50, .25);
|
||||
visibility: hidden; transform: translateX(100%);
|
||||
transition: transform .2s ease, visibility 0s linear .2s;
|
||||
}
|
||||
.drawer-open .sidebar--drawer { visibility: visible; transform: none; transition: transform .2s ease; }
|
||||
.sidebar--drawer .sidebar__bar {
|
||||
position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
|
||||
margin: 0 -16px 16px; padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.sidebar--drawer .sidebar__close { position: static; }
|
||||
.drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(20, 22, 50, .45); }
|
||||
.drawer-open { overflow: hidden; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.sidebar--drawer { transition: none; }
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- components */
|
||||
.card {
|
||||
background: var(--surface);
|
||||
|
||||
+46
-81
@@ -1704,88 +1704,7 @@
|
||||
|
||||
// ------------------------------------------------------------------ participant
|
||||
|
||||
// Fullscreen and screen wake lock for the participant view (both optional, buttons stay hidden if unsupported).
|
||||
function initScreenTools(root) {
|
||||
function setPressed(button, on) {
|
||||
var text = button.getAttribute(on ? 'data-label-on' : 'data-label-off');
|
||||
button.setAttribute('aria-pressed', on ? 'true' : 'false');
|
||||
button.setAttribute('aria-label', text);
|
||||
button.title = text;
|
||||
}
|
||||
|
||||
// The buttons live in the layout header, outside the participant root.
|
||||
var fsButton = document.querySelector('[data-fullscreen-toggle]');
|
||||
if (fsButton && document.fullscreenEnabled) {
|
||||
fsButton.hidden = false;
|
||||
fsButton.addEventListener('click', function () {
|
||||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen();
|
||||
} else {
|
||||
document.documentElement.requestFullscreen().catch(function () {});
|
||||
}
|
||||
});
|
||||
// Also fires when leaving with Esc/back gesture.
|
||||
document.addEventListener('fullscreenchange', function () {
|
||||
setPressed(fsButton, !!document.fullscreenElement);
|
||||
});
|
||||
}
|
||||
|
||||
var wlButton = document.querySelector('[data-wakelock-toggle]');
|
||||
if (wlButton && 'wakeLock' in navigator) {
|
||||
// The page reloads on every slide change, so the choice is kept per tab and re-applied on load.
|
||||
var STORE = 'plenario-wakelock';
|
||||
// On by default; only an explicit "off" is remembered.
|
||||
var wanted = true;
|
||||
var sentinel = null;
|
||||
try {
|
||||
wanted = sessionStorage.getItem(STORE) !== '0';
|
||||
} catch (e) {
|
||||
// storage blocked: choice only lasts until the next slide
|
||||
}
|
||||
var remember = function () {
|
||||
try {
|
||||
sessionStorage.setItem(STORE, wanted ? '1' : '0');
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
};
|
||||
|
||||
var acquire = function () {
|
||||
if (!wanted || sentinel || document.visibilityState !== 'visible') {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return navigator.wakeLock.request('screen').then(function (lock) {
|
||||
sentinel = lock;
|
||||
// The browser releases the lock when the tab is hidden; re-acquired on return.
|
||||
lock.addEventListener('release', function () {
|
||||
sentinel = null;
|
||||
});
|
||||
}).catch(function () {
|
||||
wanted = false; // denied (e.g. battery saver)
|
||||
remember();
|
||||
setPressed(wlButton, false);
|
||||
});
|
||||
};
|
||||
|
||||
wlButton.hidden = false;
|
||||
setPressed(wlButton, wanted);
|
||||
acquire();
|
||||
wlButton.addEventListener('click', function () {
|
||||
wanted = !wanted;
|
||||
remember();
|
||||
setPressed(wlButton, wanted);
|
||||
if (wanted) {
|
||||
acquire();
|
||||
} else if (sentinel) {
|
||||
sentinel.release();
|
||||
}
|
||||
});
|
||||
document.addEventListener('visibilitychange', acquire);
|
||||
}
|
||||
}
|
||||
|
||||
function initParticipant(root) {
|
||||
initScreenTools(root);
|
||||
var stateUrl = root.getAttribute('data-state-url');
|
||||
var voteUrl = root.getAttribute('data-vote-url');
|
||||
var version = root.getAttribute('data-version');
|
||||
@@ -3161,10 +3080,56 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Admin menu drawer: below 900px the sidebar slides in from the right (CSS), opened by the header button.
|
||||
// Without JS the button stays hidden and the sidebar remains a normal block below the slides.
|
||||
function initDrawer() {
|
||||
var toggle = document.querySelector('[data-drawer-toggle]');
|
||||
var drawer = toggle ? document.getElementById(toggle.getAttribute('aria-controls')) : null;
|
||||
if (!toggle || !drawer) {
|
||||
return;
|
||||
}
|
||||
var root = document.body;
|
||||
drawer.classList.add('sidebar--drawer');
|
||||
toggle.hidden = false;
|
||||
|
||||
function setOpen(open) {
|
||||
root.classList.toggle('drawer-open', open);
|
||||
toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
|
||||
if (open) {
|
||||
var close = drawer.querySelector('[data-drawer-close]');
|
||||
if (close) {
|
||||
close.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
toggle.addEventListener('click', function () {
|
||||
setOpen(!root.classList.contains('drawer-open'));
|
||||
});
|
||||
document.addEventListener('click', function (event) {
|
||||
var target = event.target.closest ? event.target.closest('[data-drawer-close], a[href^="#"]') : null;
|
||||
if (target && root.classList.contains('drawer-open') && (target.hasAttribute('data-drawer-close') || drawer.contains(target))) {
|
||||
setOpen(false);
|
||||
}
|
||||
});
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Escape' && root.classList.contains('drawer-open') && !document.querySelector('dialog[open]')) {
|
||||
setOpen(false);
|
||||
toggle.focus();
|
||||
}
|
||||
});
|
||||
// Back to a wide screen: the sidebar is a normal column again.
|
||||
window.addEventListener('resize', function () {
|
||||
if (window.innerWidth > 900 && root.classList.contains('drawer-open')) {
|
||||
setOpen(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.querySelectorAll('[data-theme-switch]').forEach(initThemeSwitch);
|
||||
initWidgets(document);
|
||||
initShare();
|
||||
initDrawer();
|
||||
initQrDownload();
|
||||
initAdminDashboard();
|
||||
document.querySelectorAll('[data-presenter]').forEach(initPresenter);
|
||||
|
||||
Reference in new issue
Block a user