diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js index edc0a616c..a520f22c4 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js @@ -17,7 +17,7 @@ const getLocations = () => fetchResults('/api/1.0/main/location.json'); const getLocationTypes = () => fetchResults('/api/1.0/main/location-type.json'); -const getUserCurrentLocation = +const getUserCurrentLocation = () => fetch('/api/1.0/main/user-current-location.json') .then(response => { if (response.ok) { return response.json(); } @@ -35,6 +35,13 @@ const getLocationTypeByDefaultFor = (entity) => { ); }; +/** + * Post a location + * + * **NOTE**: also in use for Calendar + * @param body + * @returns {Promise} + */ const postLocation = (body) => { const url = `/api/1.0/main/location.json`; return fetch(url, { diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js index 6125140a5..056dc129d 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js @@ -55,7 +55,7 @@ const makeAccompanyingPeriodLocation = (locationType, store) => { export default function prepareLocations(store) { -// find the locations + // find the locations let allLocations = getLocations().then( (results) => { store.commit('addAvailableLocationGroup', { @@ -111,7 +111,7 @@ export default function prepareLocations(store) { if (window.default_location_id) { for (let group of store.state.availableLocations) { let location = group.locations.find((l) => l.id === window.default_location_id); - if (location !== undefined & store.state.activity.location === null) { + if (location !== undefined && store.state.activity.location === null) { store.dispatch('updateLocation', location); break; } 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 741dbd120..2c6ae1a26 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/actions.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/actions.js @@ -1,14 +1,13 @@ -import {toRaw} from "vue"; import { addIdToValue, removeIdFromValue, - mapEntity } from './utils'; import { fetchCalendarRangeForUser, fetchCalendarRemoteForUser, } from './../api'; import {datetimeToISO} from 'ChillMainAssets/chill/js/date'; +import {postLocation} from 'ChillActivityAssets/vuejs/Activity/api'; /** * This will store a unique key for each value, and prevent to launch the same diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/index.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/index.js index 3eeea4985..ffb186cdf 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/index.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/index.js @@ -1,17 +1,12 @@ import 'es6-promise/auto'; import { createStore } from 'vuex'; -import { toRaw } from 'vue'; import { postLocation } from 'ChillActivityAssets/vuejs/Activity/api'; import getters from './getters'; import actions from './actions'; import mutations from './mutations'; import { mapEntity } from './utils'; import { whoami } from '../api'; - -import { - getLocations, getLocationTypeByDefaultFor, - getUserCurrentLocation -} from "ChillActivityAssets/vuejs/Activity/api"; +import prepareLocations from "ChillActivityAssets/vuejs/Activity/store.locations"; const debug = process.env.NODE_ENV !== 'production'; @@ -59,4 +54,6 @@ for (let u of store.state.activity.users) { store.commit('showUserOnCalendar', {ranges: false, remotes: false, user: u}); } +prepareLocations(store); + export default store; diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/mutations.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/mutations.js index 957d09ede..8fd73d1d0 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/mutations.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/mutations.js @@ -162,15 +162,12 @@ export default { userData.remotes = userData.remotes.concat(eventRemotes); userData.remotesLoaded.push({start, end}); }, - /* -// Calendar -setEvents(state, payload) { - console.log(payload) - state.currentEvent = {start: payload.start, end: payload.end} -},*/ // Location updateLocation(state, value) { console.log('### mutation: updateLocation', value); state.activity.location = value; - } + }, + addAvailableLocationGroup(state, group) { + state.availableLocations.push(group); + }, }; diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/newByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/newByAccompanyingCourse.html.twig index c4bb1f587..43fe6cb04 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/newByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/newByAccompanyingCourse.html.twig @@ -18,6 +18,7 @@ {{ encore_entry_script_tags('mod_pickentity_type') }} {{ encore_entry_script_tags('vue_calendar') }} {% endblock %}