From b56a26f87b473e3e5dbd6e296185c60f7a5ff423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Mon, 6 Aug 2018 12:12:01 +0200 Subject: [PATCH] Refactor configurator defaults config, add more defaults --- .../Classes/Controller/FormController.php | 44 +++++++++++- .../Classes/Domain/Model/Inquiry.php | 9 +++ .../ep_events/Classes/Domain/Model/Offer.php | 69 +++++++++++++++++++ .../tx_epevents_domain_model_offer.php | 39 +++++++++++ .../TCA/tx_epevents_domain_model_offer.php | 47 +++++++++++-- .../Configuration/TypoScript/setup.txt | 64 ----------------- .../Assets/js/components/Configurator.vue | 6 ++ .../Private/Templates/Form/Configurator.html | 19 ++--- .../ext/ep_events/ext_conf_template.txt | 17 +++++ web/typo3conf/ext/ep_events/ext_tables.sql | 3 + 10 files changed, 240 insertions(+), 77 deletions(-) create mode 100644 web/typo3conf/ext/ep_events/Configuration/TCA/Overrides/tx_epevents_domain_model_offer.php create mode 100644 web/typo3conf/ext/ep_events/ext_conf_template.txt diff --git a/web/typo3conf/ext/ep_events/Classes/Controller/FormController.php b/web/typo3conf/ext/ep_events/Classes/Controller/FormController.php index f4bddb03..ab06a256 100644 --- a/web/typo3conf/ext/ep_events/Classes/Controller/FormController.php +++ b/web/typo3conf/ext/ep_events/Classes/Controller/FormController.php @@ -30,6 +30,7 @@ namespace EP\EpEvents\Controller; use EP\EpEvents\Domain\Model\Inquiry; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; +use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility; class FormController extends ActionController { @@ -62,6 +63,7 @@ class FormController extends ActionController } else { $inquiry = $this->getInquiryFromContext(); } + $this->view->assign('configuratorConfig', $this->getConfiguratorConfig()); $this->view->assign('inquiry', $inquiry); } @@ -76,9 +78,11 @@ class FormController extends ActionController $offer = $content['offer']; $inquiry = Inquiry::fromOffer($offer, $defaults); } elseif (isset($content['travelType'])) { + $config = $this->getConfiguratorConfig(); /** @var \EP\EpEvents\Domain\Model\Traveltype $travelType */ $travelType = $content['travelType']; - $inquiryName = $this->settings['configurator']['options']['travelType'][$travelType->getConfiguratorType()]; + $configuratorType = $travelType->getConfiguratorType(); + $inquiryName = $config['travelTypeOptions'][$configuratorType]; $inquiry = Inquiry::fromTraveltype($travelType, $inquiryName, $defaults); } elseif (isset($content['activityType'])) { $inquiry = new Inquiry($defaults); @@ -108,4 +112,42 @@ class FormController extends ActionController ->build() ; } + + /** + * @return array + */ + protected function getConfiguratorConfig() + { + /** @var ConfigurationUtility $configUtility */ + $configUtility = $this->objectManager->get(ConfigurationUtility::class); + $extensionConfig = $configUtility->getCurrentConfiguration('ep_events'); + + return [ + 'budgetOptions' => $this->parseConfigItem($extensionConfig, 'configuratorBudgetOptions'), + 'paxOptions' => $this->parseConfigItem($extensionConfig, 'configuratorPaxOptions'), + 'periodOptions' => $this->parseConfigItem($extensionConfig, 'configuratorPeriodOptions'), + 'travelTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorTravelTypeOptions'), + 'locationTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorLocationTypeOptions'), + 'accommodationTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorAccommodationTypeOptions'), + 'programmeTypeOptions' => $this->parseConfigItem($extensionConfig, 'configuratorProgrammeTypeOptions'), + 'distanceOptions' => $this->parseConfigItem($extensionConfig, 'configuratorDistanceOptions'), + ]; + } + + /** + * @param array $configArray + * @param string $itemName + * @return array + */ + protected function parseConfigItem($configArray, $itemName) + { + $config = []; + foreach (explode(';', $configArray[$itemName]['value']) as $item) + { + list ($value, $label) = explode(':', $item); + $config[$value] = $label; + } + + return $config; + } } diff --git a/web/typo3conf/ext/ep_events/Classes/Domain/Model/Inquiry.php b/web/typo3conf/ext/ep_events/Classes/Domain/Model/Inquiry.php index 1e907ea8..8e5c965c 100644 --- a/web/typo3conf/ext/ep_events/Classes/Domain/Model/Inquiry.php +++ b/web/typo3conf/ext/ep_events/Classes/Domain/Model/Inquiry.php @@ -151,6 +151,15 @@ class Inquiry extends AbstractValueObject if ($offer->getLocation()->getConfiguratorDistance()) { $inquiry->setDistance($offer->getLocation()->getConfiguratorDistance()); } + if ($offer->getConfiguratorBudget()) { + $inquiry->setBudget($offer->getConfiguratorBudget()); + } + if ($offer->getConfiguratorPax()) { + $inquiry->setPax($offer->getConfiguratorPax()); + } + if ($offer->getConfiguratorPeriod()) { + $inquiry->setPeriod($offer->getConfiguratorPeriod()); + } $activities = []; /** @var \EP\EpEvents\Domain\Model\Activity $activity */ foreach ($offer->getActivities() as $activity) diff --git a/web/typo3conf/ext/ep_events/Classes/Domain/Model/Offer.php b/web/typo3conf/ext/ep_events/Classes/Domain/Model/Offer.php index 8c3e56fd..9ad3ee03 100644 --- a/web/typo3conf/ext/ep_events/Classes/Domain/Model/Offer.php +++ b/web/typo3conf/ext/ep_events/Classes/Domain/Model/Offer.php @@ -157,6 +157,27 @@ class Offer extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity */ protected $configuratorType = 0; + /** + * configuratorBudget + * + * @var int + */ + protected $configuratorBudget = 0; + + /** + * configuratorPax + * + * @var int + */ + protected $configuratorPax = 0; + + /** + * configuratorPeriod + * + * @var int + */ + protected $configuratorPeriod = 0; + /** * contact * @@ -626,6 +647,54 @@ class Offer extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity $this->configuratorType = $configuratorType; } + /** + * @return int + */ + public function getConfiguratorBudget() + { + return $this->configuratorBudget; + } + + /** + * @param int $configuratorBudget + */ + public function setConfiguratorBudget($configuratorBudget) + { + $this->configuratorBudget = $configuratorBudget; + } + + /** + * @return int + */ + public function getConfiguratorPax() + { + return $this->configuratorPax; + } + + /** + * @param int $configuratorPax + */ + public function setConfiguratorPax($configuratorPax) + { + $this->configuratorPax = $configuratorPax; + } + + /** + * @return int + */ + public function getConfiguratorPeriod() + { + return $this->configuratorPeriod; + } + + /** + * @param int $configuratorPeriod + */ + public function setConfiguratorPeriod($configuratorPeriod) + { + $this->configuratorPeriod = $configuratorPeriod; + } + /** * @return int */ diff --git a/web/typo3conf/ext/ep_events/Configuration/TCA/Overrides/tx_epevents_domain_model_offer.php b/web/typo3conf/ext/ep_events/Configuration/TCA/Overrides/tx_epevents_domain_model_offer.php new file mode 100644 index 00000000..149e4def --- /dev/null +++ b/web/typo3conf/ext/ep_events/Configuration/TCA/Overrides/tx_epevents_domain_model_offer.php @@ -0,0 +1,39 @@ + [ 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, type, name, name_internal, groupname, price, headline, header, arrival, schedule, services, guidelines, image_teaser, - image_teaser_mobile, image_header, booking_form, configurator_type, contact, hotel, location, activities, - detail_page, url, url_rendered', + image_teaser_mobile, image_header, booking_form, configurator_type, configurator_budget, + configurator_pax, configurator_period, contact, hotel, location, activities, detail_page, url, + url_rendered', ], 'types' => [ '1' => [ @@ -71,7 +72,7 @@ return [ ], ], 'palettes' => [ - 'general' => ['showitem' => 'type, configurator_type, detail_page'], + 'general' => ['showitem' => 'type, configurator_type, configurator_pax, configurator_budget, configurator_period, detail_page'], 'general_ext' => ['showitem' => 'type, configurator_type, price'], 'naming' => ['showitem' => 'name, name_internal'], 'url' => ['showitem' => 'url, url_rendered'], @@ -385,7 +386,45 @@ return [ 'size' => 1, 'minitems' => 1, 'maxitems' => 1, - 'eval' => '' + ], + ], + 'configurator_budget' => [ + 'exclude' => 0, + 'label' => 'Konfigurator Budget', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [], + 'default' => 1, + 'size' => 1, + 'minitems' => 0, + 'maxitems' => 1, + ], + ], + 'configurator_pax' => [ + 'exclude' => 0, + 'label' => 'Teilnehmerzahl', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [], + 'default' => 1, + 'size' => 1, + 'minitems' => 0, + 'maxitems' => 1, + ], + ], + 'configurator_period' => [ + 'exclude' => 0, + 'label' => 'Reisezeitraum', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [], + 'default' => 1, + 'size' => 1, + 'minitems' => 0, + 'maxitems' => 1, ], ], 'contact' => [ diff --git a/web/typo3conf/ext/ep_events/Configuration/TypoScript/setup.txt b/web/typo3conf/ext/ep_events/Configuration/TypoScript/setup.txt index 13cd948b..72759cfa 100644 --- a/web/typo3conf/ext/ep_events/Configuration/TypoScript/setup.txt +++ b/web/typo3conf/ext/ep_events/Configuration/TypoScript/setup.txt @@ -52,70 +52,6 @@ plugin.tx_epevents { contactFormAutoreplySubject = {$plugin.tx_epevents.settings.contactFormAutoreplySubject} businessHours = {$plugin.tx_epevents.settings.businessHours} configurator { - options { - travelType { - 1 = Incentive - 2 = Teambuilding - 3 = Meeting - 4 = Corporate Event - } - locationType { - 1 = Meer - 2 = Berge - 3 = Städte - 4 = Spezial - } - accommodationType { - 1 = 3-Sterne - 2 = 4-Sterne - 3 = 5-Sterne - 4 = Spezial - } - programmeType { - 1 = Outdoor & Action - 2 = Event-Gastronomie - 3 = Sightseeing - 4 = Spezial - } - distance { - 1 = Deutschland - 2 = Europa - 3 = Welt - } - pax { - 1 = 20 - 40 - 2 = 40 - 60 - 3 = 60 - 80 - 4 = 80 - 100 - 5 = 100 - 150 - 6 = 150 - 200 - 7 = 200 - 250 - 8 = 250 - 300 - 9 = 350 - 400 - 10 = 400 - 450 - 11 = 450 - 500 - 12 = 500+ - } - budget { - 1 = nicht festgelegt - 2 = 400 - 600 € - 3 = 600 - 800 € - 4 = 800 - 1000 € - 5 = 1000 - 1500 € - 6 = 1500 - 2000 € - 7 = 2500 - 3000 € - } - period { - 1 = Tagesevent - 2 = 1 Nacht - 3 = 2 Nächte - 4 = 3 Nächte - 5 = 4 Nächte - 6 = 5 Nächte - 7 = 6 Nächte - 8 = 7 Nächte - } - } defaults { budget = 4 } diff --git a/web/typo3conf/ext/ep_events/Resources/Private/Assets/js/components/Configurator.vue b/web/typo3conf/ext/ep_events/Resources/Private/Assets/js/components/Configurator.vue index 5a5ec9a4..1c32dae3 100644 --- a/web/typo3conf/ext/ep_events/Resources/Private/Assets/js/components/Configurator.vue +++ b/web/typo3conf/ext/ep_events/Resources/Private/Assets/js/components/Configurator.vue @@ -17,6 +17,9 @@ contextAccommodation: { type: String, default: '' }, contextProgramme: { type: String, default: '' }, contextDistance: { type: String, default: '0' }, + contextBudget: { type: String, default: '0' }, + contextPeriod: { type: String, default: '0' }, + contextPax: { type: String, default: '0' }, imagesType: { type: Object, required: true }, optionsType: { type: Object, required: true }, imagesDestination: { type: Object, required: true }, @@ -245,6 +248,9 @@ this.formData.accommodation = this.contextAccommodation ? this.contextAccommodation.split(',') : []; this.formData.programme = this.contextProgramme ? this.contextProgramme.split(',') : []; this.formData.distance = this.contextDistance ? this.contextDistance : ''; + this.formData.budget = this.contextBudget ? this.contextBudget : this.defaultValues.budget; + this.formData.pax = this.contextPax ? this.contextPax : ''; + this.formData.period = this.contextPeriod ? this.contextPeriod : ''; } } } diff --git a/web/typo3conf/ext/ep_events/Resources/Private/Templates/Form/Configurator.html b/web/typo3conf/ext/ep_events/Resources/Private/Templates/Form/Configurator.html index 40916122..d256b6f7 100644 --- a/web/typo3conf/ext/ep_events/Resources/Private/Templates/Form/Configurator.html +++ b/web/typo3conf/ext/ep_events/Resources/Private/Templates/Form/Configurator.html @@ -15,8 +15,11 @@ }' context-destination='{inquiry.locationType}' - :options-destination='{settings.configurator.options.locationType -> v:format.json.encode()}' + :options-destination='{configuratorConfig.locationTypeOptions -> v:format.json.encode()}' :images-destination='{ 1: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_destination_sea.jpg', width: '450')}", 2: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_destination_mountains_skiing.jpg', width: '450')}", @@ -32,7 +35,7 @@ 4: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_destination_special.jpg', width: '450')}" }' context-accommodation='{inquiry.hotelType}' - :options-accommodation='{settings.configurator.options.accommodationType -> v:format.json.encode()}' + :options-accommodation='{configuratorConfig.accommodationTypeOptions -> v:format.json.encode()}' :images-accommodation='{ 1: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_hotel_3-stars.jpg', width: '450')}", 2: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_hotel_4-stars.jpg', width: '450')}", @@ -40,7 +43,7 @@ 4: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_hotel_special.jpg', width: '450')}" }' context-programme='{inquiry.activityType}' - :options-programme='{settings.configurator.options.programmeType -> v:format.json.encode()}' + :options-programme='{configuratorConfig.programmeTypeOptions -> v:format.json.encode()}' :images-programme='{ 1: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_programme_outdoor-action.jpg', width: '450')}", 2: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_programme_event-gastro.jpg', width: '450')}", @@ -48,10 +51,10 @@ 4: "{f:uri.image(src: 'fileadmin/user_upload/ep_Events/Konfigurator/configurator_programme_special.jpg', width: '450')}" }' context-distance="{inquiry.distance}" - :options-distance='{settings.configurator.options.distance -> v:format.json.encode()}' - :options-pax='{settings.configurator.options.pax -> v:format.json.encode()}' - :options-budget='{settings.configurator.options.budget -> v:format.json.encode()}' - :options-period='{settings.configurator.options.period -> v:format.json.encode()}' + :options-distance='{configuratorConfig.distanceOptions -> v:format.json.encode()}' + :options-pax='{configuratorConfig.paxOptions -> v:format.json.encode()}' + :options-budget='{configuratorConfig.budgetOptions -> v:format.json.encode()}' + :options-period='{configuratorConfig.periodOptions -> v:format.json.encode()}' inline-template>