diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js
index 5cd97587..02628ee2 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js
@@ -2,7 +2,6 @@
// Import dependencies
import Vue from 'vue'
-import VueSession from 'vue-session'
import $ from 'jquery'
import dayjs from 'dayjs'
import 'dayjs/locale/de'
@@ -40,17 +39,18 @@ const sliderPrevArrow = '';
const sliderDot = '';
-// Enable session handling
-Vue.use(VueSession, { persist: true });
-
// Define date filter for vue templates
Vue.filter('date', (value) => {
return dayjs(value).format('DD.MM.YYYY');
});
+// Store
+import store from './_store';
+
// Initialize vue app
new Vue({
el: '#app',
+ store,
components: {
SearchBar,
SearchBox,
@@ -70,7 +70,6 @@ new Vue({
},
data () {
return {
- config: {},
maxWindowWidth: 991,
lastScrollPosition: 0,
scrollTopVisible: false,
@@ -78,20 +77,10 @@ new Vue({
navbarLocked: false,
searchbarFixed: false,
mobileMode: false,
- backgroundImageMode: 'mobile',
- watchlist: []
- }
- },
- computed: {
- watchlistCount () {
- return this.watchlist.length;
+ backgroundImageMode: 'mobile'
}
},
methods: {
- parseConfig () {
- const configElement = document.getElementById('appconfig');
- this.config = JSON.parse(configElement.innerHTML);
- },
setMobileMode () {
this.mobileMode = $window.outerWidth() < this.maxWindowWidth;
},
@@ -334,7 +323,7 @@ new Vue({
});
},
appendPaCode () {
- const paCode = this.config.paCode;
+ const paCode = this.$store.state.config.paCode;
if (!paCode) {
return;
}
@@ -356,7 +345,8 @@ new Vue({
}
},
created () {
- this.parseConfig();
+ this.$store.commit('initConfig');
+ this.$store.commit('initWatchlist');
EventBus.$on('ajaxContentLoaded', () => {
Vue.nextTick(() => {
this.initContentsliders();
@@ -373,25 +363,6 @@ new Vue({
EventBus.$on('scrollTo', (anchorId, offset) => {
this.scrollTo(anchorId, offset);
});
- EventBus.$on('watchlistToggle', uid => {
- let list = this.watchlist;
- let watchlistIndex = list.indexOf(uid);
- if (watchlistIndex === -1) {
- list.push(uid)
- } else {
- list.splice(watchlistIndex, 1)
- }
- this.watchlist = list;
- this.$session.set('watchlist', this.watchlist);
-
- });
- if (!this.$session.exists()) {
- this.$session.start();
- }
- if (!this.$session.has('watchlist')) {
- this.$session.set('watchlist', []);
- }
- this.watchlist = this.$session.get('watchlist');
},
mounted () {
Vue.nextTick(() => {
diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/_store.js b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_store.js
similarity index 62%
rename from web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/_store.js
rename to web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_store.js
index 8c6cffb4..921b33f7 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/myep/_store.js
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_store.js
@@ -2,16 +2,11 @@ import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
-import AddressStore from './stores/address'
-import CrmDataStore from './stores/crmdata'
-import TeamerStore from './stores/teamer'
-import EventsStore from './stores/events'
-import NewsletterStore from './stores/newsletter'
-
-const configElement = document.getElementById('appconfig');
-const config = JSON.parse(configElement.innerHTML);
-
-axios.defaults.baseURL = config.myEpApiBaseUrl;
+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);
@@ -24,12 +19,14 @@ export default new Vuex.Store({
newsletter: NewsletterStore
},
state: {
- config: config,
+ config: {},
+ watchlist: [],
+ watchlistId: null,
loading: false,
authToken: sessionStorage.getItem('token'),
loggedIn: !!sessionStorage.getItem('token'),
- isTeamer: JSON.parse(sessionStorage.getItem('teamerId')) !== null,
- teamerId: JSON.parse(sessionStorage.getItem('teamerId')),
+ isTeamer: JSON.parse(sessionStorage.getItem('isTeamer')),
+ memberId: JSON.parse(sessionStorage.getItem('memberId')),
countries: [],
abilities: [],
timeFrames: [],
@@ -40,6 +37,40 @@ export default new Vuex.Store({
}
},
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.items));
+ sessionStorage.setItem('watchlistId', JSON.stringify(list.id));
+ } else if (!sessionStorage.getItem('watchlist')) {
+ sessionStorage.setItem('watchlist', JSON.stringify([]));
+ sessionStorage.setItem('watchlistId', JSON.stringify(null));
+ }
+ state.watchlist = JSON.parse(sessionStorage.getItem('watchlist'));
+ state.watchlistId = JSON.parse(sessionStorage.getItem('watchlistId'));
+ },
+ watchlistToggle (state, uid) {
+ let list = state.watchlist;
+ let watchlistIndex = list.indexOf(uid);
+ if (watchlistIndex === -1) {
+ list.push(uid)
+ } else {
+ list.splice(watchlistIndex, 1)
+ }
+ state.watchlist = list;
+ sessionStorage.setItem('watchlist', JSON.stringify(list));
+ if (state.watchlistId) {
+ axios({
+ url: '/api/watchlists/' + state.watchlistId,
+ data: state.watchlist,
+ method: 'put'
+ });
+ }
+ },
loginSuccess (state, token) {
state.loggedIn = true;
state.authToken = token;
@@ -54,16 +85,20 @@ export default new Vuex.Store({
state.teamerId = null;
state.authToken = null;
sessionStorage.removeItem('token');
- sessionStorage.removeItem('teamerId');
+ sessionStorage.removeItem('isTeamer');
+ sessionStorage.removeItem('memberId');
},
alert (state, payload) {
state.message.text = payload.message;
state.message.class = payload.class;
},
- isTeamer (state, teamerId) {
+ isTeamer (state) {
state.isTeamer = true;
- state.teamerId = teamerId;
- sessionStorage.setItem('teamerId', teamerId);
+ sessionStorage.setItem('isTeamer', JSON.stringify(true));
+ },
+ setMember (state, memberId) {
+ state.memberId = memberId;
+ sessionStorage.setItem('memberId', memberId);
},
loadingBegin (state) {
state.loading = true;
@@ -98,9 +133,13 @@ export default new Vuex.Store({
method: 'post',
withCredentials: true
}).then((response) => {
- let teamerId = parseInt(response.data.teamer_id);
- if (teamerId > 0) {
- commit('isTeamer', teamerId);
+ let memberId = parseInt(response.data.member_id);
+ commit('setMember', memberId);
+ if (response.data.watchlist) {
+ commit('initWatchlist', response.data.watchlist);
+ }
+ if (response.data.is_teamer) {
+ commit('isTeamer');
}
commit('loginSuccess', response.data.token);
commit('loadingFinish');
@@ -164,6 +203,12 @@ export default new Vuex.Store({
}
},
getters: {
+ watchlistCount: state => {
+ return state.watchlist.length;
+ },
+ onWatchlist: (state) => (uid) => {
+ return state.watchlist.indexOf(uid) !== -1;
+ },
authToken: state => {
return state.authToken;
},
@@ -175,4 +220,3 @@ export default new Vuex.Store({
}
}
});
-
diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/HotelList.vue b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/HotelList.vue
index 30dc9d8b..7ccef431 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/HotelList.vue
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/HotelList.vue
@@ -31,8 +31,8 @@
}
},
created () {
- if (this.$session.has('filterSettings')) {
- this.filterSettings = this.$session.get('filterSettings')
+ if (sessionStorage.getItem('filterSettings')) {
+ this.filterSettings = JSON.parse(sessionStorage.getItem('filterSettings'));
}
}
}
diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/ProductDetail.vue b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/ProductDetail.vue
index f102232d..32a113b8 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/ProductDetail.vue
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/ProductDetail.vue
@@ -72,12 +72,6 @@
return {}
}
},
- watchlist: {
- type: Array,
- default () {
- return []
- }
- },
daytrip: {
type: Number,
default: 0
@@ -188,12 +182,12 @@
}
},
created () {
- if (this.$session.has('filterSettings')) {
- this.filterSettings = this.$session.get('filterSettings')
+ if (sessionStorage.getItem('filterSettings')) {
+ this.filterSettings = JSON.parse(sessionStorage.getItem('filterSettings'));
}
- if (this.$session.has('referringPage')) {
- this.referringPage = this.$session.get('referringPage');
- this.$session.remove('referringPage');
+ if (sessionStorage.getItem('referringPage')) {
+ this.referringPage = JSON.parse(sessionStorage.getItem('referringPage'));
+ sessionStorage.removeItem('referringPage');
}
EventBus.$on('loadDatesTable', () => {
this.loadDatesView();
diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/ReferrerLink.vue b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/ReferrerLink.vue
index aa7054ff..fbed24df 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/ReferrerLink.vue
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/ReferrerLink.vue
@@ -20,7 +20,7 @@
methods: {
storeReferringPage () {
if (this.referringPage.url && this.referringPage.label) {
- this.$session.set('referringPage', this.referringPage)
+ sessionStorage.setItem('referringPage', JSON.stringify(this.referringPage))
}
}
}
diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResult.vue b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResult.vue
index 68260f94..6d30206f 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResult.vue
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResult.vue
@@ -71,12 +71,6 @@
default () {
return {};
}
- },
- watchlist: {
- type: Array,
- default () {
- return [];
- }
}
},
computed: {
@@ -211,14 +205,14 @@
},
updateFilterSettings (settings) {
this.filterSettings = { ...this.filterSettings, ...settings };
- this.$session.set('filterSettings', this.filterSettings);
+ sessionStorage.setItem('filterSettings', JSON.stringify(this.filterSettings));
}
},
created () {
if (!$.isEmptyObject(this.initialFilterSettings)) {
this.updateFilterSettings(this.initialFilterSettings)
- } else if (this.$session.has('filterSettings')) {
- this.updateFilterSettings(this.$session.get('filterSettings'))
+ } else if (sessionStorage.getItem('filterSettings')) {
+ this.updateFilterSettings(JSON.parse(sessionStorage.getItem('filterSettings')))
}
},
mounted () {
diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResultItem.vue b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResultItem.vue
index b41b5c22..d2951a88 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResultItem.vue
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResultItem.vue
@@ -62,7 +62,7 @@
-