feat: explicit icon map for hotel cms-data response
This commit is contained in:
@@ -13,8 +13,8 @@ namespace App\Model;
|
|||||||
final readonly class CmsHotelData
|
final readonly class CmsHotelData
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed>|null $images
|
* @param array<string, mixed>|null $images
|
||||||
* @param array<string, array{label?: string|null, value?: mixed}>|null $icons
|
* @param list<array{icon: string, label: string|false}>|null $icons
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public ?string $name,
|
public ?string $name,
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class CmsDataProvider
|
|||||||
* room_types?: string,
|
* room_types?: string,
|
||||||
* additional_information?: string,
|
* additional_information?: string,
|
||||||
* images?: array<string, mixed>,
|
* images?: array<string, mixed>,
|
||||||
* icons?: array<string, bool|string>,
|
* icons?: list<array{icon: string, label: string|false}>,
|
||||||
* region?: array{
|
* region?: array{
|
||||||
* name: string,
|
* name: string,
|
||||||
* latitude: float,
|
* latitude: float,
|
||||||
|
|||||||
@@ -109,36 +109,18 @@
|
|||||||
} %}
|
} %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{% set icons = ctx.hotelCmsData.icons %}
|
{% set icons = ctx.hotelCmsData.icons %}
|
||||||
{% set iconMap = {
|
|
||||||
bedsCount: { icon: 'bed', label: 'Anzahl Betten' },
|
|
||||||
parkingCount: { icon: 'parking', label: 'Anzahl Parkplätze' },
|
|
||||||
altitude: { icon: 'mountain', label: 'Höhe' },
|
|
||||||
partyroom: { icon: 'party', label: 'Partyraum' },
|
|
||||||
gamesroom: { icon: 'dice', label: 'Spieleraum' },
|
|
||||||
distanceBus: { icon: 'bus', label: 'Entfernung Bus' },
|
|
||||||
distanceLift: { icon: 'lift', label: 'Entfernung Lifte' },
|
|
||||||
sauna: { icon: 'sauna', label: 'Sauna' },
|
|
||||||
shower: { icon: 'shower', label: 'Dusche' },
|
|
||||||
wifi: { icon: 'wifi', label: 'WiFi' },
|
|
||||||
} %}
|
|
||||||
{% if icons is not empty %}
|
{% if icons is not empty %}
|
||||||
<ul class="grid grid-cols-2 md:grid-cols-3 gap-2">
|
<ul class="grid grid-cols-2 md:grid-cols-3 gap-2">
|
||||||
{% for key, value in icons %}
|
{% for item in icons %}
|
||||||
{% set mapping = iconMap[key] ?? null %}
|
|
||||||
{% set isBool = value is same as(true) or value is same as(false) %}
|
|
||||||
<li class="flex items-center gap-2">
|
<li class="flex items-center gap-2">
|
||||||
<div class="border-2 border-gray-900 rounded-full w-16 h-16 shrink-0 flex flex-col items-center justify-center">
|
<div class="border-2 border-gray-900 rounded-full w-16 h-16 shrink-0 flex flex-col items-center justify-center">
|
||||||
{% if mapping %}
|
{% if item.icon %}
|
||||||
{{ icon(mapping.icon, 'w-8 h-8 shrink-0 text-gray-900') }}
|
{{ icon(item.icon, 'w-8 h-8 shrink-0 text-gray-900') }}
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div class="text-sm font-bold">
|
|
||||||
{% if isBool %}
|
|
||||||
{{ mapping ? mapping.label : '' }}
|
|
||||||
{% else %}
|
|
||||||
{{ mapping ? mapping.label ~ ': ' ~ value : value }}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% if item.label is not same as(false) %}
|
||||||
|
<div class="text-sm font-bold">{{ item.label }}</div>
|
||||||
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -23,7 +23,11 @@ class CmsDataProviderTest extends TestCase
|
|||||||
'room_types' => '<p>Zimmer</p>',
|
'room_types' => '<p>Zimmer</p>',
|
||||||
'additional_information' => '<p>Weitere Infos</p>',
|
'additional_information' => '<p>Weitere Infos</p>',
|
||||||
'images' => ['resized' => ['l' => [['url' => 'l.jpg', 'alt' => 'Alt']]]],
|
'images' => ['resized' => ['l' => [['url' => 'l.jpg', 'alt' => 'Alt']]]],
|
||||||
'icons' => ['sauna' => ['label' => 'Sauna', 'value' => true]],
|
'icons' => [
|
||||||
|
['icon' => 'bed', 'label' => '69 Betten'],
|
||||||
|
['icon' => 'wifi', 'label' => 'WiFi'],
|
||||||
|
['icon' => 'sauna', 'label' => false],
|
||||||
|
],
|
||||||
'region' => [
|
'region' => [
|
||||||
'name' => 'Alpenregion',
|
'name' => 'Alpenregion',
|
||||||
'latitude' => 47.1,
|
'latitude' => 47.1,
|
||||||
@@ -50,7 +54,11 @@ class CmsDataProviderTest extends TestCase
|
|||||||
self::assertSame("Musterstraße 1\n1234 Musterort", $data->address);
|
self::assertSame("Musterstraße 1\n1234 Musterort", $data->address);
|
||||||
self::assertSame('<p>Zimmer</p>', $data->roomTypes);
|
self::assertSame('<p>Zimmer</p>', $data->roomTypes);
|
||||||
self::assertSame('<p>Weitere Infos</p>', $data->additionalInformation);
|
self::assertSame('<p>Weitere Infos</p>', $data->additionalInformation);
|
||||||
self::assertSame(['sauna' => ['label' => 'Sauna', 'value' => true]], $data->icons);
|
self::assertSame([
|
||||||
|
['icon' => 'bed', 'label' => '69 Betten'],
|
||||||
|
['icon' => 'wifi', 'label' => 'WiFi'],
|
||||||
|
['icon' => 'sauna', 'label' => false],
|
||||||
|
], $data->icons);
|
||||||
self::assertNotNull($data->region);
|
self::assertNotNull($data->region);
|
||||||
self::assertSame('Alpenregion', $data->region->name);
|
self::assertSame('Alpenregion', $data->region->name);
|
||||||
self::assertSame('<p>Skigebiet</p>', $data->region->skiArea);
|
self::assertSame('<p>Skigebiet</p>', $data->region->skiArea);
|
||||||
|
|||||||
Reference in New Issue
Block a user