mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
start refactoring
This commit is contained in:
parent
e28d17a131
commit
c77af0bc4a
@ -203,7 +203,6 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
console.log('init')
|
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
},
|
},
|
||||||
openModal() {
|
openModal() {
|
||||||
@ -282,7 +281,7 @@ export default {
|
|||||||
if (this.showMyCalendar) {
|
if (this.showMyCalendar) {
|
||||||
this.calendarOptions.eventSources.push(this.calendarEvents.userCalendar);
|
this.calendarOptions.eventSources.push(this.calendarEvents.userCalendar);
|
||||||
}
|
}
|
||||||
// console.log(this.calendarOptions.eventSources);
|
console.log('eventSources', this.calendarOptions.eventSources);
|
||||||
},
|
},
|
||||||
toggleMyCalendar(value) {
|
toggleMyCalendar(value) {
|
||||||
this.showMyCalendar = value;
|
this.showMyCalendar = value;
|
||||||
@ -450,7 +449,7 @@ export default {
|
|||||||
color: "#3788d8"
|
color: "#3788d8"
|
||||||
};
|
};
|
||||||
// console.log(copiedEvents);
|
// console.log(copiedEvents);
|
||||||
|
|
||||||
// Add to the calendar
|
// Add to the calendar
|
||||||
let newEvents = this.calendarEvents.new.events;
|
let newEvents = this.calendarEvents.new.events;
|
||||||
newEvents.push(...copiedEvents.events);
|
newEvents.push(...copiedEvents.events);
|
||||||
@ -459,7 +458,7 @@ export default {
|
|||||||
color: "#3788d8"
|
color: "#3788d8"
|
||||||
};
|
};
|
||||||
this.updateEventsSource();
|
this.updateEventsSource();
|
||||||
|
|
||||||
// Set the last new date
|
// Set the last new date
|
||||||
this.lastNewDate = new Date(copiedEvents.events[copiedEvents.events.length - 1].start);
|
this.lastNewDate = new Date(copiedEvents.events[copiedEvents.events.length - 1].start);
|
||||||
|
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
import 'es6-promise/auto';
|
import 'es6-promise/auto';
|
||||||
import { createStore } from 'vuex';
|
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 debug = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
const store = createStore({
|
const store = createStore({
|
||||||
strict: debug,
|
strict: debug,
|
||||||
state: {
|
state: {
|
||||||
newCalendarRanges: [],
|
newCalendarRanges: [],
|
||||||
updateCalendarRanges: [],
|
updateCalendarRanges: [],
|
||||||
deleteCalendarRanges: []
|
deleteCalendarRanges: [],
|
||||||
|
userRanges: [],
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
setUserRanges(state, payload) {
|
||||||
|
state.userRanges = payload
|
||||||
|
},
|
||||||
updateRange(state, payload) {
|
updateRange(state, payload) {
|
||||||
state.updateCalendarRanges.push({
|
state.updateCalendarRanges.push({
|
||||||
id: payload.event.extendedProps.calendarRangeId,
|
id: payload.event.extendedProps.calendarRangeId,
|
||||||
@ -53,8 +57,19 @@ const store = createStore({
|
|||||||
)
|
)
|
||||||
state.deleteCalendarRanges = filteredCollection;
|
state.deleteCalendarRanges = filteredCollection;
|
||||||
},
|
},
|
||||||
|
addUserRange(state, payload) {
|
||||||
|
state.userRanges.push(payload);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
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) {
|
createRange({ commit }, payload) {
|
||||||
// console.log('### action createRange', payload);
|
// console.log('### action createRange', payload);
|
||||||
commit('addRange', payload);
|
commit('addRange', payload);
|
||||||
@ -85,5 +100,7 @@ const store = createStore({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
store.dispatch('setUserRanges');
|
||||||
|
|
||||||
|
|
||||||
export default store;
|
export default store;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user