Working schedule v2

This commit is contained in:
Mathieu Lagace
2020-07-30 17:46:11 -04:00
parent 8d22092ea8
commit 4c5d635d5b
25 changed files with 1174 additions and 497 deletions

View File

@@ -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);
}