start refactoring

This commit is contained in:
Julie Lenaerts 2022-05-06 17:38:08 +02:00
parent e28d17a131
commit c77af0bc4a
2 changed files with 24 additions and 8 deletions

View File

@ -203,7 +203,6 @@ export default {
},
methods: {
init() {
console.log('init')
this.fetchData();
},
openModal() {
@ -282,7 +281,7 @@ export default {
if (this.showMyCalendar) {
this.calendarOptions.eventSources.push(this.calendarEvents.userCalendar);
}
// console.log(this.calendarOptions.eventSources);
console.log('eventSources', this.calendarOptions.eventSources);
},
toggleMyCalendar(value) {
this.showMyCalendar = value;
@ -450,7 +449,7 @@ export default {
color: "#3788d8"
};
// console.log(copiedEvents);
// Add to the calendar
let newEvents = this.calendarEvents.new.events;
newEvents.push(...copiedEvents.events);
@ -459,7 +458,7 @@ export default {
color: "#3788d8"
};
this.updateEventsSource();
// Set the last new date
this.lastNewDate = new Date(copiedEvents.events[copiedEvents.events.length - 1].start);

View File

@ -1,17 +1,21 @@
import 'es6-promise/auto';
import { createStore } from 'vuex';
import { postCalendarRange, patchCalendarRange, deleteCalendarRange } from '../_api/api';
import { deleteCalendarRange, fetchCalendar, fetchCalendarRangesByUser, patchCalendarRange, postCalendarRange } from '../_api/api';
const debug = process.env.NODE_ENV !== 'production';
const store = createStore({
strict: debug,
state: {
newCalendarRanges: [],
updateCalendarRanges: [],
deleteCalendarRanges: []
newCalendarRanges: [],
updateCalendarRanges: [],
deleteCalendarRanges: [],
userRanges: [],
},
mutations: {
setUserRanges(state, payload) {
state.userRanges = payload
},
updateRange(state, payload) {
state.updateCalendarRanges.push({
id: payload.event.extendedProps.calendarRangeId,
@ -53,8 +57,19 @@ const store = createStore({
)
state.deleteCalendarRanges = filteredCollection;
},
addUserRange(state, payload) {
state.userRanges.push(payload);
}
},
actions: {
setUserRanges({ commit }) {
console.log('userId', window.userId);
fetchCalendarRangesByUser(window.userId)
.then((ranges) => {
console.log('ranges', ranges.results);
commit('setUserRanges', ranges.results);
})
},
createRange({ commit }, payload) {
// console.log('### action createRange', payload);
commit('addRange', payload);
@ -85,5 +100,7 @@ const store = createStore({
}
});
store.dispatch('setUserRanges');
export default store;