diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/actions.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/actions.js index 2c6ae1a26..1c3284325 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/actions.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/actions.js @@ -149,7 +149,7 @@ export default { commit('setEventTimes', {start, end}); }, - associateCalendarToRange({state, commit, dispatch}, {range}) { + associateCalendarToRange({state, commit, dispatch, getters}, {range}) { console.log('### action associateCAlendarToRange', range); let startDateInput = document.getElementById("chill_activitybundle_activity_startDate"); startDateInput.value = null !== range ? datetimeToISO(range.start) : ""; @@ -157,6 +157,13 @@ export default { endDateInput.value = null !== range ? datetimeToISO(range.end) : ""; let calendarRangeInput = document.getElementById("chill_activitybundle_activity_calendarRange"); calendarRangeInput.value = null !== range ? Number(range.extendedProps.calendarRangeId) : ""; + let location = getters.getLocationById(range.extendedProps.locationId); + + if (null === location) { + console.error("location not found!", range.extendedProps.locationId); + } + + dispatch('updateLocation', location); if (null !== range) { const userId = range.extendedProps.userId; diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/getters.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/getters.js index 4214c7411..b2b38e2ab 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/getters.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/getters.js @@ -192,6 +192,17 @@ export default { return k.remotes; }, + getLocationById: (state) => (id) => { + for (let group of state.availableLocations) { + console.log('group', group); + const found = group.locations.find(l => l.id === id); + if (typeof found !== "undefined") { + return found; + } + } + + return null; + }, suggestedEntities(state, getters) { if (typeof (state.activity.accompanyingPeriod) === 'undefined') {