Ajout de la modification des event_type

This commit is contained in:
George Frederick "Buzz" Beurling
2020-04-16 18:32:02 -04:00
parent 4b659c5db1
commit f104c1b61b
14 changed files with 797 additions and 65 deletions

View File

@@ -3,7 +3,7 @@ var nbOfPeriode;
var nbOfLevel;
var emptyPeriode;
function initScheduleEditor(id, eventType)
function initScheduleEditor(id, eventType,mode = 'normal')
{
$.ajax({
type: 'GET',
@@ -12,7 +12,7 @@ function initScheduleEditor(id, eventType)
$("#"+id).html(template);
for (let pniveau = 1; pniveau <= nbOfLevel; pniveau++) {
for (let pperiode = 1; pperiode <= nbOfPeriode; pperiode++) {
loadCourse(pniveau,pperiode);
loadCourse(pniveau,pperiode,eventType,mode);
}
}
initAutoComplete("AutoCompleteUser");
@@ -21,7 +21,7 @@ function initScheduleEditor(id, eventType)
error: function () {
showNotification('error','Impossible d\'initialiser l\'éditeur d\'horaire ...','top', 'center')
}
})
});
$('.datetimepicker').datetimepicker({
icons: {
time: "fa fa-clock-o",
@@ -56,7 +56,6 @@ function initScheduleEditor(id, eventType)
]
});
$('select').selectpicker();
}
function switchUseWeeklyMsg()
@@ -85,13 +84,17 @@ function switchUseSchedule()
}
}
function loadCourse(periode,niveau)
function loadCourse(periode,niveau,id = 1,mode = 'normal')
{
$.ajax({
type: 'GET',
url: '/api/schedule/editor/course/'+niveau+'/'+periode+'?api_token='+api_token,
url: '/api/schedule/editor/course/'+niveau+'/'+periode+'/'+id+'?api_token='+api_token,
success: function (course) {
$("#container-"+niveau+"-"+periode).html(course);
if (mode == 'editor')
{
$('.no-mandatory').removeAttr('required')
}
},
error: function () {
showNotification('error','Impossible de charger les cours ...','top', 'center')
@@ -120,6 +123,21 @@ function addPeriode()
})
}
function removePeriode()
{
$('#row-'+nbOfPeriode).remove();
nbOfPeriode--;
}
function removeLevel()
{
$('#levelHeader-'+nbOfLevel).remove();
for (let i = 0; i < nbOfPeriode+1; i++) {
$('#container-'+nbOfLevel+'-'+i).remove();
}
nbOfLevel--;
}
function addLevel()
{
var levelToAdd = nbOfLevel+1;
@@ -159,7 +177,7 @@ function loadEventType(date)
editorTemplate = result;
nbOfLevel = editorTemplate.schedule_model.niveaux.length;
nbOfPeriode = editorTemplate.schedule_model.periodes.length;
initScheduleEditor("scheduleEditor",id)
initScheduleEditor("scheduleEditor",id);
$.each(result, function (i, val) {
if(i == "is_mandatory" || i == "use_schedule" || i == "use_weekly_msg")
{