diff --git a/amd/build/suivi-table.js b/amd/build/suivi-table.js index 0a19aa86dfd72c713148550566380f8f7585259b..19bb33672c890947c4cd232d4dc77a91a4afd91f 100644 --- a/amd/build/suivi-table.js +++ b/amd/build/suivi-table.js @@ -27,30 +27,32 @@ define(['jquery'], nb_results=$("#table-body input").length; $("#select-actions-suivi-iena").prop("disabled", true); return{ + registerSelectAll:function(){ all_selected=false; - $('#iena-select-all').on('click', function(e){ - select_all_studs(e); - }); - $(".checkstudent").on("click", function(){ - checkSelectActions(); - }) + if(!$._data( $('#iena-select-all')[0], 'events' )){ + $('#iena-select-all').on('click', function(e){ + select_all_studs(e); + }); + $(".checkstudent").on("click", function(){ + checkSelectActions(); + }) + } } } function select_all_studs(e) { - - all_selected=!all_selected; - var counter = 0; - var checks = document.querySelectorAll("#table-body tr"); - for (var i = 0; i < checks.length; i++) { - if ( checks[i].style.display != "none" || all_selected ) { - var box = checks[i].querySelector("input[type='checkbox']"); - box.checked = all_selected; - counter++; - } - } + all_selected=!all_selected; + var counter = 0; + var checks = document.querySelectorAll("#table-body tr"); + for (var i = 0; i < checks.length; i++) { + if ( checks[i].style.display != "none" || all_selected ) { + var box = checks[i].querySelector("input[type='checkbox']"); + box.checked = all_selected; + counter++; + } + } checkSelectActions(); } diff --git a/amd/build/suivi.js b/amd/build/suivi.js index 023f08f6d40f7872cdd30dff858956cfb5de3bcc..37194de7f5fb8dbee94d26addd43b9b609b1a087 100644 --- a/amd/build/suivi.js +++ b/amd/build/suivi.js @@ -54,8 +54,9 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], e.stopPropagation(); }); - registerActivityFilter(); + changeSection(); + registerSelectAllActivitiesFilter(); /*calcPercentage(data); changeCompletion();*/ } @@ -203,15 +204,11 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], else{ data=calcPercentage(data); changeCompletion(); - //reloadTable(data); } changeActivitiesDropdown(data.modules); - - - - //reloadTable(data); } + //Charge les activités dynamiquement en fonction de la section choisie function changeActivitiesDropdown(modules){ //html='<li><label class="checkbox"><input type="checkbox" class="selectall" value="all" checked>Toutes les activités</label></li><li class="divider"></li>'; html=""; @@ -223,6 +220,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], } $(".iena-dynamic-options").html(html); registerActivityFilter(); + checkAllActivitiesFilter(); } function displayActivities(){ @@ -270,6 +268,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], }); } + //Reload table with nex parameters. function reloadTable(params){ url=getCompleteUrl(); templates.render('format_iena/suivi-table', params) @@ -278,6 +277,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], templates.runTemplateJS(js); window.history.pushState('suivi',"", url); initHeaders(); + }) .fail(function(){ loadMessage("error"); @@ -476,20 +476,11 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], //reloadTable(data); } - function registerActivityFilter(){ - /* $('body').on("click", ".dropdown-menu", function (e) { - $(this).parent().is(".open") && e.stopPropagation(); - });*/ - + //Evenement pour le selectall : créé une seule fois au chargement de la page + function registerSelectAllActivitiesFilter(){ $('.selectall').click(function() { - if ($(this).is(':checked')) { - $('.option').prop('checked', true); - var total = $('input[name="options[]"]:checked').length; - var message=str.get_string('selectedActivities', 'format_iena'); - $.when(message).done(function(localizedEditString) { - $(".dropdown-text").html(total + ' '+localizedEditString); - }); - $(".select-text").html(' Deselect'); + if ($(".selectall").is(':checked')) { + checkAllActivitiesFilter(); } else { $('.option').prop('checked', false); var message=str.get_string('selectedActivities', 'format_iena'); @@ -499,29 +490,52 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], $(".select-text").html(' Select'); } }); + initActivityFilter(); + } + + //On va recharger dynamiquement les options donc on doit recréer les événements à chaque fois qu'on change de section + function registerActivityFilter(){ $("input[type='checkbox'].justone").change(function(){ var a = $("input[type='checkbox'].justone"); if(a.length == a.filter(":checked").length){ + console.log("on va sélectionner tout du coup"); $('.selectall').prop('checked', true); $(".select-text").html(' Deselect'); } else { + console.log("on va décocher le sélectionner tout"); $('.selectall').prop('checked', false); $(".select-text").html(' Select'); } - var total = $('input[name="options[]"]:checked').length; - var message=str.get_string('selectedActivities', 'format_iena'); - $.when(message).done(function(localizedEditString) { - $(".dropdown-text").html(total + ' '+localizedEditString); - }); + displayTotalActivitiesFilter(); }); - - $('#iena-activities-dropdown').on('change', function(e){ + + $("input[type='checkbox'].justone").on('click', function(e){ + e.stopPropagation(); displayActivities(); }); - initActivityFilter(); + + } + + //Update activities filter label + function displayTotalActivitiesFilter(){ + var total = $('input[name="options[]"]:checked').length; + if(total == $('input[name="options[]"]').length){ + var message=str.get_string('allActivities', 'format_iena'); + $.when(message).done(function(localizedEditString) { + $(".dropdown-text").html(localizedEditString); + }); + } + else{ + var message=str.get_string('selectedActivities', 'format_iena'); + $.when(message).done(function(localizedEditString) { + $(".dropdown-text").html(total + ' '+localizedEditString); + }); + } + + } //Stocke le filtre des activités en localStorage pour ne pas avoir 50 id dans l'url @@ -546,8 +560,16 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], } } } + displayTotalActivitiesFilter(); } - + //Coche toutes les activités quand on change de section + function checkAllActivitiesFilter(){ + $('.selectall').prop('checked', true); + $('.option').prop('checked', true); + displayTotalActivitiesFilter(); + $(".select-text").html(' Deselect'); + + } }); diff --git a/lang/en/format_iena.php b/lang/en/format_iena.php index f50af72507ac34715700dbc96aa96b692d56c43d..b62f177e0250650f8d5d5a9e4ffe7a9a8511de24 100644 --- a/lang/en/format_iena.php +++ b/lang/en/format_iena.php @@ -99,4 +99,5 @@ $string['message_dist'] = "distance learning mail"; $string['message_dist_desc'] = "Configure default blended course message"; $string['message_default_dist'] = "Default message distance learning"; $string['formatenabled']="Course completion is disabled. You can enable it in the \"Course completion\" section here: "; -$string['selectedActivities']="selected"; \ No newline at end of file +$string['selectedActivities']="selected"; +$string['allActivities']="All"; \ No newline at end of file diff --git a/lang/fr/format_iena.php b/lang/fr/format_iena.php index 00614fe8e19f0a43049b77f50b197d4d233ab9d9..e174d3282c80ae01eaf20901bf4bcca33229d059 100644 --- a/lang/fr/format_iena.php +++ b/lang/fr/format_iena.php @@ -99,4 +99,5 @@ $string['message_dist'] = "Message distanciel"; $string['message_dist_desc'] = "Paramétrez le message qui sera envoyé par défaut pour un cours à distance"; $string['message_default_dist'] = "message par défaut distance"; $string['formatenabled']="L'achèvement de cours n'est pas activé. Vous pouvez l'activer dans la section \"Achèvement de cours\" des paramètres du cours : "; -$string['selectedActivities']="sélectionnée(s)"; \ No newline at end of file +$string['selectedActivities']="sélectionnée(s)"; +$string['allActivities']="Toutes"; \ No newline at end of file diff --git a/styles.css b/styles.css index 68bd43056b4769f04b1d99a7760af0e55c66504c..ed0d263c06686d5fdde0c0c934e07d2abdcb8e4b 100644 --- a/styles.css +++ b/styles.css @@ -999,7 +999,7 @@ th.first-column-iena, th.second-column-iena, th.actions-column-iena, th.third-co .iena-custom-dropdown{ border-radius: 0 5px 5px 0; border: 1px solid #e9ecef; - min-width: 11rem; + min-width: 13rem !important; } .iena-custom-dropdown button{ @@ -1010,6 +1010,8 @@ th.first-column-iena, th.second-column-iena, th.actions-column-iena, th.third-co .iena-custom-dropdown .dropdown-menu{ border-radius: 0 0 0.5rem 0.5rem; width:100%; + max-height: 200px; + overflow-y: auto; } .iena-custom-dropdown .dropdown-menu label{ @@ -1024,6 +1026,13 @@ th.first-column-iena, th.second-column-iena, th.actions-column-iena, th.third-co .iena-custom-dropdown .dropdown-text{ text-align: left; } + +.iena-custom-dropdown .dropdown-toggle::after{ + position: absolute; + right: 10px; + top: 13px; +} + .iena-dynamic-options{ list-style: none; padding: 0; @@ -1035,4 +1044,5 @@ th.first-column-iena, th.second-column-iena, th.actions-column-iena, th.third-co margin: 9px 0; overflow: hidden; background-color: #e5e5e5; -} \ No newline at end of file +} + diff --git a/templates/suivi.mustache b/templates/suivi.mustache index 19ea55ae04203d6740740f50a95bffc09b20d97c..d7002c41daf1a0c3e238852b4723fa5c8d2e75d8 100644 --- a/templates/suivi.mustache +++ b/templates/suivi.mustache @@ -36,7 +36,7 @@ <div class="input-group-text">Section</div> </div> <select class="custom-select mr-sm-2" id="section-select" name="sectionid"> - <option value="0">Toutes</option> + <option value="0">{{# str }} allActivities, format_iena {{/ str}}</option> {{#sections}} <option {{selected}} value={{id}}>{{name}}</option> {{/sections}} @@ -49,7 +49,7 @@ <div class="input-group-text">Activités</div> </div> <div class="dropdown mr-sm-2 iena-custom-dropdown"> - <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><span class="dropdown-text">Toutes</span> + <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><span class="dropdown-text">{{# str }} allActivities, format_iena {{/ str}}</span> <span class="caret"></span></button> <ul class="dropdown-menu dropdown-menu-form" id="iena-activities-dropdown"> <li><label class="checkbox"><input type="checkbox" class="selectall" checked value='all'>Toutes les activités</label></li>