Merge pull request 'Feature/slide images' (#81) from feature/slide-images into main
Reviewed-on: #81
This commit was merged in pull request #81.
This commit is contained in:
commit
3c07eba7db
7 files changed
+55
-64
No files matched your search
@@ -215,7 +215,7 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
|
|||||||
Ablage `{Plenario.images.path}/{poll_id}/{24 Hex}.webp` (Standard `data/uploads`, Docker `/data/uploads`) **außerhalb von `webroot/`**,
|
Ablage `{Plenario.images.path}/{poll_id}/{24 Hex}.webp` (Standard `data/uploads`, Docker `/data/uploads`) **außerhalb von `webroot/`**,
|
||||||
ausgeliefert über `participate:image` (`/p/{code}/img/{file}`, auch für Presenter und Einbettung; nur Dateien dieser Umfrage, `immutable`
|
ausgeliefert über `participate:image` (`/p/{code}/img/{file}`, auch für Presenter und Einbettung; nur Dateien dieser Umfrage, `immutable`
|
||||||
gecacht, kein Cookie). Jedes neue Bild bekommt einen neuen Namen → neue URL, ersetzte Bilder sind sofort 404.
|
gecacht, kein Cookie). Jedes neue Bild bekommt einen neuen Namen → neue URL, ersetzte Bilder sind sofort 404.
|
||||||
Alt-Text ist Pflicht (`image_alt`), außer „Reine Dekoration“ (`image_alt = ''`). Layout `image_layout` (`top`|`side`|`full`, `full` nur
|
Eine Bildbeschreibung wird bewusst nicht abgefragt (`image_alt` bleibt `""`, die Spalte ist ungenutzt): Bilder sind Beamer-Dekoration. Nie Pflichtfelder zum Bild einführen, die den Upload verwerfen: das Dateifeld lässt sich nach einem Fehler nicht neu füllen. Layout `image_layout` (`top`|`side`|`full`, `full` nur
|
||||||
Inhaltsfolien, `null` = Standard je Typ: Inhaltsfolie `side`, sonst `top`; `Slide::imageLayout()`); `side` gilt nur für die Bühne
|
Inhaltsfolien, `null` = Standard je Typ: Inhaltsfolie `side`, sonst `top`; `Slide::imageLayout()`); `side` gilt nur für die Bühne
|
||||||
(CSS `stage--img-*`), Teilnehmende sehen das Bild immer oben (`element/slide_image`). Kontingent `Plenario.images.maxPerPoll` Folien mit Bild.
|
(CSS `stage--img-*`), Teilnehmende sehen das Bild immer oben (`element/slide_image`). Kontingent `Plenario.images.maxPerPoll` Folien mit Bild.
|
||||||
Im State steht `slide.image` = `{url, alt, layout, width, height}` (`PollStateService::slidePayload()`).
|
Im State steht `slide.image` = `{url, alt, layout, width, height}` (`PollStateService::slidePayload()`).
|
||||||
|
|||||||
@@ -415,15 +415,10 @@ class SlidesController extends AdminAppController
|
|||||||
|
|
||||||
return $state;
|
return $state;
|
||||||
}
|
}
|
||||||
// Without an image to describe, accessibility needs either a text or the explicit "decorative".
|
|
||||||
$alt = mb_substr(trim((string)($data['image_alt'] ?? '')), 0, Slide::IMAGE_ALT_MAX);
|
|
||||||
$decorative = filter_var($data['image_decorative'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
|
||||||
if (!$decorative && $alt === '') {
|
|
||||||
$errors['image_alt'] = __('Bitte beschreibe das Bild kurz (für Menschen mit Screenreader) oder markiere es als reine Dekoration.');
|
|
||||||
}
|
|
||||||
$layout = $data['image_layout'] ?? null;
|
$layout = $data['image_layout'] ?? null;
|
||||||
$slide->patch([
|
$slide->patch([
|
||||||
'image_alt' => $decorative ? '' : $alt,
|
// Presentation images are decoration: no description is asked for (alt="").
|
||||||
|
'image_alt' => '',
|
||||||
'image_layout' => in_array($layout, Slide::IMAGE_LAYOUTS, true) ? $layout : null,
|
'image_layout' => in_array($layout, Slide::IMAGE_LAYOUTS, true) ? $layout : null,
|
||||||
], ['guard' => false]);
|
], ['guard' => false]);
|
||||||
$this->setErrors($slide, $errors);
|
$this->setErrors($slide, $errors);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use Cake\ORM\Entity;
|
|||||||
* @property bool $is_hidden Prepared, but skipped in the presentation (never live)
|
* @property bool $is_hidden Prepared, but skipped in the presentation (never live)
|
||||||
* @property array<string, mixed>|null $settings
|
* @property array<string, mixed>|null $settings
|
||||||
* @property string|null $image File name of the slide image in the poll's upload directory (see ImageService)
|
* @property string|null $image File name of the slide image in the poll's upload directory (see ImageService)
|
||||||
* @property string|null $image_alt Alternative text of the image, '' = decorative
|
* @property string|null $image_alt Always '' (decorative): images are shown on the stage, no description is asked for
|
||||||
* @property string|null $image_layout top|side|full, null = default of the type (see imageLayout())
|
* @property string|null $image_layout top|side|full, null = default of the type (see imageLayout())
|
||||||
* @property int|null $image_width Pixels of the stored (scaled) image
|
* @property int|null $image_width Pixels of the stored (scaled) image
|
||||||
* @property int|null $image_height
|
* @property int|null $image_height
|
||||||
@@ -149,11 +149,6 @@ class Slide extends Entity
|
|||||||
public const IMAGE_FULL = 'full';
|
public const IMAGE_FULL = 'full';
|
||||||
public const IMAGE_LAYOUTS = [self::IMAGE_TOP, self::IMAGE_SIDE, self::IMAGE_FULL];
|
public const IMAGE_LAYOUTS = [self::IMAGE_TOP, self::IMAGE_SIDE, self::IMAGE_FULL];
|
||||||
|
|
||||||
/**
|
|
||||||
* Longest alternative text.
|
|
||||||
*/
|
|
||||||
public const IMAGE_ALT_MAX = 255;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array<string, bool>
|
* @var array<string, bool>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ $request = $this->getRequest();
|
|||||||
$posted = $request->is(['post', 'put', 'patch']);
|
$posted = $request->is(['post', 'put', 'patch']);
|
||||||
$hasImage = $slide->hasImage();
|
$hasImage = $slide->hasImage();
|
||||||
// After a failed save the posted values are shown again.
|
// After a failed save the posted values are shown again.
|
||||||
$alt = $posted ? (string)$request->getData('image_alt', '') : (string)$slide->image_alt;
|
|
||||||
$decorative = $posted
|
|
||||||
? filter_var($request->getData('image_decorative'), FILTER_VALIDATE_BOOLEAN)
|
|
||||||
: ($hasImage && $slide->image_alt === '');
|
|
||||||
$layout = $posted && in_array($request->getData('image_layout'), Slide::IMAGE_LAYOUTS, true)
|
$layout = $posted && in_array($request->getData('image_layout'), Slide::IMAGE_LAYOUTS, true)
|
||||||
? (string)$request->getData('image_layout')
|
? (string)$request->getData('image_layout')
|
||||||
: $slide->imageLayout();
|
: $slide->imageLayout();
|
||||||
@@ -34,7 +30,6 @@ if ($slide->type === Slide::TYPE_CONTENT) {
|
|||||||
$layouts[Slide::IMAGE_FULL] = __('Bildschirm füllen (Bild so groß wie möglich)');
|
$layouts[Slide::IMAGE_FULL] = __('Bildschirm füllen (Bild so groß wie möglich)');
|
||||||
}
|
}
|
||||||
$imageError = $slide->getError('image');
|
$imageError = $slide->getError('image');
|
||||||
$altError = $slide->getError('image_alt');
|
|
||||||
$maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 * 1024 * 1024) / 1024 / 1024);
|
$maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 * 1024 * 1024) / 1024 / 1024);
|
||||||
?>
|
?>
|
||||||
<fieldset class="image-fields" data-image-fields>
|
<fieldset class="image-fields" data-image-fields>
|
||||||
@@ -47,6 +42,8 @@ $maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 *
|
|||||||
<img src="<?= h($this->Url->build(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $slide->image])) ?>"
|
<img src="<?= h($this->Url->build(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $slide->image])) ?>"
|
||||||
alt="<?= h((string)$slide->image_alt) ?>" width="<?= (int)$slide->image_width ?>" height="<?= (int)$slide->image_height ?>">
|
alt="<?= h((string)$slide->image_alt) ?>" width="<?= (int)$slide->image_width ?>" height="<?= (int)$slide->image_height ?>">
|
||||||
</figure>
|
</figure>
|
||||||
|
<?php // Without JavaScript the checkbox does the job; with it, the button toggles the same checkbox. ?>
|
||||||
|
<div class="image-fields__remove" data-image-remove>
|
||||||
<?= $this->Form->control('remove_image', [
|
<?= $this->Form->control('remove_image', [
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'label' => __('Bild entfernen'),
|
'label' => __('Bild entfernen'),
|
||||||
@@ -54,6 +51,16 @@ $maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 *
|
|||||||
'hiddenField' => false,
|
'hiddenField' => false,
|
||||||
'checked' => false,
|
'checked' => false,
|
||||||
]) ?>
|
]) ?>
|
||||||
|
<button type="button" class="button button--danger button--small" hidden aria-pressed="false" data-image-remove-button
|
||||||
|
data-label-remove="<?= h(__('Bild entfernen')) ?>" data-label-undo="<?= h(__('Entfernen rückgängig machen')) ?>">
|
||||||
|
<svg 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="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14M10 11v5M14 11v5"/>
|
||||||
|
</svg>
|
||||||
|
<span data-label><?= __('Bild entfernen') ?></span>
|
||||||
|
</button>
|
||||||
|
<span class="hint" role="status" aria-live="polite" data-image-remove-status></span>
|
||||||
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="input file<?= $imageError ? ' error' : '' ?>">
|
<div class="input file<?= $imageError ? ' error' : '' ?>">
|
||||||
<label for="image-file"><?= $hasImage ? __('Anderes Bild hochladen') : __('Bild hochladen') ?></label>
|
<label for="image-file"><?= $hasImage ? __('Anderes Bild hochladen') : __('Bild hochladen') ?></label>
|
||||||
@@ -64,23 +71,6 @@ $maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 *
|
|||||||
<div class="error-message" id="image-error"><?= h(implode(' ', (array)$imageError)) ?></div>
|
<div class="error-message" id="image-error"><?= h(implode(' ', (array)$imageError)) ?></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="input text<?= $altError ? ' error' : '' ?>">
|
|
||||||
<label for="image-alt"><?= __('Bildbeschreibung (für Screenreader)') ?></label>
|
|
||||||
<input type="text" id="image-alt" name="image_alt" maxlength="<?= Slide::IMAGE_ALT_MAX ?>" autocomplete="off"
|
|
||||||
value="<?= h($alt) ?>" placeholder="<?= h(__('z. B. Organigramm des Vereins')) ?>"
|
|
||||||
aria-describedby="image-alt-hint<?= $altError ? ' image-alt-error' : '' ?>" <?= $altError ? 'aria-invalid="true"' : '' ?>>
|
|
||||||
<p class="hint" id="image-alt-hint"><?= __('Pflicht, sobald ein Bild gesetzt ist – oder das Bild ist reine Dekoration.') ?></p>
|
|
||||||
<?php if ($altError) : ?>
|
|
||||||
<div class="error-message" id="image-alt-error"><?= h(implode(' ', (array)$altError)) ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
<?= $this->Form->control('image_decorative', [
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'label' => __('Reine Dekoration (keine Beschreibung nötig)'),
|
|
||||||
'value' => '1',
|
|
||||||
'hiddenField' => false,
|
|
||||||
'checked' => $decorative,
|
|
||||||
]) ?>
|
|
||||||
<fieldset class="scale-style image-fields__layout">
|
<fieldset class="scale-style image-fields__layout">
|
||||||
<legend><?= __('Platzierung in der Präsentation') ?></legend>
|
<legend><?= __('Platzierung in der Präsentation') ?></legend>
|
||||||
<?= $this->Form->radio('image_layout', array_map(
|
<?= $this->Form->radio('image_layout', array_map(
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ class SlideImageTest extends TestCase
|
|||||||
$this->postWithImage("/admin/$token/slides/add?type=content", $data + [
|
$this->postWithImage("/admin/$token/slides/add?type=content", $data + [
|
||||||
'type' => 'content',
|
'type' => 'content',
|
||||||
'question' => 'Mit Bild',
|
'question' => 'Mit Bild',
|
||||||
'image_alt' => 'Ein roter Kreis',
|
|
||||||
], $this->makeImage(3000, 2000));
|
], $this->makeImage(3000, 2000));
|
||||||
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->first();
|
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->first();
|
||||||
|
|
||||||
@@ -62,7 +61,6 @@ class SlideImageTest extends TestCase
|
|||||||
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
|
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
|
||||||
$this->assertNotNull($slide);
|
$this->assertNotNull($slide);
|
||||||
$this->assertTrue($slide->hasImage());
|
$this->assertTrue($slide->hasImage());
|
||||||
$this->assertSame('Ein roter Kreis', $slide->image_alt);
|
|
||||||
$this->assertSame([1600, 1067], [$slide->image_width, $slide->image_height]);
|
$this->assertSame([1600, 1067], [$slide->image_width, $slide->image_height]);
|
||||||
$this->assertSame(Slide::IMAGE_FULL, $slide->imageLayout());
|
$this->assertSame(Slide::IMAGE_FULL, $slide->imageLayout());
|
||||||
$this->assertSame([$slide->image], $this->storedImages($poll->id));
|
$this->assertSame([$slide->image], $this->storedImages($poll->id));
|
||||||
@@ -77,27 +75,19 @@ class SlideImageTest extends TestCase
|
|||||||
$this->assertSame(Slide::IMAGE_TOP, $choice->imageLayout(), 'full exists for content slides only');
|
$this->assertSame(Slide::IMAGE_TOP, $choice->imageLayout(), 'full exists for content slides only');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImageNeedsAltTextOrDecorativeFlag(): void
|
public function testNoDescriptionIsNeeded(): void
|
||||||
{
|
{
|
||||||
[$poll, $token] = $this->createPoll();
|
[$poll, $token] = $this->createPoll();
|
||||||
$this->postWithImage("/admin/$token/slides/add?type=content", [
|
$this->postWithImage("/admin/$token/slides/add?type=content", [
|
||||||
'type' => 'content',
|
'type' => 'content',
|
||||||
'question' => 'Ohne Text',
|
'question' => 'Ohne Beschreibung',
|
||||||
], $this->makeImage());
|
], $this->makeImage());
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
|
||||||
$this->assertResponseContains('Bitte beschreibe das Bild');
|
|
||||||
$this->assertSame(0, $this->slidesTable()->find()->where(['poll_id' => $poll->id])->count());
|
|
||||||
$this->assertSame([], $this->storedImages($poll->id), 'no file left behind');
|
|
||||||
|
|
||||||
$this->postWithImage("/admin/$token/slides/add?type=content", [
|
|
||||||
'type' => 'content',
|
|
||||||
'question' => 'Dekoration',
|
|
||||||
'image_decorative' => '1',
|
|
||||||
], $this->makeImage());
|
|
||||||
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->firstOrFail();
|
$slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->firstOrFail();
|
||||||
$this->assertSame('', $slide->image_alt);
|
|
||||||
$this->assertTrue($slide->hasImage());
|
$this->assertTrue($slide->hasImage());
|
||||||
|
$this->assertSame('', $slide->image_alt);
|
||||||
|
$this->assertSame([$slide->image], $this->storedImages($poll->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRejectsFilesThatAreNoImages(): void
|
public function testRejectsFilesThatAreNoImages(): void
|
||||||
@@ -110,7 +100,6 @@ class SlideImageTest extends TestCase
|
|||||||
$this->postWithImage("/admin/$token/slides/add?type=content", [
|
$this->postWithImage("/admin/$token/slides/add?type=content", [
|
||||||
'type' => 'content',
|
'type' => 'content',
|
||||||
'question' => 'Kein Bild',
|
'question' => 'Kein Bild',
|
||||||
'image_alt' => 'x',
|
|
||||||
], $path, UPLOAD_ERR_OK, 'text.jpg');
|
], $path, UPLOAD_ERR_OK, 'text.jpg');
|
||||||
|
|
||||||
$this->assertResponseContains('JPEG, PNG, WebP oder GIF');
|
$this->assertResponseContains('JPEG, PNG, WebP oder GIF');
|
||||||
@@ -124,7 +113,6 @@ class SlideImageTest extends TestCase
|
|||||||
|
|
||||||
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
|
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
|
||||||
'question' => '',
|
'question' => '',
|
||||||
'image_alt' => 'neu',
|
|
||||||
], $this->makeImage(100, 100));
|
], $this->makeImage(100, 100));
|
||||||
|
|
||||||
$this->assertResponseContains('Bitte prüfe deine Eingaben');
|
$this->assertResponseContains('Bitte prüfe deine Eingaben');
|
||||||
@@ -140,7 +128,6 @@ class SlideImageTest extends TestCase
|
|||||||
$this->postWithImage("/admin/$token/slides/add?type=content", [
|
$this->postWithImage("/admin/$token/slides/add?type=content", [
|
||||||
'type' => 'content',
|
'type' => 'content',
|
||||||
'question' => 'Zweites Bild',
|
'question' => 'Zweites Bild',
|
||||||
'image_alt' => 'x',
|
|
||||||
], $this->makeImage());
|
], $this->makeImage());
|
||||||
|
|
||||||
$this->assertResponseContains('höchstens 1 Folien mit Bild');
|
$this->assertResponseContains('höchstens 1 Folien mit Bild');
|
||||||
@@ -155,7 +142,6 @@ class SlideImageTest extends TestCase
|
|||||||
|
|
||||||
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
|
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
|
||||||
'question' => 'Mit Bild',
|
'question' => 'Mit Bild',
|
||||||
'image_alt' => 'Neu',
|
|
||||||
], $this->makeImage(300, 200));
|
], $this->makeImage(300, 200));
|
||||||
|
|
||||||
$slide = $this->slidesTable()->get($slide->id);
|
$slide = $this->slidesTable()->get($slide->id);
|
||||||
@@ -170,13 +156,11 @@ class SlideImageTest extends TestCase
|
|||||||
|
|
||||||
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
|
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
|
||||||
'question' => 'Mit Bild',
|
'question' => 'Mit Bild',
|
||||||
'image_alt' => 'Anderer Text',
|
|
||||||
'image_layout' => 'top',
|
'image_layout' => 'top',
|
||||||
], $this->makeImage(), UPLOAD_ERR_NO_FILE);
|
], $this->makeImage(), UPLOAD_ERR_NO_FILE);
|
||||||
|
|
||||||
$after = $this->slidesTable()->get($slide->id);
|
$after = $this->slidesTable()->get($slide->id);
|
||||||
$this->assertSame($slide->image, $after->image);
|
$this->assertSame($slide->image, $after->image);
|
||||||
$this->assertSame('Anderer Text', $after->image_alt);
|
|
||||||
$this->assertSame(Slide::IMAGE_TOP, $after->imageLayout());
|
$this->assertSame(Slide::IMAGE_TOP, $after->imageLayout());
|
||||||
$this->assertSame([$slide->image], $this->storedImages($poll->id));
|
$this->assertSame([$slide->image], $this->storedImages($poll->id));
|
||||||
}
|
}
|
||||||
@@ -190,7 +174,6 @@ class SlideImageTest extends TestCase
|
|||||||
|
|
||||||
$after = $this->slidesTable()->get($slide->id);
|
$after = $this->slidesTable()->get($slide->id);
|
||||||
$this->assertFalse($after->hasImage());
|
$this->assertFalse($after->hasImage());
|
||||||
$this->assertNull($after->image_alt);
|
|
||||||
$this->assertSame([], $this->storedImages($poll->id));
|
$this->assertSame([], $this->storedImages($poll->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +196,6 @@ class SlideImageTest extends TestCase
|
|||||||
$this->postWithImage("/admin/$token/slides/add?type=content", [
|
$this->postWithImage("/admin/$token/slides/add?type=content", [
|
||||||
'type' => 'content',
|
'type' => 'content',
|
||||||
'question' => 'Zweites',
|
'question' => 'Zweites',
|
||||||
'image_alt' => 'x',
|
|
||||||
], $this->makeImage());
|
], $this->makeImage());
|
||||||
$this->assertCount(2, $this->storedImages($poll->id));
|
$this->assertCount(2, $this->storedImages($poll->id));
|
||||||
|
|
||||||
@@ -233,7 +215,6 @@ class SlideImageTest extends TestCase
|
|||||||
$copy = $slides[1];
|
$copy = $slides[1];
|
||||||
$this->assertTrue($copy->hasImage());
|
$this->assertTrue($copy->hasImage());
|
||||||
$this->assertNotSame($slide->image, $copy->image);
|
$this->assertNotSame($slide->image, $copy->image);
|
||||||
$this->assertSame('Ein roter Kreis', $copy->image_alt);
|
|
||||||
$this->assertSame(Slide::IMAGE_TOP, $copy->imageLayout());
|
$this->assertSame(Slide::IMAGE_TOP, $copy->imageLayout());
|
||||||
$this->assertCount(2, $this->storedImages($poll->id));
|
$this->assertCount(2, $this->storedImages($poll->id));
|
||||||
|
|
||||||
@@ -287,7 +268,6 @@ class SlideImageTest extends TestCase
|
|||||||
$old = $slide->image;
|
$old = $slide->image;
|
||||||
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
|
$this->postWithImage("/admin/$token/slides/{$slide->id}/edit", [
|
||||||
'question' => 'Mit Bild',
|
'question' => 'Mit Bild',
|
||||||
'image_alt' => 'Neu',
|
|
||||||
], $this->makeImage(300, 200));
|
], $this->makeImage(300, 200));
|
||||||
|
|
||||||
$this->get(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $old]);
|
$this->get(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $old]);
|
||||||
@@ -302,14 +282,14 @@ class SlideImageTest extends TestCase
|
|||||||
|
|
||||||
$this->get("/admin/$token/state");
|
$this->get("/admin/$token/state");
|
||||||
$payload = json_decode((string)$this->_response->getBody(), true)['slide'];
|
$payload = json_decode((string)$this->_response->getBody(), true)['slide'];
|
||||||
$this->assertSame('Ein roter Kreis', $payload['image']['alt']);
|
$this->assertSame('', $payload['image']['alt']);
|
||||||
$this->assertSame('side', $payload['image']['layout']);
|
$this->assertSame('side', $payload['image']['layout']);
|
||||||
$this->assertSame("/p/{$poll->join_code}/img/{$slide->image}", $payload['image']['url']);
|
$this->assertSame("/p/{$poll->join_code}/img/{$slide->image}", $payload['image']['url']);
|
||||||
|
|
||||||
$this->get('/p/' . $poll->join_code);
|
$this->get('/p/' . $poll->join_code);
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains('/p/' . $poll->join_code . '/img/' . $slide->image);
|
$this->assertResponseContains('/p/' . $poll->join_code . '/img/' . $slide->image);
|
||||||
$this->assertResponseContains('alt="Ein roter Kreis"');
|
$this->assertResponseContains('alt=""');
|
||||||
$this->assertResponseContains('width="1600" height="1067"');
|
$this->assertResponseContains('width="1600" height="1067"');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,7 +313,6 @@ class SlideImageTest extends TestCase
|
|||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains('enctype="multipart/form-data"');
|
$this->assertResponseContains('enctype="multipart/form-data"');
|
||||||
$this->assertResponseContains('name="remove_image"');
|
$this->assertResponseContains('name="remove_image"');
|
||||||
$this->assertResponseContains('value="Ein roter Kreis"');
|
|
||||||
$this->assertResponseContains('Bildschirm füllen');
|
$this->assertResponseContains('Bildschirm füllen');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -800,4 +800,8 @@ body:has(dialog[open]) { overflow: hidden; }
|
|||||||
.image-fields > legend { font-weight: 600; padding: 0; margin-bottom: .5em; }
|
.image-fields > legend { font-weight: 600; padding: 0; margin-bottom: .5em; }
|
||||||
.image-fields__layout > legend { padding: 0; margin-bottom: .25em; }
|
.image-fields__layout > legend { padding: 0; margin-bottom: .25em; }
|
||||||
.image-fields__current { margin: 0 0 .75em; }
|
.image-fields__current { margin: 0 0 .75em; }
|
||||||
|
.image-fields__current.is-removed img { opacity: .3; filter: grayscale(1); }
|
||||||
|
.image-fields__remove { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 1em; }
|
||||||
|
.image-fields__remove .button { display: inline-flex; align-items: center; gap: 6px; }
|
||||||
|
.image-fields__remove .hint { margin: 0; }
|
||||||
.image-fields__current img { display: block; max-width: 100%; max-height: 180px; width: auto; height: auto; border-radius: 6px; }
|
.image-fields__current img { display: block; max-width: 100%; max-height: 180px; width: auto; height: auto; border-radius: 6px; }
|
||||||
@@ -2232,6 +2232,33 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------ slide form
|
// ------------------------------------------------------------------ slide form
|
||||||
|
|
||||||
|
/** Slide image: a trash button toggles the "remove image" checkbox (the checkbox stays for use without JavaScript). */
|
||||||
|
function initImageRemove(box) {
|
||||||
|
var checkbox = box.querySelector('input[type="checkbox"]');
|
||||||
|
var button = box.querySelector('[data-image-remove-button]');
|
||||||
|
var status = box.querySelector('[data-image-remove-status]');
|
||||||
|
var figure = box.parentNode.querySelector('.image-fields__current');
|
||||||
|
if (!checkbox || !button) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var field = checkbox.closest('.input');
|
||||||
|
if (field) {
|
||||||
|
field.hidden = true;
|
||||||
|
}
|
||||||
|
button.hidden = false;
|
||||||
|
button.addEventListener('click', function () {
|
||||||
|
checkbox.checked = !checkbox.checked;
|
||||||
|
button.setAttribute('aria-pressed', checkbox.checked ? 'true' : 'false');
|
||||||
|
button.querySelector('[data-label]').textContent = button.getAttribute(checkbox.checked ? 'data-label-undo' : 'data-label-remove');
|
||||||
|
if (figure) {
|
||||||
|
figure.classList.toggle('is-removed', checkbox.checked);
|
||||||
|
}
|
||||||
|
if (status) {
|
||||||
|
status.textContent = checkbox.checked ? 'Das Bild wird beim Speichern entfernt.' : '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** Quiz slide form: add further answer rows (the server renders a few already). */
|
/** Quiz slide form: add further answer rows (the server renders a few already). */
|
||||||
function initQuizOptions(fieldset) {
|
function initQuizOptions(fieldset) {
|
||||||
var list = fieldset.querySelector('[data-quiz-list]');
|
var list = fieldset.querySelector('[data-quiz-list]');
|
||||||
@@ -2851,6 +2878,7 @@
|
|||||||
initCopy(root);
|
initCopy(root);
|
||||||
root.querySelectorAll('[data-youtube-form]').forEach(initYouTubeForm);
|
root.querySelectorAll('[data-youtube-form]').forEach(initYouTubeForm);
|
||||||
root.querySelectorAll('[data-quiz-options]').forEach(initQuizOptions);
|
root.querySelectorAll('[data-quiz-options]').forEach(initQuizOptions);
|
||||||
|
root.querySelectorAll('[data-image-remove]').forEach(initImageRemove);
|
||||||
root.querySelectorAll('[data-sortable]').forEach(initSortable);
|
root.querySelectorAll('[data-sortable]').forEach(initSortable);
|
||||||
root.querySelectorAll('[data-order-options]').forEach(initOrderOptions);
|
root.querySelectorAll('[data-order-options]').forEach(initOrderOptions);
|
||||||
root.querySelectorAll('[data-scale-style]').forEach(initScaleStyle);
|
root.querySelectorAll('[data-scale-style]').forEach(initScaleStyle);
|
||||||
|
|||||||
Reference in new issue
Block a user