Files
c-cms-legacy/public/js/calendar.js
2019-08-18 17:26:49 -04:00

50 lines
1.8 KiB
JavaScript
Vendored

function initFullCalendar(authToken) {
document.addEventListener('DOMContentLoaded', function () {
var calendarEl = document.getElementById('fullCalendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: ['dayGrid','interaction'],
locale: 'fr-ca',
header: {
left: 'title',
center: '',
right: 'prev,next'
},
events: '/api/schedule/events',
eventClick: function (info) {
$.get("/api/schedule/events/modal/full/" + info.event.id + "/"+ info.event.extendedProps.extraParams.db_type + "?api_token="+authToken, function (data) {
$("#modal-content").html(data);
});
$('#schedulemodal').modal('toggle')
},
dateClick: function (info) {
var date = moment(info.date).format("YYYY-MM-DD");
Swal.fire({
title: 'Ajouter un evenement?',
text: "Voulez vous ajouter un evenement le "+date,
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Oui',
cancelButtonText: 'Non',
}).then((result) => {
if (result.value) {
window.location.href = '/admin/schedule/add/'+date;
}
})
}
});
calendar.render();
});
}
function switchType(date) {
var selectInput = $('#type')
$.get( "/api/schedule/events/add/modal/"+selectInput.val()+"/"+date+"?api_token="+api_token, function( data ) {
$( "#container" ).html( data );
console.log( "Loading defaut value for activity type ("+selectInput.val()+")" );
});
}