mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
Working schedule v2
This commit is contained in:
34
public/js/calendar.js
vendored
34
public/js/calendar.js
vendored
@@ -1,5 +1,13 @@
|
||||
function initFullCalendar(authToken) {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
let urlParam = new URLSearchParams(window.location.search);
|
||||
let initDate = urlParam.get("d");
|
||||
if (initDate == null) {
|
||||
initDate = moment().format("YYYY-MM-DD");
|
||||
urlParam.set("d",initDate.toString());
|
||||
}
|
||||
history.pushState({id: 'schedule'},'Horaire - C-CMS', '/admin/schedule?'+urlParam.toString());
|
||||
|
||||
var calendarEl = document.getElementById('fullCalendar');
|
||||
|
||||
var calendar = new FullCalendar.Calendar(calendarEl, {
|
||||
@@ -10,6 +18,7 @@ function initFullCalendar(authToken) {
|
||||
center: 'dayGridMonth,listWeek',
|
||||
right: 'prev,next'
|
||||
},
|
||||
defaultDate: initDate,
|
||||
events: '/api/schedule/events',
|
||||
eventRender: function(event, element) {
|
||||
if (event.event.extendedProps.icon && event.view.type == 'dayGridMonth')
|
||||
@@ -28,9 +37,16 @@ function initFullCalendar(authToken) {
|
||||
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);
|
||||
let urlParams = new URLSearchParams(window.location.search);
|
||||
urlParams.set("e",info.event.id);
|
||||
history.pushState({id: 'schedule'},'Horaire - C-CMS', '/admin/schedule?'+urlParams.toString());
|
||||
});
|
||||
$('#schedulemodal').modal('toggle')
|
||||
},
|
||||
datesRender(arg) {
|
||||
urlParam.set("d",moment(arg.view.currentStart).format("YYYY-MM-DD"));
|
||||
history.pushState({id: 'schedule'},'Horaire - C-CMS', '/admin/schedule?'+urlParam.toString());
|
||||
},
|
||||
dateClick: function (info) {
|
||||
var date = moment(info.date).format("YYYY-MM-DD");
|
||||
Swal.fire({
|
||||
@@ -47,12 +63,28 @@ function initFullCalendar(authToken) {
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
calendar.render();
|
||||
if (urlParam.get('e') != null) {
|
||||
$.get("/api/schedule/events/modal/full/" + urlParam.get('e')+ "/event?api_token="+authToken, function (data) {
|
||||
$("#modal-content").html(data);
|
||||
$('#schedulemodal').modal('toggle')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function closeScheduleModal() {
|
||||
let urlParams = new URLSearchParams(window.location.search);
|
||||
urlParams.delete("e");
|
||||
if (urlParams.entries().next().done) {
|
||||
history.pushState({id: 'schedule'},'Horaire - C-CMS', '/admin/schedule');
|
||||
} else {
|
||||
history.pushState({id: 'schedule'},'Horaire - C-CMS', '/admin/schedule?'+urlParams.toString());
|
||||
}
|
||||
$('#schedulemodal').modal('toggle');
|
||||
}
|
||||
|
||||
function switchType(date) {
|
||||
|
||||
var selectInput = $('#type')
|
||||
|
||||
152
public/js/plugins/schedule/editorv2.js
vendored
152
public/js/plugins/schedule/editorv2.js
vendored
@@ -8,16 +8,30 @@ function initEditor(event_id = 1, mode = 'schedule')
|
||||
let editor = $('#editor');
|
||||
editorMode = mode;
|
||||
eventType = null;
|
||||
let eventTypePromise = $.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/eventType/'+event_id+'?api_token='+api_token,
|
||||
success: function (template) {
|
||||
eventType = template;
|
||||
},
|
||||
error: function () {
|
||||
showNotification('error','Impossible d\'initialiser l\'éditeur d\'horaire ...','top', 'center')
|
||||
}
|
||||
});
|
||||
let eventTypePromise = null;
|
||||
if (mode == "schedule-edit") {
|
||||
eventTypePromise = $.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/event/'+event_id+'?api_token='+api_token,
|
||||
success: function (template) {
|
||||
eventType = template;
|
||||
},
|
||||
error: function () {
|
||||
showNotification('error','Impossible d\'initialiser l\'éditeur d\'horaire ...','top', 'center')
|
||||
}
|
||||
});
|
||||
} else {
|
||||
eventTypePromise = $.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/eventType/'+event_id+'?api_token='+api_token,
|
||||
success: function (template) {
|
||||
eventType = template;
|
||||
},
|
||||
error: function () {
|
||||
showNotification('error','Impossible d\'initialiser l\'éditeur d\'horaire ...','top', 'center')
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$.when(eventTypePromise).done(function () {
|
||||
console.log(eventType);
|
||||
@@ -45,7 +59,7 @@ function initEditor(event_id = 1, mode = 'schedule')
|
||||
['fullscreen']
|
||||
]
|
||||
});
|
||||
if (mode == 'eventType' || mode == 'schedule-add')
|
||||
if (mode == 'eventType' || mode == 'schedule-add' || mode == "schedule-edit")
|
||||
{
|
||||
let scheduleModel = eventType['schedule_model'];
|
||||
if (scheduleModel['default_value'])
|
||||
@@ -566,6 +580,116 @@ function loadEventType(date,id = 1)
|
||||
})
|
||||
}
|
||||
|
||||
function loadEvent(date,id)
|
||||
{
|
||||
initEditor(id,'schedule-edit').done(function () {
|
||||
|
||||
if (eventType['is_mandatory'] == 1)
|
||||
{
|
||||
$('#is_mandatory').prop('checked',true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#is_mandatory').removeAttr('checked');
|
||||
}
|
||||
|
||||
if (eventType['use_schedule'] == 1)
|
||||
{
|
||||
$('#use_schedule').prop('checked',true);
|
||||
switchUseSchedule();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#use_schedule').removeAttr('checked');
|
||||
switchUseSchedule();
|
||||
}
|
||||
|
||||
if (eventType['use_weekly_msg'] == 1)
|
||||
{
|
||||
$('#use_weekly_msg').prop('checked',true);
|
||||
switchUseWeeklyMsg();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#use_weekly_msg').removeAttr('checked');
|
||||
switchUseWeeklyMsg();
|
||||
}
|
||||
let begin_time = $('#begin_time');
|
||||
begin_time.datetimepicker({
|
||||
icons: {
|
||||
time: "fa fa-clock-o",
|
||||
date: "fa fa-calendar",
|
||||
up: "fa fa-chevron-up",
|
||||
down: "fa fa-chevron-down",
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-screenshot',
|
||||
clear: 'fa fa-trash',
|
||||
close: 'fa fa-remove'
|
||||
},
|
||||
date: new Date(moment(eventType['date_begin'],"MM/DD/YYYY HH:mm A"))
|
||||
});
|
||||
let end_time = $('#end_time');
|
||||
end_time.datetimepicker({
|
||||
icons: {
|
||||
time: "fa fa-clock-o",
|
||||
date: "fa fa-calendar",
|
||||
up: "fa fa-chevron-up",
|
||||
down: "fa fa-chevron-down",
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-screenshot',
|
||||
clear: 'fa fa-trash',
|
||||
close: 'fa fa-remove'
|
||||
},
|
||||
date: new Date(moment(eventType['date_end'],"MM/DD/YYYY HH:mm A"))
|
||||
});
|
||||
let weekly_msg_publication_time = $('#weekly_msg_publication_time');
|
||||
if (eventType['use_schedule'])
|
||||
{
|
||||
weekly_msg_publication_time.datetimepicker({
|
||||
icons: {
|
||||
time: "fa fa-clock-o",
|
||||
date: "fa fa-calendar",
|
||||
up: "fa fa-chevron-up",
|
||||
down: "fa fa-chevron-down",
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-screenshot',
|
||||
clear: 'fa fa-trash',
|
||||
close: 'fa fa-remove'
|
||||
},
|
||||
date: new Date(moment(eventType['weekly_msg_publication_time'],"MM/DD/YYYY HH:mm A"))
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
weekly_msg_publication_time.datetimepicker({
|
||||
icons: {
|
||||
time: "fa fa-clock-o",
|
||||
date: "fa fa-calendar",
|
||||
up: "fa fa-chevron-up",
|
||||
down: "fa fa-chevron-down",
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-screenshot',
|
||||
clear: 'fa fa-trash',
|
||||
close: 'fa fa-remove'
|
||||
},
|
||||
date: new Date(moment(eventType['date_begin'],"MM/DD/YYYY HH:mm A").subtract(1,'days'))
|
||||
});
|
||||
}
|
||||
$('#location').val(eventType['location']);
|
||||
$('#name').val(eventType['name']);
|
||||
$('#admin_desc').trumbowyg('html', eventType['desc']);
|
||||
$('#calendar_color').val(eventType['calendar_color']);
|
||||
pickr.setColor(eventType['calendar_color']);
|
||||
$('#calendar_icon').val(eventType['calendar_icon']);
|
||||
$('#calendar_icon_display').removeAttr('class');
|
||||
$('#calendar_icon_display').addClass(eventType['calendar_icon']);
|
||||
})
|
||||
}
|
||||
|
||||
function switchUseSchedule()
|
||||
{
|
||||
if($('#use_schedule').is(":checked"))
|
||||
@@ -590,4 +714,10 @@ function switchUseWeeklyMsg()
|
||||
{
|
||||
$('#collmessagedelasemaine').addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
function removeFile(file) {
|
||||
document.getElementById("removedfile").setAttribute("value",document.getElementById("removedfile").getAttribute("value")+"|"+file);
|
||||
document.getElementById(file).remove();
|
||||
console.log(file);
|
||||
}
|
||||
Reference in New Issue
Block a user