WIP Migrate watchlist
This commit is contained in:
@@ -54,6 +54,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// LEGACY CODE FROM HERE ///
|
||||||
|
|
||||||
// Import dependencies
|
// Import dependencies
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
@@ -81,7 +82,6 @@ import OsmMap from './components/OsmMap.vue'
|
|||||||
import Calendar from './components/Calendar.vue'
|
import Calendar from './components/Calendar.vue'
|
||||||
import EventPricetable from './components/EventPriceTable.vue'
|
import EventPricetable from './components/EventPriceTable.vue'
|
||||||
import ContactForm from './components/ContactForm.vue'
|
import ContactForm from './components/ContactForm.vue'
|
||||||
import WatchlistToggle from './components/WatchlistToggle.vue'
|
|
||||||
import Watchlist from './components/Watchlist.vue'
|
import Watchlist from './components/Watchlist.vue'
|
||||||
import HotelList from './components/HotelList.vue'
|
import HotelList from './components/HotelList.vue'
|
||||||
|
|
||||||
@@ -113,7 +113,6 @@ new Vue({
|
|||||||
Calendar,
|
Calendar,
|
||||||
EventPricetable,
|
EventPricetable,
|
||||||
ContactForm,
|
ContactForm,
|
||||||
WatchlistToggle,
|
|
||||||
Watchlist,
|
Watchlist,
|
||||||
HotelList,
|
HotelList,
|
||||||
MyEp: () => import('./myep/App.vue'),
|
MyEp: () => import('./myep/App.vue'),
|
||||||
|
|||||||
@@ -3,6 +3,5 @@
|
|||||||
require('font-awesome/css/font-awesome.min.css');
|
require('font-awesome/css/font-awesome.min.css');
|
||||||
require('cookieconsent/build/cookieconsent.min.css');
|
require('cookieconsent/build/cookieconsent.min.css');
|
||||||
require('@fancyapps/fancybox/dist/jquery.fancybox.min.css');
|
require('@fancyapps/fancybox/dist/jquery.fancybox.min.css');
|
||||||
require('slick-carousel/slick/slick.css');
|
|
||||||
require('leaflet/dist/leaflet.css');
|
require('leaflet/dist/leaflet.css');
|
||||||
require('flatpickr/dist/flatpickr.css');
|
require('flatpickr/dist/flatpickr.css');
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import WatchlistToggle from './WatchlistToggle'
|
|
||||||
|
|
||||||
import defaultFilterSettings from '../_filtersettings'
|
import defaultFilterSettings from '../_filtersettings'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
|
||||||
WatchlistToggle,
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
referringPageUrl: {
|
referringPageUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
import DaterangeSelect from './DaterangeSelect.vue'
|
import DaterangeSelect from './DaterangeSelect.vue'
|
||||||
import AjaxContent from './AjaxContent.vue'
|
import AjaxContent from './AjaxContent.vue'
|
||||||
import Calendar from './Calendar.vue'
|
import Calendar from './Calendar.vue'
|
||||||
import WatchlistToggle from './WatchlistToggle.vue'
|
|
||||||
import OsmMap from './OsmMap.vue'
|
import OsmMap from './OsmMap.vue'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import 'dayjs/locale/de'
|
import 'dayjs/locale/de'
|
||||||
@@ -26,7 +25,6 @@
|
|||||||
DaterangeSelect,
|
DaterangeSelect,
|
||||||
AjaxContent,
|
AjaxContent,
|
||||||
Calendar,
|
Calendar,
|
||||||
WatchlistToggle,
|
|
||||||
OsmMap,
|
OsmMap,
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
|||||||
+8
-5
@@ -61,19 +61,22 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<watchlist-toggle :uid="item.key" class="teaserbox-watchlist"></watchlist-toggle>
|
<a href="#"
|
||||||
|
data-controller="watchlist-toggle"
|
||||||
|
:data-watchlist-toggle-uid-value="item.key"
|
||||||
|
data-action="watchlist-toggle#toggle">
|
||||||
|
<span data-microtip-position="top" data-watchlist-toggle-target="tooltip" role="tooltip">
|
||||||
|
<i class="fa" data-watchlist-toggle-target="icon"></i>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import 'dayjs/locale/de'
|
import 'dayjs/locale/de'
|
||||||
import WatchlistToggle from './WatchlistToggle.vue'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
|
||||||
WatchlistToggle
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
item: {
|
item: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { mapState, mapGetters } from 'vuex'
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import EventBus from '../_bus'
|
import EventBus from '../_bus'
|
||||||
import SearchResultItem from './SearchResultItem.vue'
|
import SearchResultItem from './SearchResultItem.vue'
|
||||||
@@ -58,13 +57,13 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadList () {
|
loadList () {
|
||||||
if (this.watchlistCount === 0) {
|
if (this.watchlist.length === 0) {
|
||||||
this.teasers = {};
|
this.teasers = {};
|
||||||
this.total = 0;
|
this.total = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let query = {};
|
let query = {};
|
||||||
query['tx_epproducts_ajax[watchlistUids]'] = this.userData.watchList;
|
query['tx_epproducts_ajax[watchlistUids]'] = this.watchlist;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
axios({
|
axios({
|
||||||
url: this.watchlistUri,
|
url: this.watchlistUri,
|
||||||
@@ -84,11 +83,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['userData']),
|
watchlist() {
|
||||||
...mapGetters(['watchlistCount', 'onWatchlist'])
|
const initialList = JSON.parse(sessionStorage.getItem('myep-watchlist'))
|
||||||
|
return initialList ? initialList : []
|
||||||
|
},
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
EventBus.$on('watchlistToggle', () => {
|
EventBus.$on('oggle', () => {
|
||||||
this.loadList();
|
this.loadList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a href="#" @click.prevent="toggleWatchlist()">
|
|
||||||
<span data-microtip-position="top" :aria-label="onWatchlist ? 'von der Merkliste löschen' : 'auf die Merkliste setzen'" role="tooltip">
|
|
||||||
<i class="fa" :class="{ 'fa-minus-circle': onWatchlist, 'fa-plus-circle': !onWatchlist }"></i>
|
|
||||||
</span>
|
|
||||||
<span v-if="layout === 'link'">
|
|
||||||
{{ onWatchlist ? 'von der Merkliste entfernen' : 'auf die Merkliste setzen' }}
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import EventBus from '../_bus'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
uid: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
layout: {
|
|
||||||
type: String,
|
|
||||||
default: 'toggle'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
toggleWatchlist () {
|
|
||||||
this.$store.dispatch('watchlistToggle', this.uid);
|
|
||||||
EventBus.$emit('watchlistToggle');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
onWatchlist () {
|
|
||||||
return this.$store.getters.onWatchlist(this.uid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
import { Controller } from 'stimulus'
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
|
||||||
|
static targets = [ 'watchlist' ]
|
||||||
|
|
||||||
|
updateWatchlist(e) {
|
||||||
|
this.watchlistTarget.style.display = e.detail.length ? 'block' : 'none'
|
||||||
|
}
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
import { Controller } from 'stimulus'
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
|
||||||
|
static targets = [ 'tooltip', 'label', 'icon' ]
|
||||||
|
static values = { uid: String, onList: Boolean }
|
||||||
|
|
||||||
|
connect() {
|
||||||
|
const list = this.getCurrentList()
|
||||||
|
this.onListValue = -1 !== list.indexOf(this.uidValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle(e) {
|
||||||
|
e.preventDefault()
|
||||||
|
const list = this.getCurrentList()
|
||||||
|
const listIndex = list.indexOf(this.uidValue)
|
||||||
|
if (-1 === listIndex) {
|
||||||
|
list.push(this.uidValue)
|
||||||
|
this.onListValue = true
|
||||||
|
} else {
|
||||||
|
list.splice(listIndex, 1)
|
||||||
|
this.onListValue = false
|
||||||
|
}
|
||||||
|
sessionStorage.setItem('myep-watchlist', JSON.stringify(list))
|
||||||
|
window.dispatchEvent(new CustomEvent('watchlist-update', {
|
||||||
|
detail: list
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
onListValueChanged() {
|
||||||
|
const label = this.onListValue ? 'von der Merkliste entfernen' : 'auf die Merkliste setzen'
|
||||||
|
if (this.hasTooltipTarget) {
|
||||||
|
this.tooltipTarget.setAttribute('aria-label', label)
|
||||||
|
}
|
||||||
|
if (this.hasLabelTarget) {
|
||||||
|
this.labelTarget.textContent = label
|
||||||
|
}
|
||||||
|
if (this.hasIconTarget) {
|
||||||
|
this.iconTarget.classList.toggle('fa-minus-circle', this.onListValue)
|
||||||
|
this.iconTarget.classList.toggle('fa-plus-circle', !this.onListValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentList() {
|
||||||
|
const initialList = JSON.parse(sessionStorage.getItem('myep-watchlist'))
|
||||||
|
return initialList ? initialList : []
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,6 @@ const defaultUserData = {
|
|||||||
phoneMobile: '',
|
phoneMobile: '',
|
||||||
phonePrivate: '',
|
phonePrivate: '',
|
||||||
newsletter: false,
|
newsletter: false,
|
||||||
watchList: []
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
@@ -47,16 +46,6 @@ export default new Vuex.Store({
|
|||||||
state.config = JSON.parse(configElement.innerHTML);
|
state.config = JSON.parse(configElement.innerHTML);
|
||||||
axios.defaults.baseURL = state.config.myEpApiBaseUrl;
|
axios.defaults.baseURL = state.config.myEpApiBaseUrl;
|
||||||
},
|
},
|
||||||
initWatchlist(state) {
|
|
||||||
if (!sessionStorage.getItem('myep-watchlist')) {
|
|
||||||
sessionStorage.setItem('myep-watchlist', JSON.stringify([]));
|
|
||||||
}
|
|
||||||
state.userData.watchList = JSON.parse(sessionStorage.getItem('myep-watchlist'));
|
|
||||||
},
|
|
||||||
setWatchlist(state, list) {
|
|
||||||
state.userData.watchList = list;
|
|
||||||
sessionStorage.setItem('myep-watchlist', JSON.stringify(list));
|
|
||||||
},
|
|
||||||
setUserData(state, data) {
|
setUserData(state, data) {
|
||||||
data.watchList = [...state.userData.watchList, ...data.watchList];
|
data.watchList = [...state.userData.watchList, ...data.watchList];
|
||||||
state.userData = data;
|
state.userData = data;
|
||||||
@@ -73,7 +62,6 @@ export default new Vuex.Store({
|
|||||||
state.refreshToken = null;
|
state.refreshToken = null;
|
||||||
sessionStorage.removeItem('myep-auth-token');
|
sessionStorage.removeItem('myep-auth-token');
|
||||||
sessionStorage.removeItem('myep-refresh-token');
|
sessionStorage.removeItem('myep-refresh-token');
|
||||||
sessionStorage.removeItem('myep-watchlist');
|
|
||||||
},
|
},
|
||||||
alert(state, payload) {
|
alert(state, payload) {
|
||||||
state.alert = payload;
|
state.alert = payload;
|
||||||
@@ -94,7 +82,6 @@ export default new Vuex.Store({
|
|||||||
actions: {
|
actions: {
|
||||||
init({commit}) {
|
init({commit}) {
|
||||||
commit('initConfig');
|
commit('initConfig');
|
||||||
commit('initWatchlist');
|
|
||||||
commit('initSession');
|
commit('initSession');
|
||||||
},
|
},
|
||||||
login({commit, dispatch}, credentials) {
|
login({commit, dispatch}, credentials) {
|
||||||
@@ -155,19 +142,6 @@ export default new Vuex.Store({
|
|||||||
commit('endLoading');
|
commit('endLoading');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
watchlistToggle({commit, state}, uid) {
|
|
||||||
let list = state.userData.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)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
loadAddress({commit, state}) {
|
loadAddress({commit, state}) {
|
||||||
commit('beginLoading');
|
commit('beginLoading');
|
||||||
|
|
||||||
@@ -211,7 +185,6 @@ export default new Vuex.Store({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
watchlistCount: state => state.userData.watchList.length,
|
|
||||||
onWatchlist: state => uid => state.userData.watchList.indexOf(uid) !== -1,
|
onWatchlist: state => uid => state.userData.watchList.indexOf(uid) !== -1,
|
||||||
isLoggedIn: state => !!state.authToken,
|
isLoggedIn: state => !!state.authToken,
|
||||||
isTeamer: state => !!state.userData.isTeamer,
|
isTeamer: state => !!state.userData.isTeamer,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
|
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
|
||||||
<div class="ep-contactnav">
|
<div class="ep-contactnav" data-controller="contactbar" data-action="watchlist-update@window->contactbar#updateWatchlist">
|
||||||
<a href="{f:uri.typolink(parameter: settings.watchlistPageUid)}" class="bg-red watchlist"
|
<a href="{f:uri.typolink(parameter: settings.watchlistPageUid)}" class="bg-red watchlist"
|
||||||
v-show="$store.getters.watchlistCount > 0" v-cloak rel="nofollow">
|
data-contactbar-target="watchlist" rel="nofollow">
|
||||||
<span class="fa fa-list" aria-hidden="true"></span>
|
<span class="fa fa-list" aria-hidden="true"></span>
|
||||||
<div>Merkliste ({{ $store.getters.watchlistCount }})</div>
|
<div>Merkliste ({{ $store.getters.watchlistCount }})</div>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -117,7 +117,12 @@
|
|||||||
</f:else>
|
</f:else>
|
||||||
</f:if>
|
</f:if>
|
||||||
</div>
|
</div>
|
||||||
<watchlist-toggle uid="{item.hotel.uid}:{product.uid}" class="teaserbox-watchlist"></watchlist-toggle>
|
<a href="#"
|
||||||
|
class="teaserbox-watchlist"
|
||||||
|
data-controller="watchlist-toggle"
|
||||||
|
data-watchlist-toggle-uid-value="{item.hotel.uid}:{product.uid}"
|
||||||
|
data-action="watchlist-toggle#toggle">
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</f:section>
|
</f:section>
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,12 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<watchlist-toggle uid="{teaser.key}" class="teaserbox-watchlist"></watchlist-toggle>
|
<a href="#"
|
||||||
|
class="teaserbox-watchlist"
|
||||||
|
data-controller="watchlist-toggle"
|
||||||
|
data-watchlist-toggle-uid-value="{teaser.key}"
|
||||||
|
data-action="watchlist-toggle#toggle">
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</f:section>
|
</f:section>
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<p>
|
<p>
|
||||||
<watchlist-toggle uid="{hotel.uid}:{product.uid}" layout="link"></watchlist-toggle>
|
<a href="#"
|
||||||
|
data-controller="watchlist-toggle"
|
||||||
|
data-watchlist-toggle-uid-value="{hotel.uid}:{product.uid}"
|
||||||
|
data-action="watchlist-toggle#toggle">
|
||||||
|
<span data-microtip-position="top" data-watchlist-toggle-target="tooltip" role="tooltip">
|
||||||
|
<i class="fa" data-watchlist-toggle-target="icon"></i>
|
||||||
|
</span>
|
||||||
|
<span data-watchlist-toggle-target="label">
|
||||||
|
auf die Merkliste setzen
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a href="{f:uri.typolink(parameter: settings.coronaUpdatesPageUid)}"
|
<a href="{f:uri.typolink(parameter: settings.coronaUpdatesPageUid)}"
|
||||||
|
|||||||
Reference in New Issue
Block a user