From c20024ed96cc68951f79f970006c589e5d5b4865 Mon Sep 17 00:00:00 2001 From: Mathieu Lagace Date: Mon, 23 Dec 2019 17:57:41 -0500 Subject: [PATCH] Update schedule editor --- app/Http/Controllers/OCOMController.php | 27 ++++++ .../Controllers/ScheduleEditorController.php | 2 +- public/css/material-dashboard.css | 6 +- public/js/plugins/autocomplete.js | 10 ++ public/js/plugins/schedule/editor.js | 82 +++++++++++++++- .../admin/schedule/editor/course.blade.php | 93 +++++++++++++------ .../admin/schedule/editor/template.blade.php | 44 +++++++-- .../views/admin/schedule/event/add.blade.php | 6 +- routes/api.php | 3 +- 9 files changed, 229 insertions(+), 44 deletions(-) diff --git a/app/Http/Controllers/OCOMController.php b/app/Http/Controllers/OCOMController.php index e0c4c129..16e7d2bc 100644 --- a/app/Http/Controllers/OCOMController.php +++ b/app/Http/Controllers/OCOMController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\OCOM; use Illuminate\Http\Request; +use function GuzzleHttp\json_encode; use function GuzzleHttp\Psr7\str; class OCOMController extends Controller @@ -699,4 +700,30 @@ X20,\"Participer à des activités { // } + + public function jsonList() + { + $ocoms = \App\OCOM::all(); + + $name = []; + + foreach ($ocoms as $ocom) { + array_push($name, $ocom->ocom); + } + + return json_encode($name); + } + + public function getName(string $ocom) + { + $foo = \App\OCOM::all()->where('ocom','=',$ocom)->first(); + if($foo != null) + { + return $foo->objectif_competence; + } + else + { + return null; + } + } } diff --git a/app/Http/Controllers/ScheduleEditorController.php b/app/Http/Controllers/ScheduleEditorController.php index 4387b10d..bd4e9664 100644 --- a/app/Http/Controllers/ScheduleEditorController.php +++ b/app/Http/Controllers/ScheduleEditorController.php @@ -56,7 +56,7 @@ class ScheduleEditorController extends Controller "end_time" => "20:30" ], 2 => [ - "name" => "Periode 1", + "name" => "Periode 2", "begin_time" => "20:30", "end_time" => "21:20" ] diff --git a/public/css/material-dashboard.css b/public/css/material-dashboard.css index 223c69a9..4b2dc50c 100644 --- a/public/css/material-dashboard.css +++ b/public/css/material-dashboard.css @@ -3305,9 +3305,9 @@ fieldset:disabled a.btn { } .btn-secondary:hover { - color: #ffffff; - background-color: #5a6268; - border-color: #545b62; + color: #ffffff !important; + background-color: #5a6268 !important; + border-color: #545b62 !important; } .btn-secondary:focus, diff --git a/public/js/plugins/autocomplete.js b/public/js/plugins/autocomplete.js index 2102ed7e..a0c6a0b0 100644 --- a/public/js/plugins/autocomplete.js +++ b/public/js/plugins/autocomplete.js @@ -103,4 +103,14 @@ function initAutoComplete(htmlClass) autocomplete(document.getElementById(this.id), users); }) }); +} + +function initAutoCompleteOCOM(htmlClass) +{ + $.get('/api/ocom/list?api_token='+api_token, function ( data ) { + var ocoms = JSON.parse(data); + $("."+htmlClass).each(function ( index ) { + autocomplete(document.getElementById(this.id), ocoms); + }) + }); } \ No newline at end of file diff --git a/public/js/plugins/schedule/editor.js b/public/js/plugins/schedule/editor.js index 7289e417..67ab97db 100644 --- a/public/js/plugins/schedule/editor.js +++ b/public/js/plugins/schedule/editor.js @@ -1,3 +1,5 @@ +var editorTemplate; + function initScheduleEditor(id, eventType) { $.ajax({ @@ -10,7 +12,8 @@ function initScheduleEditor(id, eventType) loadCourse(pniveau,pperiode); } } - initAutoComplete("AutoComplete"); + initAutoComplete("AutoCompleteUser"); + initAutoCompleteOCOM('AutoCompleteOCOM'); }, error: function () { showNotification('error','Impossible d\'initialiser l\'éditeur d\'horaire ...','top', 'center') @@ -84,6 +87,7 @@ function loadEventType(date) url: '/api/schedule/editor/template/'+id+'?api_token='+api_token, success: function (data) { var result = JSON.parse(data); + editorTemplate = result; initScheduleEditor("scheduleEditor",id) $.each(result, function (i, val) { if(i == "is_mandatory" || i == "use_schedule" || i == "use_weekly_msg") @@ -158,4 +162,80 @@ function loadEventType(date) showNotification('error','Impossible de charger le type d\'évenement ...','top', 'center') } }) +} + +function updateCourseName(niveau, periode) { + setTimeout(function(){ + let val = $('#ocom_n'+niveau+'_p'+periode).val(); + if(val != "") + { + $.ajax({ + type: 'GET', + url: '/api/ocom/'+val+'/name?api_token='+api_token, + success: function (data) { + if(data != null && data != "") + { + $('#name_n'+niveau+'_p'+periode).val(data); + } + }, + error: function () { + showNotification('error','Erreur impossible de charger l\'objectif de rendement ...','top', 'center') + } + }) + } + }, 100); +} + +function selectCourseMode(mode, niveau, periode) +{ + if(mode == "course") + { + $('#descContainer'+niveau+'-'+periode).addClass('d-none'); + $('#isDoneContainer'+niveau+'-'+periode).removeClass('d-none'); + $('#isDoneContainer'+niveau+'-'+periode).addClass('d-flex'); + $('#OCOMContainer'+niveau+'-'+periode).removeClass('d-none'); + $('#nameContainer'+niveau+'-'+periode).removeClass('d-none'); + $('#modeSwitchC'+niveau+'-'+periode).addClass('active'); + $('#modeSwitchO'+niveau+'-'+periode).removeClass('active'); + } + else + { + $('#descContainer'+niveau+'-'+periode).removeClass('d-none'); + $('#isDoneContainer'+niveau+'-'+periode).addClass('d-none'); + $('#isDoneContainer'+niveau+'-'+periode).removeClass('d-flex'); + $('#OCOMContainer'+niveau+'-'+periode).addClass('d-none'); + $('#nameContainer'+niveau+'-'+periode).addClass('d-none'); + $('#modeSwitchC'+niveau+'-'+periode).removeClass('active'); + $('#modeSwitchO'+niveau+'-'+periode).addClass('active'); + } +} + +function selectCourseModePeriode(mode,periode) +{ + $.each(editorTemplate['schedule_model']['niveaux'], function (i, val) { + selectCourseMode(mode,i+1,periode); + }); +} + +function selectCourseModeNiveau(mode,niveau) +{ + $.each(editorTemplate['schedule_model']['periodes'], function (i, val) { + selectCourseMode(mode,niveau,i+1); + }); +} + +function updatePlantext(toggle,id) +{ + if($('#'+toggle).is(":checked")) + { + $('#'+id).removeClass('text-warning'); + $('#'+id).addClass('text-success'); + $('#'+id).html('Plan de cours remis') + } + else + { + $('#'+id).addClass('text-warning'); + $('#'+id).removeClass('text-success'); + $('#'+id).html('Plan de cours non remis') + } } \ No newline at end of file diff --git a/resources/views/admin/schedule/editor/course.blade.php b/resources/views/admin/schedule/editor/course.blade.php index 74cb0673..17a7b53c 100644 --- a/resources/views/admin/schedule/editor/course.blade.php +++ b/resources/views/admin/schedule/editor/course.blade.php @@ -1,36 +1,77 @@ -
-
-
- - +
+
+
+
+ +
+
+ Plan de cours non remis +
-
-
- -
+
+
+
+
+
+ + +
+
+
+
+
+ +
+ +
+
+
+
+ + -
-
-
-
- - -
-
-
-
-
- +
-
+
+ Test +
\ No newline at end of file diff --git a/resources/views/admin/schedule/editor/template.blade.php b/resources/views/admin/schedule/editor/template.blade.php index cd64c21d..d21dd37e 100644 --- a/resources/views/admin/schedule/editor/template.blade.php +++ b/resources/views/admin/schedule/editor/template.blade.php @@ -6,11 +6,24 @@
@foreach($eventType->schedule_model['niveaux'] as $niveau)
-
- -
@endforeach @@ -23,11 +36,24 @@ @foreach($eventType->schedule_model['periodes'] as $periode)
-
- - +
+
+
+ + +
+
+
+ + +
@@ -45,7 +71,7 @@
@foreach($eventType->schedule_model['niveaux'] as $niveau) -
+
@loaderDot
@endforeach diff --git a/resources/views/admin/schedule/event/add.blade.php b/resources/views/admin/schedule/event/add.blade.php index cb2d3c2a..ca482534 100644 --- a/resources/views/admin/schedule/event/add.blade.php +++ b/resources/views/admin/schedule/event/add.blade.php @@ -58,7 +58,7 @@
-