From d59748a03040ffc45d52c734668676a7cfb1b9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Mon, 9 Sep 2019 13:54:43 +0200 Subject: [PATCH 01/22] Connect contact forms with buspro api --- composer.json | 1 + composer.lock | 209 ++++++++++++++---- .../Classes/Controller/AjaxFormController.php | 22 +- .../Classes/Domain/Model/Dto/ContactForm.php | 44 ++++ .../ep_theme/Classes/Form/BpnApiFinisher.php | 41 ++++ .../Classes/Service/BookingApiService.php | 56 +++++ .../Configuration/Forms/FormSetup.yaml | 3 + .../TypoScript/constants.typoscript | 4 +- .../Configuration/TypoScript/setup.typoscript | 1 + .../Private/Forms/ContactForm.form.yaml | 72 ++++-- .../Private/Language/de.locallang.xlf | 3 + .../Resources/Private/Language/locallang.xlf | 3 + .../Private/Templates/Form/FullForm.html | 12 + .../Private/Templates/Form/SimpleForm.html | 12 + 14 files changed, 417 insertions(+), 66 deletions(-) create mode 100644 public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php create mode 100644 public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php diff --git a/composer.json b/composer.json index ee2be881..94cb8838 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "helhum/typo3-console": "^5.6", "league/csv": "^9.2", "pixelant/pxa-social-feed": "^1.10", + "symfony/http-client": "^4.3", "symfony/options-resolver": "^4.2", "symfony/property-access": "^4.3", "symfony/serializer": "^4.2", diff --git a/composer.lock b/composer.lock index 8726d27d..73d8904f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "43ff1e099d6b3f1ded82923c05a3e7f8", + "content-hash": "65c7db27e084cf03eddd1ddb83812563", "packages": [ { "name": "algo26-matthias/idna-convert", @@ -1173,9 +1173,9 @@ "authors": [ { "name": "Helmut Hummel", + "role": "Developer", "email": "info@helhum.io", - "homepage": "http://helhum.io", - "role": "Developer" + "homepage": "http://helhum.io" } ], "description": "A reliable and powerful command line interface for TYPO3 CMS", @@ -1294,9 +1294,9 @@ "authors": [ { "name": "Ignace Nyamagana Butera", + "role": "Developer", "email": "nyamsprod@gmail.com", - "homepage": "https://github.com/nyamsprod/", - "role": "Developer" + "homepage": "https://github.com/nyamsprod/" } ], "description": "Csv data manipulation made easy in PHP", @@ -2122,6 +2122,125 @@ "homepage": "https://symfony.com", "time": "2019-08-14T12:26:46+00:00" }, + { + "name": "symfony/http-client", + "version": "v4.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-client.git", + "reference": "9a4fa769269ed730196a5c52c742b30600cf1e87" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-client/zipball/9a4fa769269ed730196a5c52c742b30600cf1e87", + "reference": "9a4fa769269ed730196a5c52c742b30600cf1e87", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "psr/log": "^1.0", + "symfony/http-client-contracts": "^1.1.6", + "symfony/polyfill-php73": "^1.11" + }, + "provide": { + "psr/http-client-implementation": "1.0", + "symfony/http-client-implementation": "1.1" + }, + "require-dev": { + "nyholm/psr7": "^1.0", + "psr/http-client": "^1.0", + "symfony/http-kernel": "^4.3", + "symfony/process": "^4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpClient\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony HttpClient component", + "homepage": "https://symfony.com", + "time": "2019-08-20T14:27:59+00:00" + }, + { + "name": "symfony/http-client-contracts", + "version": "v1.1.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-client-contracts.git", + "reference": "6005fe61a33724405d56eb5b055d5d370192a1bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/6005fe61a33724405d56eb5b055d5d370192a1bd", + "reference": "6005fe61a33724405d56eb5b055d5d370192a1bd", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "suggest": { + "symfony/http-client-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\HttpClient\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to HTTP clients", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-08-08T10:05:21+00:00" + }, { "name": "symfony/inflector", "version": "v4.3.4", @@ -3222,8 +3341,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "The TYPO3 admin panel provides a panel with additional functionality in the frontend (Debugging, Caching, Preview...)", @@ -3287,8 +3406,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Classes for the TYPO3 backend.", @@ -3391,8 +3510,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Backend user administration and overview. Allows you to compare the settings of users and verify their permissions and see who is online.", @@ -3606,8 +3725,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "The core library of TYPO3.", @@ -3722,8 +3841,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "TYPO3 Extension Manager", @@ -3828,8 +3947,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Listing of files in the directory", @@ -3933,8 +4052,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Fluid is a next-generation templating engine which makes the life of extension authors a lot easier!", @@ -4102,8 +4221,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Classes for the frontend of TYPO3.", @@ -4161,8 +4280,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Shows various infos", @@ -4219,8 +4338,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "The Install Tool mounted as the module Tools>Install in TYPO3.", @@ -4276,8 +4395,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Enables the 'Config' and 'DB Check' modules for technical analysis of the system. This includes raw database search, checking relations, counting pages and records etc.", @@ -4335,8 +4454,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "List of database-records", @@ -4387,8 +4506,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "The recycler offers the possibility to restore deleted records or remove them from the database permanently. These actions can be applied to a single record, multiple records, and recursively to child records (ex. restoring a page can restore all content elements on that page). Filtering by page and by table provides a quick overview of deleted records before taking action on them.", @@ -4441,8 +4560,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Custom redirects in TYPO3.", @@ -4556,8 +4675,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Integration of CKEditor as Rich Text Editor.", @@ -4605,8 +4724,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "The TYPO3 Scheduler let's you register tasks to happen at a specific time", @@ -4659,8 +4778,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "SEO features for TYPO3.", @@ -4768,8 +4887,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "JavaScript-driven editor with syntax highlighting and codecompletion. Based on CodeMirror.", @@ -4869,8 +4988,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Framework for management of TypoScript template records for the CMS frontend.", @@ -4921,8 +5040,8 @@ "authors": [ { "name": "TYPO3 Core Team", - "email": "typo3cms@typo3.org", - "role": "Developer" + "role": "Developer", + "email": "typo3cms@typo3.org" } ], "description": "Shows the frontend webpage inside the backend frameset.", diff --git a/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php b/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php index 45f1853a..5f4c61fd 100644 --- a/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php +++ b/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php @@ -26,6 +26,7 @@ namespace EP\EpTheme\Controller; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use EP\EpTheme\Service\BookingApiService; use EP\EpTheme\Service\EmailService; use EP\EpTheme\Domain\Model\Dto\ContactForm; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -40,12 +41,20 @@ class AjaxFormController extends ActionController protected $emailService; /** - * @param EmailService $emailService + * @var BookingApiService */ - public function __construct(EmailService $emailService) + protected $bookingApiService; + + /** + * @param EmailService $emailService + * @param BookingApiService $bookingApiService + */ + public function __construct(EmailService $emailService, BookingApiService $bookingApiService) { parent::__construct(); + $this->emailService = $emailService; + $this->bookingApiService = $bookingApiService; } /** @@ -63,6 +72,15 @@ class AjaxFormController extends ActionController [ 'contactForm' => $contactForm ] ); + $addressData = [ + 'name' => $contactForm->getName(), + 'vorname' => $contactForm->getFirstName(), + 'email' => $contactForm->getEmail(), + 'geschlecht' => $contactForm->getGender(), + ]; + + $this->bookingApiService->registerAddress($addressData); + return json_encode($response); } diff --git a/public/typo3conf/ext/ep_theme/Classes/Domain/Model/Dto/ContactForm.php b/public/typo3conf/ext/ep_theme/Classes/Domain/Model/Dto/ContactForm.php index 164d718c..3c046ddb 100644 --- a/public/typo3conf/ext/ep_theme/Classes/Domain/Model/Dto/ContactForm.php +++ b/public/typo3conf/ext/ep_theme/Classes/Domain/Model/Dto/ContactForm.php @@ -42,6 +42,18 @@ class ContactForm */ protected $name; + /** + * @var string + * @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty") + */ + protected $firstName; + + /** + * @var string + * @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty") + */ + protected $gender; + /** * @var string */ @@ -121,6 +133,38 @@ class ContactForm $this->name = $name; } + /** + * @return string + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * @param string $firstName + */ + public function setFirstName($firstName) + { + $this->firstName = $firstName; + } + + /** + * @return string + */ + public function getGender() + { + return $this->gender; + } + + /** + * @param string $gender + */ + public function setGender($gender) + { + $this->gender = $gender; + } + /** * @return string */ diff --git a/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php b/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php new file mode 100644 index 00000000..490ac591 --- /dev/null +++ b/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php @@ -0,0 +1,41 @@ +bookingApiService = $bookingApiService; + } + + /** + * @return string|null + */ + protected function executeInternal() + { + $formValues = $this->finisherContext->getFormValues(); + $addressData = [ + 'name' => $formValues['name'], + 'vorname' => $formValues['vorname'], + 'geschlecht' => $formValues['geschlecht'], + 'email' => $formValues['email'], + 'strasse' => $formValues['strasse'], + 'plz' => $formValues['plz'], + 'ort' => $formValues['ort'], + 'telefon' => $formValues['telefon'], + ]; + $this->bookingApiService->registerAddress($addressData); + } +} \ No newline at end of file diff --git a/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php b/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php new file mode 100644 index 00000000..8ece2bb2 --- /dev/null +++ b/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php @@ -0,0 +1,56 @@ +getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT) + ); + + $this->apiToken = $settings['plugin']['tx_eptheme']['settings']['myEpApiToken']; + $this->apiEndpointUrl = $settings['plugin']['tx_eptheme']['settings']['myEpApiBaseUrl']; + } + + /** + * @param array $addressData + */ + public function registerAddress(array $addressData) + { + $client = HttpClient::create(); + + try { + $client->request('POST', $this->apiEndpointUrl . '/booking/address', [ + 'headers' => [ + 'X-AUTH-TOKEN' => $this->apiToken, + ], + 'body' => [ + 'data' => $addressData, + ], + ]); + } + catch (TransportExceptionInterface $e) + {} + } +} \ No newline at end of file diff --git a/public/typo3conf/ext/ep_theme/Configuration/Forms/FormSetup.yaml b/public/typo3conf/ext/ep_theme/Configuration/Forms/FormSetup.yaml index 3bea7e5e..ec06bc77 100644 --- a/public/typo3conf/ext/ep_theme/Configuration/Forms/FormSetup.yaml +++ b/public/typo3conf/ext/ep_theme/Configuration/Forms/FormSetup.yaml @@ -11,6 +11,9 @@ TYPO3: prototypes: standard: + finishersDefinition: + BpnApiFinisher: + implementationClassName: 'EP\EpTheme\Form\BpnApiFinisher' formElementsDefinition: Form: renderingOptions: diff --git a/public/typo3conf/ext/ep_theme/Configuration/TypoScript/constants.typoscript b/public/typo3conf/ext/ep_theme/Configuration/TypoScript/constants.typoscript index d2f59e8e..948691ec 100644 --- a/public/typo3conf/ext/ep_theme/Configuration/TypoScript/constants.typoscript +++ b/public/typo3conf/ext/ep_theme/Configuration/TypoScript/constants.typoscript @@ -157,7 +157,9 @@ plugin.tx_eptheme { partnerIdSelectLabel = # cat=eptheme/900/100; type=string; label=MyE&P API base url - myEpApiBaseUrl = https://myep.burn.dpn + myEpApiBaseUrl = + # cat=eptheme/900/110; type=string; label=MyE&P API auth token + myEpApiToken = } } diff --git a/public/typo3conf/ext/ep_theme/Configuration/TypoScript/setup.typoscript b/public/typo3conf/ext/ep_theme/Configuration/TypoScript/setup.typoscript index b08396db..9779a299 100644 --- a/public/typo3conf/ext/ep_theme/Configuration/TypoScript/setup.typoscript +++ b/public/typo3conf/ext/ep_theme/Configuration/TypoScript/setup.typoscript @@ -88,6 +88,7 @@ plugin.tx_eptheme { conceptsPageUid = {$plugin.tx_eptheme.settings.conceptsPageUid} myEpPageUid = {$plugin.tx_eptheme.settings.myEpPageUid} myEpApiBaseUrl = {$plugin.tx_eptheme.settings.myEpApiBaseUrl} + myEpApiToken = {$plugin.tx_eptheme.settings.myEpApiToken} facebookViewContentValues { productUid = {$plugin.tx_eptheme.settings.facebookViewContentProductUid} nameInternal = {$plugin.tx_eptheme.settings.facebookViewContentNameInternal} diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml b/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml index 9fd2f7c0..d5ceb9ad 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml @@ -7,12 +7,16 @@ label: Kontaktformular prototypeName: contactform finishers: - + identifier: BpnApiFinisher options: - subject: 'Kontaktanfrage von {text-1}' + apiToken: foobarbaz + - + options: + subject: 'Kontaktanfrage von {vorname} {name}' recipientAddress: info@ep-reisen.de recipientName: 'E&P Reisen' - senderAddress: '{text-4}' - senderName: '{text-1}' + senderAddress: '{email}' + senderName: '{vorname} {name}' replyToAddress: info@ep-reisen.de carbonCopyAddress: '' blindCarbonCopyAddress: '' @@ -38,11 +42,11 @@ renderables: - defaultValue: '' type: Text - identifier: text-1 - label: Name + identifier: vorname + label: Vorname properties: fluidAdditionalAttributes: - placeholder: 'Vor- & Nachname' + placeholder: 'Vorname' required: required elementDescription: '' validators: @@ -51,21 +55,34 @@ renderables: - defaultValue: '' type: Text - identifier: text-2 - label: Anschrift + identifier: name + label: Nachname properties: fluidAdditionalAttributes: - placeholder: 'Straße & Nr.' + placeholder: 'Nachname' + required: required elementDescription: '' + validators: + - + identifier: NotEmpty + - + properties: + options: + m: m + w: w + d: d + fluidAdditionalAttributes: + required: required + type: SingleSelect + identifier: geschlecht + label: Gender + validators: + - + identifier: NotEmpty - defaultValue: '' type: Text - identifier: text-3 - label: 'PLZ, Ort' - - - defaultValue: '' - type: Text - identifier: text-4 + identifier: email label: E-Mail properties: fluidAdditionalAttributes: @@ -78,16 +95,35 @@ renderables: - defaultValue: '' type: Text - identifier: text-5 + identifier: strasse + label: Straße + properties: + fluidAdditionalAttributes: + placeholder: 'Straße & Nr.' + elementDescription: '' + - + defaultValue: '' + type: Text + identifier: plz + label: 'PLZ' + - + defaultValue: '' + type: Text + identifier: ort + label: 'Ort' + - + defaultValue: '' + type: Text + identifier: telefon label: Telefon - defaultValue: '' type: Textarea - identifier: textarea-1 + identifier: message label: 'Deine Kontaktanfrage' - type: Checkbox - identifier: checkbox-1 + identifier: privacypolicyaccepted label: 'Ich habe die Datenschutzbestimmungen gelesen und akzeptiere sie' properties: elementDescription: '' diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf b/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf index def6408d..9f7f9662 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Language/de.locallang.xlf @@ -76,6 +76,9 @@ Bitte angeben + + Bitte angeben + Bitte angeben diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf b/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf index e5eee541..ade32fcd 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Language/locallang.xlf @@ -75,6 +75,9 @@ Bitte angeben + + Bitte angeben + Bitte angeben diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/FullForm.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/FullForm.html index 0015bd00..105c2787 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/FullForm.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/FullForm.html @@ -18,6 +18,18 @@
+
+ + +
+
+
+ + +
+
diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/SimpleForm.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/SimpleForm.html index d59aec9f..5d5594ca 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/SimpleForm.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Form/SimpleForm.html @@ -12,12 +12,24 @@ pageUid="{settings.defaultAjaxUid}" class="border" additionalAttributes="{'v-show': '!success', '@submit.prevent': 'submitForm()'}"> +
+ + +
+
+
+ + +
+
From 60793401623a70c9e2049428c53ab87129991241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Tue, 17 Sep 2019 11:14:22 +0200 Subject: [PATCH 02/22] Adapt changes in api --- .../Classes/Controller/AjaxFormController.php | 4 ++-- .../ep_theme/Classes/Form/BpnApiFinisher.php | 12 ++++++------ .../Classes/Service/BookingApiService.php | 3 +++ .../Private/Forms/ContactForm.form.yaml | 18 ++++++++---------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php b/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php index 5f4c61fd..49440c2c 100644 --- a/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php +++ b/public/typo3conf/ext/ep_theme/Classes/Controller/AjaxFormController.php @@ -74,9 +74,9 @@ class AjaxFormController extends ActionController $addressData = [ 'name' => $contactForm->getName(), - 'vorname' => $contactForm->getFirstName(), + 'firstName' => $contactForm->getFirstName(), 'email' => $contactForm->getEmail(), - 'geschlecht' => $contactForm->getGender(), + 'gender' => $contactForm->getGender(), ]; $this->bookingApiService->registerAddress($addressData); diff --git a/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php b/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php index 490ac591..64ac9f17 100644 --- a/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php +++ b/public/typo3conf/ext/ep_theme/Classes/Form/BpnApiFinisher.php @@ -28,13 +28,13 @@ class BpnApiFinisher extends AbstractFinisher $formValues = $this->finisherContext->getFormValues(); $addressData = [ 'name' => $formValues['name'], - 'vorname' => $formValues['vorname'], - 'geschlecht' => $formValues['geschlecht'], + 'firstName' => $formValues['vorname'], + 'gender' => $formValues['geschlecht'], 'email' => $formValues['email'], - 'strasse' => $formValues['strasse'], - 'plz' => $formValues['plz'], - 'ort' => $formValues['ort'], - 'telefon' => $formValues['telefon'], + 'street' => $formValues['strasse'], + 'zipCode' => $formValues['plz'], + 'city' => $formValues['ort'], + 'phone' => $formValues['telefon'], ]; $this->bookingApiService->registerAddress($addressData); } diff --git a/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php b/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php index 8ece2bb2..46c26f0d 100644 --- a/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php +++ b/public/typo3conf/ext/ep_theme/Classes/Service/BookingApiService.php @@ -2,6 +2,7 @@ namespace EP\EpTheme\Service; +use Symfony\Component\HttpClient\Exception\ServerException; use Symfony\Component\HttpClient\HttpClient; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use TYPO3\CMS\Core\SingletonInterface; @@ -52,5 +53,7 @@ class BookingApiService implements SingletonInterface } catch (TransportExceptionInterface $e) {} + catch (ServerException $e) + {} } } \ No newline at end of file diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml b/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml index d5ceb9ad..ae6fd830 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Forms/ContactForm.form.yaml @@ -8,15 +8,13 @@ prototypeName: contactform finishers: - identifier: BpnApiFinisher - options: - apiToken: foobarbaz - options: - subject: 'Kontaktanfrage von {vorname} {name}' + subject: 'Kontaktanfrage von {firstName} {name}' recipientAddress: info@ep-reisen.de recipientName: 'E&P Reisen' senderAddress: '{email}' - senderName: '{vorname} {name}' + senderName: '{firstName} {name}' replyToAddress: info@ep-reisen.de carbonCopyAddress: '' blindCarbonCopyAddress: '' @@ -42,7 +40,7 @@ renderables: - defaultValue: '' type: Text - identifier: vorname + identifier: firstName label: Vorname properties: fluidAdditionalAttributes: @@ -74,7 +72,7 @@ renderables: fluidAdditionalAttributes: required: required type: SingleSelect - identifier: geschlecht + identifier: gender label: Gender validators: - @@ -95,7 +93,7 @@ renderables: - defaultValue: '' type: Text - identifier: strasse + identifier: street label: Straße properties: fluidAdditionalAttributes: @@ -104,17 +102,17 @@ renderables: - defaultValue: '' type: Text - identifier: plz + identifier: zipCode label: 'PLZ' - defaultValue: '' type: Text - identifier: ort + identifier: city label: 'Ort' - defaultValue: '' type: Text - identifier: telefon + identifier: phone label: Telefon - defaultValue: '' From ef14ae586343dc3082d4fb86aa07f4c387116a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Tue, 17 Sep 2019 16:16:39 +0200 Subject: [PATCH 03/22] WIP Refactor general api login --- .../Resources/Private/Assets/js/_app.js | 7 +- .../Resources/Private/Assets/js/_store.js | 249 ------------------ .../Assets/js/components/WatchlistToggle.vue | 2 +- .../js/myep/{components => }/Address.vue | 69 ++--- .../Assets/js/myep/{components => }/App.vue | 65 +++-- .../js/myep/{components => }/CrmData.vue | 12 +- .../js/myep/{components => }/Events.vue | 13 +- .../Assets/js/myep/{components => }/Login.vue | 11 +- .../Private/Assets/js/myep/Newsletter.vue | 42 +++ .../js/myep/{components => }/Registration.vue | 8 +- .../js/myep/{components => }/Teamer.vue | 52 ++-- .../Assets/js/myep/components/Newsletter.vue | 61 ----- .../Private/Assets/js/myep/stores/teamer.js | 60 ----- .../js/{myep/_router.js => router/index.js} | 37 +-- .../Private/Assets/js/store/index.js | 208 +++++++++++++++ .../{myep/stores => store/modules}/address.js | 30 +-- .../{myep/stores => store/modules}/crmdata.js | 9 +- .../{myep/stores => store/modules}/events.js | 4 +- .../stores => store/modules}/newsletter.js | 8 +- .../Private/Assets/js/store/modules/teamer.js | 75 ++++++ 20 files changed, 475 insertions(+), 547 deletions(-) delete mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_store.js rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/{components => }/Address.vue (73%) rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/{components => }/App.vue (65%) rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/{components => }/CrmData.vue (91%) rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/{components => }/Events.vue (91%) rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/{components => }/Login.vue (93%) create mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Newsletter.vue rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/{components => }/Registration.vue (95%) rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/{components => }/Teamer.vue (78%) delete mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Newsletter.vue delete mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/teamer.js rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/{myep/_router.js => router/index.js} (70%) create mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/{myep/stores => store/modules}/address.js (68%) rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/{myep/stores => store/modules}/crmdata.js (85%) rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/{myep/stores => store/modules}/events.js (89%) rename public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/{myep/stores => store/modules}/newsletter.js (84%) create mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/teamer.js diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js index 059117b3..addd73e5 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js @@ -45,7 +45,7 @@ Vue.filter('date', (value) => { }); // Store -import store from './_store'; +import store from './store'; // Initialize vue app new Vue({ @@ -65,7 +65,7 @@ new Vue({ Watchlist, HotelList, BackLink, - MyEp: () => import('./myep/components/App.vue'), + MyEp: () => import('./myep/App.vue'), FacebookPixel }, data () { @@ -355,8 +355,7 @@ new Vue({ } }, created () { - this.$store.commit('initConfig'); - this.$store.commit('initWatchlist'); + this.$store.dispatch('init'); EventBus.$on('ajaxContentLoaded', () => { Vue.nextTick(() => { this.initContentsliders(); diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_store.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_store.js deleted file mode 100644 index e04e000a..00000000 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_store.js +++ /dev/null @@ -1,249 +0,0 @@ -import Vue from 'vue' -import Vuex from 'vuex' -import axios from 'axios' - -import AddressStore from './myep/stores/address' -import CrmDataStore from './myep/stores/crmdata' -import TeamerStore from './myep/stores/teamer' -import EventsStore from './myep/stores/events' -import NewsletterStore from './myep/stores/newsletter' - -Vue.use(Vuex); - -export default new Vuex.Store({ - modules: { - address: AddressStore, - crmdata: CrmDataStore, - teamer: TeamerStore, - events: EventsStore, - newsletter: NewsletterStore - }, - state: { - config: {}, - watchlist: [], - loading: false, - authToken: sessionStorage.getItem('token'), - loggedIn: !!sessionStorage.getItem('token'), - isTeamer: JSON.parse(sessionStorage.getItem('isTeamer')), - memberId: JSON.parse(sessionStorage.getItem('memberId')), - memberName: sessionStorage.getItem('memberName'), - countries: [], - abilities: [], - timeFrames: [], - jobProfiles: [], - message: { - text: '', - class: '' - } - }, - mutations: { - initConfig (state) { - const configElement = document.getElementById('appconfig'); - state.config = JSON.parse(configElement.innerHTML); - axios.defaults.baseURL = state.config.myEpApiBaseUrl; - }, - initWatchlist (state, list = null) { - if (list) { - sessionStorage.setItem('watchlist', JSON.stringify(list)); - } else if (!sessionStorage.getItem('watchlist')) { - sessionStorage.setItem('watchlist', JSON.stringify({ id: null, items: [] })); - } - state.watchlist = JSON.parse(sessionStorage.getItem('watchlist')); - }, - watchlistToggle (state, uid) { - let list = state.watchlist.items; - let watchlistIndex = list.indexOf(uid); - if (watchlistIndex === -1) { - list.push(uid) - } else { - list.splice(watchlistIndex, 1) - } - state.watchlist.items = list; - sessionStorage.setItem('watchlist', JSON.stringify(state.watchlist)); - - if (state.loggedIn) { - const client = axios.create({ - headers: { - 'X-Auth-Token': state.authToken - } - }); - client.put('/api/watchlists/' + state.watchlist.id, state.watchlist); - } - }, - loginSuccess (state, token) { - state.loggedIn = true; - state.authToken = token; - sessionStorage.setItem('token', token); - }, - loginFailure (state) { - state.loggedIn = false; - }, - logout (state) { - state.loggedIn = false; - state.isTeamer = false; - state.teamerId = null; - state.authToken = null; - state.watchlist = { id: null, items: [] }; - sessionStorage.removeItem('token'); - sessionStorage.removeItem('isTeamer'); - sessionStorage.removeItem('memberId'); - sessionStorage.removeItem('memberName'); - sessionStorage.removeItem('watchlist'); - }, - alert (state, payload) { - state.message.text = payload.message; - state.message.class = payload.class; - }, - isTeamer (state) { - state.isTeamer = true; - sessionStorage.setItem('isTeamer', JSON.stringify(true)); - }, - setMember (state, member) { - state.memberId = member.id; - state.memberName = member.name; - sessionStorage.setItem('memberId', member.id); - sessionStorage.setItem('memberName', member.name); - }, - loadingBegin (state) { - state.loading = true; - state.message.text = ''; - state.message.class = ''; - }, - loadingFinish (state) { - state.loading = false; - }, - setCountries (state, countries) { - state.countries = countries; - }, - setAbilities (state, abilities) { - state.abilities = abilities; - }, - setTimeFrames (state, timeFrames) { - state.timeFrames = timeFrames; - }, - setJobProfiles (state, jobProfiles) { - state.jobProfiles = jobProfiles; - } - }, - actions: { - login({ commit }, credentials) { - commit('loadingBegin'); - const formData = new FormData(); - formData.append('_username', credentials.email); - formData.append('_password', credentials.password); - return axios({ - url: '/api/login', - data: formData, - method: 'post', - withCredentials: true - }).then((response) => { - let memberId = parseInt(response.data.member_id); - commit('setMember', { id: memberId, name: response.data.member_name }); - if (response.data.watchlist) { - commit('initWatchlist', response.data.watchlist); - } - if (response.data.is_teamer) { - commit('isTeamer'); - } - commit('loginSuccess', response.data.token); - commit('loadingFinish'); - }).catch((error) => { - commit('loginFailure'); - commit('alert', { - message: 'Der Login ist fehlgeschlagen :(', - class: 'alert-danger' - }); - commit('loadingFinish'); - throw error; - }); - }, - logout({ commit, state }) { - commit('loadingBegin'); - return axios({ - url: '/api/logout', - headers: { - 'x-auth-token': state.authToken - } - }).then(() => { - commit('logout'); - commit('loadingFinish'); - }).catch((error) => { - commit('alert', { - message: 'Der Logout ist fehlgeschlagen :(', - class: 'alert-danger' - }); - commit('loadingFinish'); - throw error; - }); - }, - resetPassword({ commit }, email) { - commit('loadingBegin'); - const formData = new FormData(); - formData.append('email', email); - return axios({ - url: '/api/reset-password', - data: formData, - method: 'post' - }).then((response) => { - commit('loadingFinish'); - return response; - }).catch((error) => { - commit('loadingFinish'); - throw error; - }); - }, - register({ commit }, userData) { - commit('loadingBegin'); - return axios({ - url: '/api/addresses', - data: userData, - method: 'post' - }).then((response) => { - commit('loadingFinish'); - return response; - }).catch((error) => { - commit('loadingFinish'); - throw error; - }); - }, - loadSelectableValues ({ commit }) { - axios({ - url: '/api/countries', - }).then((response) => { - commit('setCountries', response.data['hydra:member']); - }); - axios({ - url: '/api/teamer-abilities', - }).then((response) => { - commit('setAbilities', response.data['hydra:member']); - }); - axios({ - url: '/api/timeframes', - }).then((response) => { - commit('setTimeFrames', response.data['hydra:member']); - }); - axios({ - url: '/api/teamer-job-profiles', - }).then((response) => { - commit('setJobProfiles', response.data['hydra:member']); - }); - } - }, - getters: { - watchlistCount: state => { - return state.watchlist.items.length; - }, - onWatchlist: (state) => (uid) => { - return state.watchlist.items.indexOf(uid) !== -1; - }, - authToken: state => { - return state.authToken; - }, - isTeamer: state => { - return state.isTeamer; - }, - teamerId: state => { - return state.teamerId; - } - } -}); diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/WatchlistToggle.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/WatchlistToggle.vue index de6056ef..20911cd3 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/WatchlistToggle.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/WatchlistToggle.vue @@ -24,7 +24,7 @@ }, methods: { toggleWatchlist () { - this.$store.commit('watchlistToggle', this.uid); + this.$store.dispatch('watchlistToggle', this.uid); EventBus.$emit('watchlistToggle'); } }, diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Address.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Address.vue similarity index 73% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Address.vue rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Address.vue index 1d3faefb..3eab91b2 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Address.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Address.vue @@ -8,30 +8,30 @@ - + + +
- +
-
+
- - {{ formErrors.name }} + + {{ formErrors.lastName }}
- + {{ formErrors.firstName }}
@@ -46,28 +46,28 @@ - + {{ formErrors.street }}
- + {{ formErrors.zipCode }}
- + {{ formErrors.city }}
- @@ -77,20 +77,20 @@ - + {{ formErrors.email }}
- +
- +
@@ -107,22 +107,24 @@ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/App.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/App.vue similarity index 65% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/App.vue rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/App.vue index cc1f19c3..629f45b4 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/App.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/App.vue @@ -16,36 +16,34 @@ Newsletter Mein Profil Reise-Historie - Teamer + Teamer
-
+
-
+
- {{ $store.state.message.text }} + {{ alert.message }}
-
-
- -
+
+
- diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/CrmData.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/CrmData.vue similarity index 91% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/CrmData.vue rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/CrmData.vue index ddaa56ba..a071fdd4 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/CrmData.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/CrmData.vue @@ -44,7 +44,7 @@ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Events.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Events.vue similarity index 91% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Events.vue rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Events.vue index 86994402..47cfd443 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Events.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Events.vue @@ -42,9 +42,9 @@ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Login.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Login.vue similarity index 93% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Login.vue rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Login.vue index 5f98f635..a0df5c7f 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Login.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Login.vue @@ -42,7 +42,7 @@ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Registration.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Registration.vue similarity index 95% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Registration.vue rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Registration.vue index 45936343..efba99d0 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Registration.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Registration.vue @@ -65,7 +65,7 @@ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Teamer.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Teamer.vue similarity index 78% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Teamer.vue rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Teamer.vue index f70e7f36..2cd40715 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/components/Teamer.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Teamer.vue @@ -6,10 +6,10 @@

Fährst du Ski oder Board?

-
+
@@ -17,10 +17,10 @@

Mögliche Jobprofile

-
+
@@ -30,7 +30,7 @@
@@ -40,7 +40,7 @@ -
@@ -48,7 +48,7 @@ -
@@ -56,22 +56,22 @@ - +

Verfügbarkeiten

-
+
@@ -92,7 +92,7 @@ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/teamer.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/teamer.js deleted file mode 100644 index 63e1ebd9..00000000 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/teamer.js +++ /dev/null @@ -1,60 +0,0 @@ -import EventBus from '../../_bus'; -import axios from 'axios'; - -export default { - namespaced: true, - state: {}, - actions: { - load ({ commit, rootState }) { - commit('loadingBegin', null, { root: true }); - - const client = axios.create({ - headers: { - 'X-Auth-Token': rootState.authToken - } - }); - - return client.get('/api/teamers/' + rootState.memberId) - .then((response) => { - commit('loadingFinish', null, { root: true }); - return response.data; - }).catch((error) => { - commit('loadingFinish', null, { root: true }); - commit('alert', { - message: 'Es ist ein Fehler aufgetreten :(', - class: 'alert-danger' - }, { root: true }); - commit('logout', null, { root: true }); - EventBus.$emit('forcedLogout'); - throw error; - }); - }, - save ({ commit, rootState }, data) { - commit('loadingBegin', null, { root: true }); - - const client = axios.create({ - headers: { - 'X-Auth-Token': rootState.authToken - } - }); - - return client.put('/api/teamers/' + rootState.memberId, data) - .then(() => { - commit('loadingFinish', null, { root: true }); - commit('alert', { - message: 'Die Änderungen wurden gespeichert', - class: 'alert-success' - }, { root: true }); - }).catch((error) => { - commit('loadingFinish', null, { root: true }); - commit('alert', { - message: 'Es ist ein Fehler aufgetreten :(', - class: 'alert-danger' - }, { root: true }); - commit('logout', null, { root: true }); - EventBus.$emit('forcedLogout'); - throw error; - }); - } - } -} diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/_router.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/router/index.js similarity index 70% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/_router.js rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/router/index.js index 5db0b8ff..64777b52 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/_router.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/router/index.js @@ -1,30 +1,28 @@ import Vue from 'vue'; import VueRouter from 'vue-router'; -import store from './../_store'; +import store from '../store'; Vue.use(VueRouter); const guard = (to, from, next) => { if (store.state.loading) { next(false); - } else if (store.state.loggedIn) { - if (to.meta.requiresTeamer && !store.getters.isTeamer) { - next(false); - } else { - next(); - } - } else { + } else if (store.getters.isLoggedIn === false) { next({ name: 'login' }); + } else if (to.meta.requiresTeamer && store.getters.isTeamer === false) { + next(false); + } else { + next(); } }; -import Address from './components/Address.vue' -import Events from './components/Events.vue' -import Login from './components/Login.vue' -import CrmData from './components/CrmData.vue' -import Teamer from './components/Teamer.vue' -import Newsletter from './components/Newsletter.vue' -import Registration from './components/Registration' +import Address from '../myep/Address' +import Events from '../myep/Events' +import Login from '../myep/Login' +import CrmData from '../myep/CrmData' +import Teamer from '../myep/Teamer' +import Newsletter from '../myep/Newsletter' +import Registration from '../myep/Registration' export default new VueRouter({ routes: [ @@ -33,7 +31,7 @@ export default new VueRouter({ path: '/', component: Login, beforeEnter (from, to, next) { - if (!store.state.loggedIn) { + if (store.getters.isLoggedIn === false) { next(); } else { next({ name: 'address' }); @@ -45,7 +43,7 @@ export default new VueRouter({ path: '/register', component: Registration, beforeEnter (from, to, next) { - if (!store.state.loggedIn) { + if (store.getters.isLoggedIn === false) { next(); } else { next({ name: 'address' }); @@ -87,5 +85,8 @@ export default new VueRouter({ path: '*', redirect: { name: 'login' } } - ] + ], + scrollBehavior (to, from, savedPosition) { + return { selector: '#myep-main', offset: { x: 0, y: 160 } } + } }); diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js new file mode 100644 index 00000000..2b4b6eb9 --- /dev/null +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js @@ -0,0 +1,208 @@ +import Vue from 'vue' +import Vuex from 'vuex' +import axios from 'axios' + +import AddressStore from './modules/address' +import CrmDataStore from './modules/crmdata' +import TeamerStore from './modules/teamer' +import EventsStore from './modules/events' +import NewsletterStore from './modules/newsletter' + +Vue.use(Vuex); + +const defaultUserData = { + isTeamer: false, + email: '', + firstName: '', + lastName: '', + gender: '', + dateOfBirth: null, + street: '', + zipCode: '', + city: '', + phoneMobile: '', + phonePrivate: '', + newsletter: false +}; + +export default new Vuex.Store({ + modules: { + address: AddressStore, + crmdata: CrmDataStore, + teamer: TeamerStore, + events: EventsStore, + newsletter: NewsletterStore + }, + state: { + config: {}, + watchlist: [], + loading: false, + authToken: null, + userData: defaultUserData, + countries: [], + alert: { + message: '', + class: '' + } + }, + mutations: { + initSession (state) { + const authToken = sessionStorage.getItem('token'); + if (authToken) { + state.authToken = authToken; + } + }, + initConfig (state) { + const configElement = document.getElementById('appconfig'); + state.config = JSON.parse(configElement.innerHTML); + axios.defaults.baseURL = state.config.myEpApiBaseUrl; + }, + initWatchlist (state) { + if (!sessionStorage.getItem('watchlist')) { + sessionStorage.setItem('watchlist', JSON.stringify([])); + } + state.watchlist = JSON.parse(sessionStorage.getItem('watchlist')); + }, + setWatchlist (state, list) { + state.watchlist = list; + sessionStorage.setItem('watchlist', JSON.stringify(state.watchlist)); + }, + setUserData (state, data) { + state.userData = data; + }, + login (state, token) { + state.authToken = token; + sessionStorage.setItem('token', token); + }, + logout (state) { + state.authToken = null; + state.watchlist = []; + state.userData = defaultUserData; + sessionStorage.removeItem('token'); + sessionStorage.removeItem('watchlist'); + }, + alert (state, payload) { + state.alert = payload; + }, + loadingBegin (state) { + state.loading = true; + state.alert = { message: '', class: ''}; + }, + loadingFinish (state) { + state.loading = false; + }, + setCountries (state, countries) { + state.countries = countries; + } + }, + actions: { + init({ commit }) { + commit('initConfig'); + commit('initWatchlist'); + }, + initSession({ commit, dispatch }) { + commit('initSession'); + return dispatch('loadSelectableValues') + }, + login({ commit, dispatch }, credentials) { + commit('loadingBegin'); + return axios({ + url: '/api/login_check', + method: 'post', + data: { + username: credentials.email, + password: credentials.password + } + }).then(response => { + commit('login', response.data.token); + }).catch(error => { + commit('logout'); + commit('alert', { + message: 'Der Login ist fehlgeschlagen :(', + class: 'alert-danger' + }); + throw error; + }).finally(() => { + commit('loadingFinish'); + }); + }, + logout({ commit, state }) { + commit('loadingBegin'); + const client = axios.create({ + headers: { + 'Authorization': 'Bearer ' + state.authToken, + } + }); + return client({ + url: '/api/logout' + }).then(() => { + commit('logout'); + }).catch(error => { + commit('alert', { + message: 'Der Logout ist fehlgeschlagen :(', + class: 'alert-danger' + }); + throw error; + }).finally(() => { + commit('loadingFinish'); + }); + }, + resetPassword({ commit }, email) { + commit('loadingBegin'); + return axios({ + url: '/api/reset-password', + data: { email: email }, + method: 'post' + }).then(response => { + return response; + }).catch(error => { + throw error; + }).finally(() => { + commit('loadingFinish'); + }); + }, + register({ commit }, userData) { + commit('loadingBegin'); + return axios({ + url: '/api/register', + data: userData, + method: 'post' + }).then(response => { + return response; + }).catch(error => { + throw error; + }).finally(() => { + commit('loadingFinish'); + }); + }, + loadSelectableValues ({ commit }) { + commit('loadingBegin'); + return axios({ + url: '/api/countries', + }).then(response => { + commit('setCountries', response.data); + }).finally(() => { + commit('loadingFinish'); + }); + }, + watchlistToggle ({ commit, state }, uid) { + let list = state.watchlist; + let watchlistIndex = list.indexOf(uid); + if (watchlistIndex === -1) { + list.push(uid) + } else { + list.splice(watchlistIndex, 1) + } + commit('setWatchlist', list); + if (!!state.authToken) { + axios.put('/api/watchlist', list) + } + }, + }, + getters: { + watchlistCount: state => state.watchlist.length, + onWatchlist: (state) => (uid) => state.watchlist.indexOf(uid) !== -1, + isLoggedIn: state => !!state.authToken, + isTeamer: state => state.userData.isTeamer, + } +}); diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/address.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/address.js similarity index 68% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/address.js rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/address.js index 3ca0b8f7..6aaba9f2 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/address.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/address.js @@ -1,4 +1,3 @@ -import EventBus from '../../_bus'; import axios from 'axios'; export default { @@ -10,23 +9,24 @@ export default { const client = axios.create({ headers: { - 'X-Auth-Token': rootState.authToken + 'Authorization': 'Bearer ' + rootState.authToken, } }); - return client.get('/api/addresses') - .then((response) => { - commit('loadingFinish', null, { root: true }); - return response.data['hydra:member'][0]; - }).catch((error) => { - commit('loadingFinish', null, { root: true }); + return client.get('/api/address') + .then(response => { + commit('setUserData', response.data, { root: true }); + if (response.data.watchlist) { + commit('setWatchlist', response.data.watchlist, { root: true }); + } + }).catch(() => { commit('alert', { message: 'Es ist ein Fehler aufgetreten :(', class: 'alert-danger' }, { root: true }); commit('logout', null, { root: true }); - EventBus.$emit('forcedLogout'); - throw error; + }).finally(() => { + commit('loadingFinish', null, { root: true }); }); }, save ({ commit, rootState }, data) { @@ -34,25 +34,25 @@ export default { const client = axios.create({ headers: { - 'X-Auth-Token': rootState.authToken + 'Authorization': 'Bearer ' + rootState.authToken, } }); - return client.put('/api/addresses/' + data.id, data) + return client.put('/api/address', data) .then(() => { - commit('loadingFinish', null, { root: true }); commit('alert', { message: 'Die Änderungen wurden gespeichert', class: 'alert-success' }, { root: true }); }) - .catch((error) => { - commit('loadingFinish', null, { root: true }); + .catch(error => { commit('alert', { message: 'Es ist ein Fehler aufgetreten :(', class: 'alert-danger' }, { root: true }); throw error; + }).finally(() => { + commit('loadingFinish', null, { root: true }); }); } } diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/crmdata.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/crmdata.js similarity index 85% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/crmdata.js rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/crmdata.js index 5d394dd8..fae24675 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/crmdata.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/crmdata.js @@ -1,4 +1,3 @@ -import EventBus from '../../_bus'; import axios from 'axios'; export default { @@ -10,14 +9,14 @@ export default { const client = axios.create({ headers: { - 'X-Auth-Token': rootState.authToken + 'Authorization': 'Bearer ' + rootState.authToken } }); return client.get('/api/crm-selections') .then((response) => { commit('loadingFinish', null, { root: true }); - return response.data['hydra:member'][0]; + return response.data; }).catch((error) => { commit('loadingFinish', null, { root: true }); commit('alert', { @@ -25,7 +24,6 @@ export default { class: 'alert-danger' }, { root: true }); commit('logout', null, { root: true }); - EventBus.$emit('forcedLogout'); throw error; }); }, @@ -34,7 +32,7 @@ export default { const client = axios.create({ headers: { - 'X-Auth-Token': rootState.authToken + 'Authorization': 'Bearer ' + rootState.authToken } }); @@ -52,7 +50,6 @@ export default { class: 'alert-danger' }, { root: true }); commit('logout', null, { root: true }); - EventBus.$emit('forcedLogout'); throw error; }); } diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/events.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/events.js similarity index 89% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/events.js rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/events.js index d55f97f4..5232859f 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/events.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/events.js @@ -10,14 +10,14 @@ export default { const client = axios.create({ headers: { - 'X-Auth-Token': rootState.authToken + 'Authorization': 'Bearer ' + rootState.authToken } }); return client.get('/api/events') .then((response) => { commit('loadingFinish', null, { root: true }); - return response.data['hydra:member']; + return response.data; }).catch((error) => { commit('loadingFinish', null, { root: true }); commit('alert', { diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/newsletter.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/newsletter.js similarity index 84% rename from public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/newsletter.js rename to public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/newsletter.js index a134f6f6..5cf3c614 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/stores/newsletter.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/newsletter.js @@ -10,20 +10,18 @@ export default { const client = axios.create({ headers: { - 'X-Auth-Token': rootState.authToken + 'Authorization': 'Bearer ' + rootState.authToken } }); - return client.put('/api/newsletters/' + data.id, data) + return client.put('/api/newsletter', data) .then(() => { - commit('loadingFinish', null, { root: true }); commit('alert', { message: 'Die Änderungen wurden gespeichert', class: 'alert-success' }, { root: true }); }) .catch((error) => { - commit('loadingFinish', null, { root: true }); commit('alert', { message: 'Es ist ein Fehler aufgetreten :(', class: 'alert-danger' @@ -31,6 +29,8 @@ export default { commit('logout', null, { root: true }); EventBus.$emit('forcedLogout'); throw error; + }).finally(() => { + commit('loadingFinish', null, { root: true }); }); } } diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/teamer.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/teamer.js new file mode 100644 index 00000000..496b9676 --- /dev/null +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/teamer.js @@ -0,0 +1,75 @@ +import EventBus from '../../_bus'; +import axios from 'axios'; + +export default { + namespaced: true, + state: { + abilities: [], + timeFrames: [], + jobProfiles: [] + }, + mutations: { + setAbilities (state, abilities) { + state.abilities = abilities; + }, + setTimeFrames (state, timeFrames) { + state.timeFrames = timeFrames; + }, + setJobProfiles (state, jobProfiles) { + state.jobProfiles = jobProfiles; + } + }, + actions: { + save ({ commit, rootState }, data) { + commit('loadingBegin', null, { root: true }); + + const client = axios.create({ + headers: { + 'Authorization': 'Bearer ' + rootState.authToken + } + }); + + return client.put('/api/teamer/', data) + .then(() => { + commit('alert', { + message: 'Die Änderungen wurden gespeichert', + class: 'alert-success' + }, { root: true }); + }).catch(error => { + commit('alert', { + message: 'Es ist ein Fehler aufgetreten :(', + class: 'alert-danger' + }, { root: true }); + commit('logout', null, { root: true }); + EventBus.$emit('forcedLogout'); + throw error; + }).finally(() => { + commit('loadingFinish', null, { root: true }); + }); + }, + loadSelectableValues ({ commit, rootState }) { + commit('loadingBegin', null, { root: true }); + + const client = axios.create({ + headers: { + 'Authorization': 'Bearer ' + rootState.authToken + } + }); + + return client.get('/api/teamer-data') + .then(response => { + commit('setAbilities', response.data.abilities); + commit('setTimeFrames', response.data.timeFrames); + commit('setJobProfiles', response.data.jobProfiles); + }).catch(error => { + }).finally(() => { + commit('loadingFinish', null, { root: true }); + }); + } + }, + getters: { + abilities: state => state.abilities, + jobProfiles: state => state.jobProfiles, + timeFrames: state => state.timeFrames + } +} From 4b462da45f83996176c6c6fd0186f387e5a94ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Fri, 27 Sep 2019 13:25:07 +0200 Subject: [PATCH 04/22] Integrate watchlist closer into store --- .../Assets/js/components/Watchlist.vue | 10 +++++--- .../Assets/js/components/WatchlistToggle.vue | 5 ++-- .../Private/Assets/js/store/index.js | 24 +++++++++---------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/Watchlist.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/Watchlist.vue index a2117bfe..ccf905de 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/Watchlist.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/Watchlist.vue @@ -22,6 +22,7 @@ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js index 2b4b6eb9..7ed6e933 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js @@ -22,7 +22,8 @@ const defaultUserData = { city: '', phoneMobile: '', phonePrivate: '', - newsletter: false + newsletter: false, + watchList: [] }; export default new Vuex.Store({ @@ -35,7 +36,6 @@ export default new Vuex.Store({ }, state: { config: {}, - watchlist: [], loading: false, authToken: null, userData: defaultUserData, @@ -58,16 +58,17 @@ export default new Vuex.Store({ axios.defaults.baseURL = state.config.myEpApiBaseUrl; }, initWatchlist (state) { - if (!sessionStorage.getItem('watchlist')) { - sessionStorage.setItem('watchlist', JSON.stringify([])); + if (!sessionStorage.getItem('watchList')) { + sessionStorage.setItem('watchList', JSON.stringify([])); } - state.watchlist = JSON.parse(sessionStorage.getItem('watchlist')); + state.userData.watchList = JSON.parse(sessionStorage.getItem('watchList')); }, setWatchlist (state, list) { - state.watchlist = list; - sessionStorage.setItem('watchlist', JSON.stringify(state.watchlist)); + state.userData.watchList = list; + sessionStorage.setItem('watchList', JSON.stringify(list)); }, setUserData (state, data) { + data.watchList = [...state.userData.watchList, ...data.watchList]; state.userData = data; }, login (state, token) { @@ -76,7 +77,6 @@ export default new Vuex.Store({ }, logout (state) { state.authToken = null; - state.watchlist = []; state.userData = defaultUserData; sessionStorage.removeItem('token'); sessionStorage.removeItem('watchlist'); @@ -186,7 +186,7 @@ export default new Vuex.Store({ }); }, watchlistToggle ({ commit, state }, uid) { - let list = state.watchlist; + let list = state.userData.watchList; let watchlistIndex = list.indexOf(uid); if (watchlistIndex === -1) { list.push(uid) @@ -200,9 +200,9 @@ export default new Vuex.Store({ }, }, getters: { - watchlistCount: state => state.watchlist.length, - onWatchlist: (state) => (uid) => state.watchlist.indexOf(uid) !== -1, + watchlistCount: state => state.userData.watchList.length, + onWatchlist: (state) => (uid) => state.userData.watchList.indexOf(uid) !== -1, isLoggedIn: state => !!state.authToken, - isTeamer: state => state.userData.isTeamer, + isTeamer: state => !!state.userData.isTeamer, } }); From ed51294ee53cc09d13ad5e01fa0e68e11b778248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Fri, 27 Sep 2019 13:25:18 +0200 Subject: [PATCH 05/22] Remove scrollbehaviour --- .../ext/ep_theme/Resources/Private/Assets/js/router/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/router/index.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/router/index.js index 64777b52..b8384dda 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/router/index.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/router/index.js @@ -85,8 +85,5 @@ export default new VueRouter({ path: '*', redirect: { name: 'login' } } - ], - scrollBehavior (to, from, savedPosition) { - return { selector: '#myep-main', offset: { x: 0, y: 160 } } - } + ] }); From 8cd0aabe29421559fc24b1bb72ace8bbb0334bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Fri, 27 Sep 2019 13:25:34 +0200 Subject: [PATCH 06/22] Adjust crmdata store --- .../ep_theme/Resources/Private/Assets/js/myep/CrmData.vue | 6 ++---- .../Resources/Private/Assets/js/store/modules/crmdata.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/CrmData.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/CrmData.vue index a071fdd4..f7d39233 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/CrmData.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/CrmData.vue @@ -62,13 +62,11 @@ this.$store.dispatch('crmdata/load') .then((data) => { this.crmData = data; - }).catch(error => { - }); + }).catch(error => {}); }, saveSelections () { this.$store.dispatch('crmdata/save', this.crmData) - .catch(error => { - }); + .catch(error => {}); }, hasVisibleSelections (group) { if (this.hiddenSelectionGroups.indexOf(group.id) !== -1) { diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/crmdata.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/crmdata.js index fae24675..9f842a5d 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/crmdata.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/crmdata.js @@ -36,7 +36,7 @@ export default { } }); - return client.put('/api/crm-selections/' + data.id, data) + return client.put('/api/crm-selections', data) .then(() => { commit('loadingFinish', null, { root: true }); commit('alert', { From 9db2fd456df702f892686997c40b35c4949d845d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Sat, 28 Sep 2019 10:26:34 +0200 Subject: [PATCH 07/22] Allow cookies on login --- .../ext/ep_theme/Resources/Private/Assets/js/store/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js index 7ed6e933..052bc390 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/index.js @@ -112,7 +112,8 @@ export default new Vuex.Store({ data: { username: credentials.email, password: credentials.password - } + }, + withCredentials: true }).then(response => { commit('login', response.data.token); }).catch(error => { @@ -203,6 +204,6 @@ export default new Vuex.Store({ watchlistCount: state => state.userData.watchList.length, onWatchlist: (state) => (uid) => state.userData.watchList.indexOf(uid) !== -1, isLoggedIn: state => !!state.authToken, - isTeamer: state => !!state.userData.isTeamer, + isTeamer: state => !!state.userData.isTeamer } }); From 5713c811cc4619ced398824885a4082bf4a3446c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Sat, 28 Sep 2019 10:26:41 +0200 Subject: [PATCH 08/22] Adjust to teamer data api --- .../Resources/Private/Assets/js/myep/Teamer.vue | 12 +++++++++++- .../Private/Assets/js/store/modules/teamer.js | 4 +--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Teamer.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Teamer.vue index 2cd40715..cb659995 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Teamer.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Teamer.vue @@ -111,7 +111,17 @@ this.$store.dispatch('teamer/loadSelectableValues'); }, saveTeamerData () { - this.$store.dispatch('teamer/save', this.teamerData) + const data = { + abilities: this.userData.abilities, + jobProfiles: this.userData.jobProfiles, + availableTimeFrames: this.userData.availableTimeFrames, + jacketSize: this.userData.jacketSize, + seniority: this.userData.seniority, + wantsToLead: this.userData.wantsToLead, + monthLong: this.userData.monthLong, + notes: this.userData.notes, + }; + this.$store.dispatch('teamer/save', data) .catch(error => { }); } diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/teamer.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/teamer.js index 496b9676..c24a81d4 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/teamer.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/teamer.js @@ -1,4 +1,3 @@ -import EventBus from '../../_bus'; import axios from 'axios'; export default { @@ -29,7 +28,7 @@ export default { } }); - return client.put('/api/teamer/', data) + return client.put('/api/teamer-data', data) .then(() => { commit('alert', { message: 'Die Änderungen wurden gespeichert', @@ -41,7 +40,6 @@ export default { class: 'alert-danger' }, { root: true }); commit('logout', null, { root: true }); - EventBus.$emit('forcedLogout'); throw error; }).finally(() => { commit('loadingFinish', null, { root: true }); From ebbebcca08b03b78abdba54f29ad0ba4fe2201db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Sat, 28 Sep 2019 22:40:29 +0200 Subject: [PATCH 09/22] Code cleanup --- .../Assets/js/components/HotelList.vue | 6 +- .../Assets/js/components/Watchlist.vue | 3 +- .../Assets/js/components/WatchlistToggle.vue | 4 +- .../Private/Assets/js/myep/Address.vue | 38 +++-- .../Resources/Private/Assets/js/myep/App.vue | 15 +- .../Private/Assets/js/myep/CrmData.vue | 68 +++++--- .../Private/Assets/js/myep/Events.vue | 34 ++-- .../Private/Assets/js/myep/Login.vue | 25 +-- .../Private/Assets/js/myep/Newsletter.vue | 38 ++++- .../Private/Assets/js/myep/Registration.vue | 55 ++++--- .../Private/Assets/js/myep/Teamer.vue | 65 ++++++-- .../Private/Assets/js/router/index.js | 4 +- .../Private/Assets/js/store/index.js | 147 ++++++++++-------- .../Assets/js/store/modules/address.js | 59 ------- .../Assets/js/store/modules/crmdata.js | 57 ------- .../Private/Assets/js/store/modules/events.js | 33 ---- .../Assets/js/store/modules/newsletter.js | 37 ----- .../Private/Assets/js/store/modules/teamer.js | 73 --------- 18 files changed, 319 insertions(+), 442 deletions(-) delete mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/address.js delete mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/crmdata.js delete mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/events.js delete mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/newsletter.js delete mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/store/modules/teamer.js diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/HotelList.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/HotelList.vue index d6dad1a4..64a58fd3 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/HotelList.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/HotelList.vue @@ -1,11 +1,13 @@ diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Address.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Address.vue index 3eab91b2..efd98f1d 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Address.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/Address.vue @@ -1,7 +1,7 @@