feat: confirmation dialog with custom text when clicking product teaser

This commit is contained in:
Björn Fromme
2024-11-12 19:07:02 +01:00
parent 31d85a0e54
commit 89f3a32ce7
9 changed files with 63 additions and 3 deletions
@@ -65,6 +65,11 @@ class Concept extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements
*/
protected $teaser = '';
/**
* @var string
*/
protected $popupText = '';
/**
* @var string
*/
@@ -180,6 +185,18 @@ class Concept extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements
$this->teaser = $teaser;
}
public function getPopupText()
{
return $this->popupText;
}
public function setPopupText($popupText)
{
$this->popupText = $popupText;
return $this;
}
/**
* @return string
*/
@@ -59,6 +59,7 @@ class ProductRepository extends AbstractRepository
->select(
'date.concept as conceptUid', 'date.concept_name as conceptName',
'date.concept_code as conceptCode', 'date.concept_sorting as conceptSorting',
'date.concept_popup_text as conceptPopupText',
'date.product as productUid', 'date.product_name as productName',
'date.product_detail_page as productDetailPage', 'date.product_feature as productFeature',
'date.daytrip as daytrip', 'date.country as countryUid','date.country_name as countryName',
@@ -135,7 +136,7 @@ class ProductRepository extends AbstractRepository
'skipass_included as skipassIncluded', 'bus_included as busIncluded',
'earlybird', 'new', 'daytrip', 'hide_booking_button as hideBookingButton',
'low_contingent as lowContingent', 'concept_code as conceptCode', 'concept_name as conceptName',
'board', 'new'
'date.concept_popup_text as conceptPopupText', 'board', 'new'
)
->from('tx_epproducts_domain_model_date', 'date')
->where('date_start >= NOW()')
@@ -238,7 +238,8 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
cnt.name country_name, cnt.code country_code, cnt.keywords country_keywords, r.name region_name,
r.keywords region_keywords, r.feature region_feature,
c.name city_name, c.keywords city_keywords,
con.name concept_name, con.code concept_code, con.sorting concept_sorting
con.name concept_name, con.code concept_code, con.sorting concept_sorting,
con.popup_text concept_popup_text
FROM tx_epproducts_domain_model_product p
INNER JOIN tx_epproducts_domain_model_country cnt ON p.country = cnt.uid
INNER JOIN tx_epproducts_domain_model_region r ON p.region = r.uid
@@ -357,6 +358,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
'concept' => $product['concept'],
'concept_name' => $product['concept_name'],
'concept_code' => $product['concept_code'],
'concept_popup_text' => $product['concept_popup_text'],
'concept_sorting' => $product['concept_sorting'],
'season' => empty($product['season']) ? 'w' : $product['season'],
'date_start' => $dateStart->format('Y-m-d'),
@@ -205,6 +205,7 @@ class ProductDataService implements SingletonInterface
'concept' => [
'name' => $teaserData['conceptName'],
'code' => $teaserData['conceptCode'],
'popupText' => $teaserData['conceptPopupText'],
],
'hotel' => [
'name' => $teaserData['hotelName'],
@@ -97,6 +97,7 @@ class SearchResultService implements SingletonInterface
'name' => $row['conceptName'],
'code' => $row['conceptCode'],
'sorting' => $row['conceptSorting'],
'popupText' => $row['conceptPopupText'],
],
'items' => [],
];
@@ -24,7 +24,8 @@ return [
],
'types' => [
'1' => [
'showitem' => '--palette--;;top, --palette--;;naming, --palette--;;header, teaser, description, description_extended,
'showitem' => '--palette--;;top, --palette--;;naming, --palette--;;header, teaser, description,
description_extended, popup_text,
--div--;Bilder/Dateien, teaser_images, header_images, images',
],
],
@@ -215,6 +216,17 @@ return [
'renderType' => 'inputLink',
]
],
'popup_text' => [
'exclude' => 0,
'label' => 'Popup Text',
'description' => 'Wenn ausgefüllt, wird ein Popup mit diesem Text beim Anklicken eines Teasers angezeigt.',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 5,
'eval' => 'trim',
],
],
'teaser_images' => [
'exclude' => 0,
'label' => 'Teaserbild(er)',
@@ -142,6 +142,7 @@ CREATE TABLE tx_epproducts_domain_model_date
concept_name varchar(255) DEFAULT '' NOT NULL,
concept_code varchar(32) DEFAULT '' NOT NULL,
concept_sorting int(11) DEFAULT '0' NOT NULL,
concept_popup_text text NOT NULL,
country int(11) unsigned DEFAULT '0',
country_name varchar(255) DEFAULT '' NOT NULL,
country_code char(2) DEFAULT '' NOT NULL,
@@ -526,6 +527,7 @@ CREATE TABLE tx_epproducts_domain_model_concept
detail_page varchar(255) DEFAULT '' NOT NULL,
products int(11) DEFAULT '0' NOT NULL,
teaser text NOT NULL,
popup_text text NOT NULL,
headline varchar(255) DEFAULT '' NOT NULL,
header_title varchar(255) DEFAULT '' NOT NULL,
header_subtitle varchar(255) DEFAULT '' NOT NULL,
@@ -0,0 +1,14 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static values = { text: String }
open(e) {
if (this.hasTextValue && confirm(this.textValue)) {
return
}
e.preventDefault()
}
}
@@ -14,6 +14,11 @@
<f:section name="TeaserImage">
<div class="relative{f:if(condition: landscape, then: ' sm:w-2/5')}">
<a href="{ep:uri.product(forceHotelUid: forceHotelUid, product: product, hotel: hotel, dateFrom: dateFrom, dateTo: dateTo, ref: referringPageUri)}"
<f:if condition="{concept.popupText}">
data-controller="teaser-popup"
data-teaser-popup-text-value="{concept.popupText}"
data-action="teaser-popup#open"
</f:if>
title="{region.name} {product.name} Details und Buchen">
<f:if condition="{productImage}">
<f:then>
@@ -73,6 +78,11 @@
<f:section name="TeaserContent">
{f:variable(name: 'including', value: '{f:render(section: \'Including\', arguments: \'{_all}\') -> v:format.trim()}')}
<a href="{ep:uri.product(forceHotelUid: forceHotelUid, product: product, hotel: hotel, dateFrom: dateFrom, dateTo: dateTo, ref: referringPageUri)}"
<f:if condition="{concept.popupText}">
data-controller="teaser-popup"
data-teaser-popup-text-value="{concept.popupText}"
data-action="teaser-popup#open"
</f:if>
title="{region.name} {product.name} Details und Buchen"
class="flex-1 flex flex-col space-y-1 px-2 py-4 md:p-4">
<div class="product-teaser__label-name">