use the location from the calendar range, when associating a range with the calendar

This commit is contained in:
Julien Fastré 2022-06-30 20:05:28 +02:00
parent 71b6b158ba
commit a5b5eea146
2 changed files with 19 additions and 1 deletions

View File

@ -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;

View File

@ -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') {