mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: add calendar range events in myCalendar
This commit is contained in:
parent
329d3cc3d8
commit
0fe6d7d00b
@ -7,6 +7,7 @@
|
|||||||
<i> {{ arg.event.title }}</i>
|
<i> {{ arg.event.title }}</i>
|
||||||
</template>
|
</template>
|
||||||
</FullCalendar>
|
</FullCalendar>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ import FullCalendar from '@fullcalendar/vue3';
|
|||||||
import dayGridPlugin from '@fullcalendar/daygrid';
|
import dayGridPlugin from '@fullcalendar/daygrid';
|
||||||
import interactionPlugin from '@fullcalendar/interaction';
|
import interactionPlugin from '@fullcalendar/interaction';
|
||||||
import timeGridPlugin from '@fullcalendar/timegrid';
|
import timeGridPlugin from '@fullcalendar/timegrid';
|
||||||
import { fetchCalendar } from '../_api/api';
|
import { fetchCalendar, fetchCalendarRangesByUser } from '../_api/api';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "App",
|
name: "App",
|
||||||
@ -30,7 +31,8 @@ export default {
|
|||||||
userId: window.userId,
|
userId: window.userId,
|
||||||
showMyCalendar: true,
|
showMyCalendar: true,
|
||||||
calendarEvents: {
|
calendarEvents: {
|
||||||
user: [],
|
userCalendar: [],
|
||||||
|
userCalendarRange: []
|
||||||
},
|
},
|
||||||
calendarOptions: {
|
calendarOptions: {
|
||||||
locale: frLocale,
|
locale: frLocale,
|
||||||
@ -59,9 +61,23 @@ export default {
|
|||||||
},
|
},
|
||||||
fetchData() {
|
fetchData() {
|
||||||
console.log(this.userId);
|
console.log(this.userId);
|
||||||
|
|
||||||
|
fetchCalendarRangesByUser(this.userId).then(calendarRanges => new Promise((resolve, reject) => {
|
||||||
|
let events = calendarRanges.results.map(i =>
|
||||||
|
({
|
||||||
|
start: i.startDate.datetime,
|
||||||
|
end: i.endDate.datetime,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
let calendarRangeEvents = {
|
||||||
|
events: events,
|
||||||
|
color: 'orange',
|
||||||
|
textColor: '#444444'
|
||||||
|
};
|
||||||
|
this.calendarEvents.userCalendarRange = calendarRangeEvents;
|
||||||
|
|
||||||
fetchCalendar(this.userId).then(calendar => new Promise((resolve, reject) => {
|
fetchCalendar(this.userId).then(calendar => new Promise((resolve, reject) => {
|
||||||
let results = calendar.results;
|
let events = calendar.results.map(i =>
|
||||||
let events = results.map(i =>
|
|
||||||
({
|
({
|
||||||
start: i.startDate.datetime,
|
start: i.startDate.datetime,
|
||||||
end: i.endDate.datetime,
|
end: i.endDate.datetime,
|
||||||
@ -73,16 +89,21 @@ export default {
|
|||||||
id: 1000,
|
id: 1000,
|
||||||
editable: false
|
editable: false
|
||||||
};
|
};
|
||||||
this.calendarEvents.user = calendarEventsCurrentUser;
|
this.calendarEvents.userCalendar = calendarEventsCurrentUser;
|
||||||
this.updateEventsSource()
|
this.updateEventsSource();
|
||||||
|
resolve();
|
||||||
|
}));
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
updateEventsSource() {
|
updateEventsSource() {
|
||||||
this.calendarOptions.eventSources = [];
|
this.calendarOptions.eventSources = [];
|
||||||
|
this.calendarOptions.eventSources.push(this.calendarEvents.userCalendarRange);
|
||||||
if (this.showMyCalendar) {
|
if (this.showMyCalendar) {
|
||||||
this.calendarOptions.eventSources.push(this.calendarEvents.user);
|
this.calendarOptions.eventSources.push(this.calendarEvents.userCalendar);
|
||||||
}
|
}
|
||||||
|
console.log(this.calendarOptions.eventSources);
|
||||||
},
|
},
|
||||||
toggleMyCalendar(value) {
|
toggleMyCalendar(value) {
|
||||||
this.showMyCalendar = value;
|
this.showMyCalendar = value;
|
||||||
@ -92,11 +113,14 @@ export default {
|
|||||||
},
|
},
|
||||||
onDateSelect(payload) {
|
onDateSelect(payload) {
|
||||||
console.log(payload)
|
console.log(payload)
|
||||||
|
this.$store.dispatch('createRange', payload);
|
||||||
},
|
},
|
||||||
onEventChange(payload) {
|
onEventChange(payload) {
|
||||||
//this.$store.dispatch('updateEvent', payload);
|
console.log(payload)
|
||||||
|
this.$store.dispatch('updateRange', payload);
|
||||||
},
|
},
|
||||||
onEventClick(payload) {
|
onEventClick(payload) {
|
||||||
|
console.log(payload)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
||||||
import { appMessages } from './i18n'
|
import { appMessages } from './i18n'
|
||||||
//import store from './store'
|
import store from './store'
|
||||||
|
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ const i18n = _createI18n(appMessages);
|
|||||||
const app = createApp({
|
const app = createApp({
|
||||||
template: `<app></app>`,
|
template: `<app></app>`,
|
||||||
})
|
})
|
||||||
//.use(store)
|
.use(store)
|
||||||
.use(i18n)
|
.use(i18n)
|
||||||
.component('app', App)
|
.component('app', App)
|
||||||
.mount('#myCalendar');
|
.mount('#myCalendar');
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
import 'es6-promise/auto';
|
||||||
|
import { createStore } from 'vuex';
|
||||||
|
|
||||||
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
|
const store = createStore({
|
||||||
|
strict: debug,
|
||||||
|
state: {
|
||||||
|
newCalendarRanges: [],
|
||||||
|
updateCalendarRanges: [],
|
||||||
|
deleteCalendarRanges: []
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
updateRange(state, payload) {
|
||||||
|
state.updateCalendarRanges.push({start: payload.start, end: payload.end});
|
||||||
|
},
|
||||||
|
addRange(state, payload) {
|
||||||
|
state.newCalendarRanges.push({start: payload.start, end: payload.end});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
createRange({ commit }, payload) {
|
||||||
|
console.log('### action createRange', payload);
|
||||||
|
commit('addRange', payload);
|
||||||
|
},
|
||||||
|
updateRange({ commit }, payload) {
|
||||||
|
console.log('### action updateRange', payload);
|
||||||
|
commit('updateRange', payload);
|
||||||
|
},
|
||||||
|
saveRanges({ commit }, payload) {
|
||||||
|
console.log('### action saveRange', payload);
|
||||||
|
postRange()
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default store;
|
@ -12,6 +12,15 @@ const fetchCalendarRanges = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const fetchCalendarRangesByUser = (userId) => {
|
||||||
|
const url = `/api/1.0/calendar/calendar-range-available.json?user=${userId}`;
|
||||||
|
return fetch(url)
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) { return response.json(); }
|
||||||
|
throw Error('Error with request resource response');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Endpoint chill_api_single_calendar
|
* Endpoint chill_api_single_calendar
|
||||||
* method GET, get Calendar events, can be filtered by mainUser
|
* method GET, get Calendar events, can be filtered by mainUser
|
||||||
@ -28,5 +37,6 @@ const fetchCalendar = (mainUserId) => {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
fetchCalendarRanges,
|
fetchCalendarRanges,
|
||||||
fetchCalendar
|
fetchCalendar,
|
||||||
|
fetchCalendarRangesByUser
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user