diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js index 408d68147..a752f1bfd 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js @@ -36,6 +36,7 @@ const store = createStore({ activity: mapEntity(window.entity), // activity is the calendar entity actually currentEvent: null, availableLocations: [], + mainUser: null }, getters: { suggestedEntities(state) { @@ -94,6 +95,11 @@ const store = createStore({ } }, mutations: { + setMainUser(state, mainUser) { + if (state.mainUser === null || state.mainUser.id != mainUser.id) { + state.mainUser = mainUser; + } + }, // ConcernedGroups addPersonsInvolved(state, payload) { @@ -184,7 +190,7 @@ const store = createStore({ //mainUserInput.value = payload.users.logged.id; commit('setEvents', payload); }, - updateEvent({ commit }, payload) { + updateEvent({ commit, dispatch }, payload) { console.log('### action updateEvent', payload); let startDateInput = document.getElementById("chill_activitybundle_activity_startDate"); startDateInput.value = payload.event.start.toISOString(); @@ -192,10 +198,21 @@ const store = createStore({ endDateInput.value = payload.event.end.toISOString(); let calendarRangeInput = document.getElementById("chill_activitybundle_activity_calendarRange"); calendarRangeInput.value = Number(payload.event.extendedProps.calendarRangeId); + + dispatch('setMainUser', payload.event.source); //let mainUserInput = document.getElementById("chill_activitybundle_activity_mainUser"); //mainUserInput.value = Number(payload.event.source.id); commit('setEvents', payload); }, + setMainUser({ commit }, mainUser) { + const event = new CustomEvent('pick-entity-type-action', {detail: { + name: "chill_activitybundle_activity_mainUser", + entity: mainUser, + action: 'add' + }}); + document.dispatchEvent(event); + commit('setMainUser', mainUser); + }, // Location updateLocation({ commit }, value) { diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index 4e71e8568..91839e5a2 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -101,7 +101,7 @@ document.addEventListener('show-hide-hide', function(e) { }) }); -document.addEventListener('pick-entity-type', function (e) { +document.addEventListener('pick-entity-type-action', function (e) { console.log('pick entity event', e); if (!appsPerInput.has(e.detail.name)) { console.error('no app with this name');