mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
Update schedule editor
This commit is contained in:
131
public/js/plugins/schedule/editor.js
vendored
131
public/js/plugins/schedule/editor.js
vendored
@@ -1,8 +1,8 @@
|
||||
function initScheduleEditor(id, periode, niveau)
|
||||
function initScheduleEditor(id, eventType)
|
||||
{
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/schedule/editor/init?api_token='+api_token,
|
||||
url: '/api/schedule/editor/init/'+eventType+'?api_token='+api_token,
|
||||
success: function (template) {
|
||||
$("#"+id).html(template);
|
||||
for (let pniveau = 1; pniveau <= 3; pniveau++) {
|
||||
@@ -16,11 +16,49 @@ function initScheduleEditor(id, periode, niveau)
|
||||
showNotification('error','Impossible d\'initialiser l\'éditeur d\'horaire ...','top', 'center')
|
||||
}
|
||||
})
|
||||
$('.datetimepicker').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'
|
||||
}
|
||||
});
|
||||
$('.richeditor').trumbowyg({
|
||||
lang: 'fr'
|
||||
});
|
||||
$('select').selectpicker();
|
||||
}
|
||||
|
||||
function loadTemplate(id)
|
||||
function switchUseWeeklyMsg()
|
||||
{
|
||||
$.get('/api/schedule/editor/init?api_token='+api_token, function ( data ) {$("#"+id).html(data);});
|
||||
|
||||
if($('#use_weekly_msg').is(":checked"))
|
||||
{
|
||||
$('#collmessagedelasemaine').removeClass('d-none');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#collmessagedelasemaine').addClass('d-none');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function switchUseSchedule()
|
||||
{
|
||||
if($('#use_schedule').is(":checked"))
|
||||
{
|
||||
$('#collschedule').removeClass('d-none');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#collschedule').addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
function loadCourse(periode,niveau)
|
||||
@@ -35,4 +73,89 @@ function loadCourse(periode,niveau)
|
||||
showNotification('error','Impossible de charger les cours ...','top', 'center')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function loadEventType(date)
|
||||
{
|
||||
var selectInput = $('#type');
|
||||
var id = selectInput.val();
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/schedule/editor/template/'+id+'?api_token='+api_token,
|
||||
success: function (data) {
|
||||
var result = JSON.parse(data);
|
||||
initScheduleEditor("scheduleEditor",id)
|
||||
$.each(result, function (i, val) {
|
||||
if(i == "is_mandatory" || i == "use_schedule" || i == "use_weekly_msg")
|
||||
{
|
||||
if(val == 1)
|
||||
{
|
||||
$('#'+i).prop( "checked", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#'+i).prop( "checked", false );
|
||||
}
|
||||
switchUseSchedule();
|
||||
switchUseWeeklyMsg();
|
||||
}
|
||||
else if(i == "begin_time" || i == "end_time")
|
||||
{
|
||||
var foo = $('#'+i);
|
||||
var mdate = moment(date+" "+val);
|
||||
foo.data("DateTimePicker").destroy();
|
||||
foo.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(mdate)
|
||||
});
|
||||
|
||||
}
|
||||
else if(i == "weekly_msg_publication_time")
|
||||
{
|
||||
var foo = $('#'+i);
|
||||
var mdate = moment(date+" "+result["begin_time"]);
|
||||
mdate.subtract(5, 'days');
|
||||
foo.data("DateTimePicker").destroy();
|
||||
foo.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(mdate)
|
||||
});
|
||||
|
||||
}
|
||||
else if(i == "location" || i == "name")
|
||||
{
|
||||
var foo = $('#'+i);
|
||||
foo.val(val);
|
||||
}
|
||||
else if(i == "admin_desc")
|
||||
{
|
||||
var foo = $('#'+i);
|
||||
foo.trumbowyg('html', val);
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
showNotification('error','Impossible de charger le type d\'évenement ...','top', 'center')
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user