Participants can now always submit any number of words. Drops the max_words setting, its form field, the limit checks in VoteService and the remaining/limitReached state; existing max_words values in stored settings are ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
104 lines
5.1 KiB
PHP
104 lines
5.1 KiB
PHP
<?php
|
|
/**
|
|
* Add / edit form for slides. Type specific fields are rendered per type;
|
|
* the type itself cannot be changed after creation.
|
|
*
|
|
* @var \App\View\AppView $this
|
|
* @var \App\Model\Entity\Poll $poll
|
|
* @var string $adminToken
|
|
* @var \App\Model\Entity\Slide $slide
|
|
* @var string $optionsText
|
|
* @var bool|null $hasResponses
|
|
*/
|
|
$isNew = $slide->isNew();
|
|
$settings = $slide->getSettings();
|
|
$this->assign('title', $isNew ? __('Neue Folie') : __('Folie bearbeiten'));
|
|
$this->assign('noindex', '1');
|
|
$formUrl = $isNew
|
|
? ['_name' => 'slides:add', 'token' => $adminToken, '?' => ['type' => $slide->type]]
|
|
: ['_name' => 'slides:edit', 'token' => $adminToken, 'id' => $slide->id];
|
|
$optionsError = $slide->getError('options_text');
|
|
?>
|
|
<p><a href="<?= $this->Url->build(['_name' => 'admin', 'token' => $adminToken]) ?>">← <?= __('Zurück zu „{0}“', h($poll->title)) ?></a></p>
|
|
|
|
<section class="card card--form">
|
|
<p class="eyebrow"><?= h($slide->typeLabel()) ?></p>
|
|
<h1><?= $isNew ? __('Neue Folie') : __('Folie bearbeiten') ?></h1>
|
|
|
|
<?= $this->Form->create($slide, ['url' => $formUrl]) ?>
|
|
<?= $this->Form->hidden('type') ?>
|
|
<?= $this->Form->control('question', [
|
|
'label' => $slide->type === 'content' ? __('Überschrift') : __('Frage'),
|
|
'maxlength' => 500,
|
|
'required' => true,
|
|
'autofocus' => $isNew,
|
|
]) ?>
|
|
<?= $this->Form->control('description', [
|
|
'type' => 'textarea',
|
|
'rows' => $slide->type === 'content' ? 6 : 2,
|
|
'label' => $slide->type === 'content' ? __('Text') : __('Beschreibung (optional)'),
|
|
]) ?>
|
|
|
|
<?php if ($slide->type === 'choice') : ?>
|
|
<div class="input textarea<?= $optionsError ? ' error' : '' ?>">
|
|
<label for="options-text"><?= __('Antwortoptionen (eine pro Zeile, max. 20)') ?></label>
|
|
<textarea id="options-text" name="options_text" rows="6" required><?= h($optionsText) ?></textarea>
|
|
<?php if ($optionsError) : ?>
|
|
<div class="error-message"><?= h(implode(' ', (array)$optionsError)) ?></div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($hasResponses)) : ?>
|
|
<p class="hint"><?= __('Achtung: Entfernte oder umbenannte Optionen verlieren ihre bisherigen Stimmen.') ?></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?= $this->Form->control('settings.multiple', [
|
|
'type' => 'checkbox',
|
|
'label' => __('Mehrfachauswahl erlauben'),
|
|
'checked' => (bool)$settings['multiple'],
|
|
]) ?>
|
|
<?php elseif ($slide->type === 'wordcloud') : ?>
|
|
<?= $this->Form->control('settings.allow_upvotes', [
|
|
'type' => 'checkbox',
|
|
'label' => __('Upvotes erlauben (Teilnehmende sehen die Wortwolke live und können Begriffe per Klick unterstützen)'),
|
|
'checked' => (bool)$settings['allow_upvotes'],
|
|
]) ?>
|
|
<?= $this->Form->control('settings.allow_downvotes', [
|
|
'type' => 'checkbox',
|
|
'label' => __('Downvotes erlauben (nur zusammen mit Upvotes: Teilnehmende können Begriffe anderer ablehnen)'),
|
|
'checked' => (bool)$settings['allow_downvotes'],
|
|
]) ?>
|
|
<?php elseif ($slide->type === 'scale') : ?>
|
|
<div class="grid grid--2 grid--tight">
|
|
<?= $this->Form->control('settings.scale_min', [
|
|
'type' => 'select', 'options' => [0 => '0', 1 => '1'],
|
|
'label' => __('Von'), 'value' => $settings['scale_min'],
|
|
]) ?>
|
|
<?= $this->Form->control('settings.scale_max', [
|
|
'type' => 'select', 'options' => array_combine(range(2, 10), range(2, 10)),
|
|
'label' => __('Bis'), 'value' => $settings['scale_max'],
|
|
]) ?>
|
|
<?= $this->Form->control('settings.min_label', [
|
|
'label' => __('Beschriftung links (optional)'), 'maxlength' => 60,
|
|
'placeholder' => __('z. B. gar nicht'), 'value' => $settings['min_label'],
|
|
]) ?>
|
|
<?= $this->Form->control('settings.max_label', [
|
|
'label' => __('Beschriftung rechts (optional)'), 'maxlength' => 60,
|
|
'placeholder' => __('z. B. sehr'), 'value' => $settings['max_label'],
|
|
]) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($slide->isInteractive()) : ?>
|
|
<?= $this->Form->control('is_voting_open', [
|
|
'type' => 'checkbox',
|
|
'label' => __('Abstimmung geöffnet'),
|
|
'checked' => $isNew ? true : $slide->is_voting_open,
|
|
]) ?>
|
|
<?php endif; ?>
|
|
|
|
<div class="form-actions">
|
|
<?= $this->Form->button($isNew ? __('Folie anlegen') : __('Speichern'), ['class' => 'button button--primary']) ?>
|
|
<a class="button button--ghost" href="<?= $this->Url->build(['_name' => 'admin', 'token' => $adminToken]) ?>"><?= __('Abbrechen') ?></a>
|
|
</div>
|
|
<?= $this->Form->end() ?>
|
|
</section>
|