From 8e173e6eacb2d51fc3d8c973b041b83fbbf38d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Thu, 4 May 2023 16:53:47 +0200 Subject: [PATCH 1/2] #1001 [Lib] add: all font awesome pictos lib --- lib/dolismq_answer.lib.php | 72 ++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/lib/dolismq_answer.lib.php b/lib/dolismq_answer.lib.php index 247d1f3a..e5b8f096 100644 --- a/lib/dolismq_answer.lib.php +++ b/lib/dolismq_answer.lib.php @@ -70,33 +70,51 @@ function get_answer_pictos_array(): array { global $langs; - $pictosArray = [ - [ - 'name' => $langs->transnoentities('None'), - 'picto_source' => $langs->transnoentities('None'), - 'position' => 0, - ], - [ - 'name' => $langs->transnoentities('Ok'), - 'picto_source' => '', - 'position' => 1 - ], - [ - 'name' => $langs->transnoentities('Ko'), - 'picto_source' => '', - 'position' => 2 - ], - [ - 'name' => $langs->transnoentities('ToFix'), - 'picto_source' => '', - 'position' => 3 - ], - [ - 'name' => $langs->transnoentities('NonApplicable'), - 'picto_source' => 'N/A', - 'position' => 4 - ], - ]; + $fontAwesomePictosList = dol_dir_list(DOL_DOCUMENT_ROOT . '\theme\common\fontawesome-5\svgs\solid'); + + $position = 0; + if (is_array($fontAwesomePictosList) && !empty($fontAwesomePictosList)) { + foreach($fontAwesomePictosList as $fontAwesomePicto) { + $pictoInfos = pathinfo($fontAwesomePicto['name']); + $pictoName = $pictoInfos['filename']; + + $pictosArray[] = [ + 'name' => ucfirst($pictoName), + 'picto_source' => '', + 'position' => $position, + ]; + + $position++; + } + } +// +// $pictosArray = [ +// [ +// 'name' => $langs->transnoentities('None'), +// 'picto_source' => $langs->transnoentities('None'), +// 'position' => 0, +// ], +// [ +// 'name' => $langs->transnoentities('Ok'), +// 'picto_source' => '', +// 'position' => 1 +// ], +// [ +// 'name' => $langs->transnoentities('Ko'), +// 'picto_source' => '', +// 'position' => 2 +// ], +// [ +// 'name' => $langs->transnoentities('ToFix'), +// 'picto_source' => '', +// 'position' => 3 +// ], +// [ +// 'name' => $langs->transnoentities('NonApplicable'), +// 'picto_source' => 'N/A', +// 'position' => 4 +// ], +// ]; return $pictosArray; } From 67a113b88c4ad56cf1c06ef0e79b15ada58a3afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20David?= Date: Thu, 4 May 2023 17:46:20 +0200 Subject: [PATCH 2/2] #1001 [Answer] add: dynamic picto search --- js/dolismq.min.js | 2 +- js/modules/question.js | 21 ++++++++++++++++++++- lib/dolismq_answer.lib.php | 5 +++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/js/dolismq.min.js b/js/dolismq.min.js index 618319a1..07635538 100644 --- a/js/dolismq.min.js +++ b/js/dolismq.min.js @@ -1 +1 @@ -window.dolismq||(window.dolismq={},window.dolismq.scriptsLoaded=!1),window.dolismq.scriptsLoaded||(window.dolismq.init=function(){window.dolismq.load_list_script()},window.dolismq.load_list_script=function(){if(!window.dolismq.scriptsLoaded){var o=void 0,t=void 0;for(o in window.dolismq)for(t in window.dolismq[o].init&&window.dolismq[o].init(),window.dolismq[o])window.dolismq[o]&&window.dolismq[o][t]&&window.dolismq[o][t].init&&window.dolismq[o][t].init();window.dolismq.scriptsLoaded=!0}},window.dolismq.refresh=function(){var o=void 0,t=void 0;for(o in window.dolismq)for(t in window.dolismq[o].refresh&&window.dolismq[o].refresh(),window.dolismq[o])window.dolismq[o]&&window.dolismq[o][t]&&window.dolismq[o][t].refresh&&window.dolismq[o][t].refresh()},$(document).ready(window.dolismq.init)),window.dolismq.control={},window.dolismq.control.init=function(){window.dolismq.control.event()},window.dolismq.control.event=function(){$(document).on("click",".answer:not(.disable)",window.dolismq.control.selectAnswer),$(document).on("input",".input-answer:not(.disable)",window.dolismq.control.selectAnswer),$(document).on("keyup",".question-comment",window.dolismq.control.writeComment),$(document).on("keyup",".question-comment",window.dolismq.control.showCommentUnsaved),$(document).on("change","#fk_product",window.dolismq.control.reloadProductLot),$(document).on("change","#fk_project",window.dolismq.control.reloadTask),$(document).on("change","#fk_soc",window.dolismq.control.reloadContact),$(document).on("click",".validateButton",window.dolismq.control.getAnswerCounter),$(document).on("change","#fk_sheet",window.dolismq.control.showSelectObjectLinked),$(document).on("click",".toggleControlInfo",window.dolismq.control.toggleControlInfo)},window.dolismq.control.selectAnswer=function(o){var t=$(this).hasClass("answer")?$(this).attr("value"):$(this).val();let e="";if($(this).closest(".table-cell").hasClass("select-answer")){if($(this).hasClass("multiple-answers")){$(this).closest("span").toggleClass("active");let o=[];$(".multiple-answers.active").each(function(){o.push($(this).attr("value"))}),e=o}else $(this).closest(".table-cell").find(".answer.active").css("background-color","#fff"),$(this).closest(".table-cell").find("span").removeClass("active"),$(this).closest("span").addClass("active"),e=t;$(this).hasClass("active")?(t=$(this).closest(".answer-cell").find(".answer-color-"+$(this).attr("value")).val(),$(this).attr("style",$(this).attr("style")+" background:"+t+";")):$(this).attr("style",$(this).attr("style")+" background:#fff;"),$(this).closest(".answer-cell").find(".question-answer").val(e)}window.dolismq.control.updateButtonsStatus()},window.dolismq.control.writeComment=function(o){var t=$(this).closest(".table-cell").find(".question-comment").attr("name"),e=$(this).closest(".table-cell").find(".question-comment").val();let n=$(this).closest(".tabBar").find(".validateButton").attr("href");n.match("&"+t+"=")&&(n=n.split("&"+t+"=")[0]),$(this).closest(".tabBar").find(".validateButton").attr("href",n+"&"+t+"="+e)},window.dolismq.control.showCommentUnsaved=function(o){$(this).hasClass("show-comment-unsaved-message")||($(this).after('

Commentaire non enregistré

'),$(this).addClass("show-comment-unsaved-message")),window.dolismq.control.updateButtonsStatus()},window.dolismq.control.updateButtonsStatus=function(){$("#saveButton").removeClass("butActionRefused"),$("#saveButton").addClass("butAction"),$("#saveButton").attr("onclick",'$("#saveControl").submit()'),$("#validateButton").removeClass("butAction"),$("#validateButton").addClass("butActionRefused")},window.dolismq.control.reloadProductLot=function(o){var t=$(".id-container").find('input[name="token"]').val(),e=document.getElementById("createControlForm"),e=new FormData(e),n=e.get("fk_sheet"),e=e.get("fk_product"),t=document.URL+(document.URL.match(/\?action=create/)?"":"?action=create")+"&token="+t+"&fk_sheet="+n+"&fk_product="+e;$.ajax({url:t,type:"POST",processData:!1,contentType:!1,success:function(o){$(".lot-container").html($(o).find(".lot-content"))},error:function(){}})},window.dolismq.control.reloadTask=function(o){var t=document.getElementById("createControlForm"),t=new FormData(t),e=t.get("fk_sheet"),t=t.get("fk_project"),n=$(".id-container").find('input[name="token"]').val(),n=document.URL+(document.URL.match(/\?action=create/)?"":"?action=create")+"&token="+n+"&fk_sheet="+e+"&fk_project="+t;$.ajax({url:n,type:"POST",processData:!1,contentType:!1,success:function(o){$(".task-container").html($(o).find(".task-content"))},error:function(){}})},window.dolismq.control.reloadContact=function(o){var t=document.getElementById("createControlForm"),t=new FormData(t),e=t.get("fk_soc"),t=t.get("fk_sheet"),n=$(".id-container").find('input[name="token"]').val(),n=document.URL+(document.URL.match(/\?action=create/)?"":"?action=create")+"&token="+n+"&fk_sheet="+t+"&fk_soc="+e;$.ajax({url:n,type:"POST",processData:!1,contentType:!1,success:function(o){$("#fk_contact").html($(o).find("#fk_contact").children())},error:function(){}})},window.dolismq.control.getAnswerCounter=function(o){let t=0;jQuery("#tablelines").children().each(function(){0<$(this).find(".answer.active").length&&(t+=1)}),document.cookie="answerCounter="+t},window.dolismq.control.showSelectObjectLinked=function(o){var t=document.getElementById("createControlForm"),t=new FormData(t),e=$(".id-container").find('input[name="token"]').val(),n=t.get("fk_sheet"),i=t.get("fk_user_controller"),t=t.get("fk_project"),n=(n=document.URL+(document.URL.match(/\?action=create/)?"":"?action=create")+"&fk_sheet="+n+"&token="+e)+("&fk_project="+t)+("&fk_user_controller="+i);window.saturne.loader.display($(".tabBar.tabBarWithBottom tbody")),$.ajax({url:n,type:"POST",processData:!1,contentType:!1,success:function(o){$(".tabBar.tabBarWithBottom tbody").html($(o).find(".tabBar.tabBarWithBottom tbody").children()),$(".wpeo-loader").removeClass("wpeo-loader")},error:function(){}})},window.dolismq.control.toggleControlInfo=function(o){$(this).hasClass("fa-minus-square")?($(this).removeClass("fa-minus-square").addClass("fa-caret-square-down"),$(this).closest(".fiche").find(".fichecenter.controlInfo").addClass("hidden")):($(this).removeClass("fa-caret-square-down").addClass("fa-minus-square"),$(this).closest(".fiche").find(".fichecenter.controlInfo").removeClass("hidden"))},window.dolismq.question={},window.dolismq.question.init=function(){window.dolismq.question.event()},window.dolismq.question.event=function(){$(document).on("click",".clicked-photo-preview",window.dolismq.question.previewPhoto),$(document).on("click",".ui-dialog-titlebar-close",window.dolismq.question.closePreviewPhoto),$(document).on("click","#show_photo",window.dolismq.question.showPhoto),$(document).on("click",".answer-picto .item, .wpeo-table .item",window.dolismq.question.selectAnswerPicto)},window.dolismq.question.previewPhoto=function(o){$(this).hasClass("photo-ok")?$("#dialogforpopup").attr("style","border: 10px solid #47e58e"):$(this).hasClass("photo-ko")&&$("#dialogforpopup").attr("style","border: 10px solid #e05353")},window.dolismq.question.closePreviewPhoto=function(o){$("#dialogforpopup").attr("style","border:")},window.dolismq.question.showPhoto=function(){var o=$(this).closest(".question-table").find(".linked-medias");o.hasClass("hidden")?(o.attr("style",""),o.removeClass("hidden")):(o.attr("style","display:none"),o.addClass("hidden"))},window.dolismq.question.selectAnswerPicto=function(o){var t=$(this).closest(".wpeo-dropdown");$(this).closest(".content").removeClass("active"),t.find(".dropdown-toggle span").hide(),t.find(".dropdown-toggle.button-picto").html($(this).closest(".wpeo-tooltip-event").html()),t.find(".input-hidden-picto").val($(this).data("id"))},window.dolismq.sheet={},window.dolismq.sheet.init=function(){window.dolismq.sheet.event()},window.dolismq.sheet.event=function(){}; \ No newline at end of file +window.dolismq||(window.dolismq={},window.dolismq.scriptsLoaded=!1),window.dolismq.scriptsLoaded||(window.dolismq.init=function(){window.dolismq.load_list_script()},window.dolismq.load_list_script=function(){if(!window.dolismq.scriptsLoaded){var o=void 0,t=void 0;for(o in window.dolismq)for(t in window.dolismq[o].init&&window.dolismq[o].init(),window.dolismq[o])window.dolismq[o]&&window.dolismq[o][t]&&window.dolismq[o][t].init&&window.dolismq[o][t].init();window.dolismq.scriptsLoaded=!0}},window.dolismq.refresh=function(){var o=void 0,t=void 0;for(o in window.dolismq)for(t in window.dolismq[o].refresh&&window.dolismq[o].refresh(),window.dolismq[o])window.dolismq[o]&&window.dolismq[o][t]&&window.dolismq[o][t].refresh&&window.dolismq[o][t].refresh()},$(document).ready(window.dolismq.init)),window.dolismq.control={},window.dolismq.control.init=function(){window.dolismq.control.event()},window.dolismq.control.event=function(){$(document).on("click",".answer:not(.disable)",window.dolismq.control.selectAnswer),$(document).on("input",".input-answer:not(.disable)",window.dolismq.control.selectAnswer),$(document).on("keyup",".question-comment",window.dolismq.control.writeComment),$(document).on("keyup",".question-comment",window.dolismq.control.showCommentUnsaved),$(document).on("change","#fk_product",window.dolismq.control.reloadProductLot),$(document).on("change","#fk_project",window.dolismq.control.reloadTask),$(document).on("change","#fk_soc",window.dolismq.control.reloadContact),$(document).on("click",".validateButton",window.dolismq.control.getAnswerCounter),$(document).on("change","#fk_sheet",window.dolismq.control.showSelectObjectLinked),$(document).on("click",".toggleControlInfo",window.dolismq.control.toggleControlInfo)},window.dolismq.control.selectAnswer=function(o){var t=$(this).hasClass("answer")?$(this).attr("value"):$(this).val();let e="";if($(this).closest(".table-cell").hasClass("select-answer")){if($(this).hasClass("multiple-answers")){$(this).closest("span").toggleClass("active");let o=[];$(".multiple-answers.active").each(function(){o.push($(this).attr("value"))}),e=o}else $(this).closest(".table-cell").find(".answer.active").css("background-color","#fff"),$(this).closest(".table-cell").find("span").removeClass("active"),$(this).closest("span").addClass("active"),e=t;$(this).hasClass("active")?(t=$(this).closest(".answer-cell").find(".answer-color-"+$(this).attr("value")).val(),$(this).attr("style",$(this).attr("style")+" background:"+t+";")):$(this).attr("style",$(this).attr("style")+" background:#fff;"),$(this).closest(".answer-cell").find(".question-answer").val(e)}window.dolismq.control.updateButtonsStatus()},window.dolismq.control.writeComment=function(o){var t=$(this).closest(".table-cell").find(".question-comment").attr("name"),e=$(this).closest(".table-cell").find(".question-comment").val();let n=$(this).closest(".tabBar").find(".validateButton").attr("href");n.match("&"+t+"=")&&(n=n.split("&"+t+"=")[0]),$(this).closest(".tabBar").find(".validateButton").attr("href",n+"&"+t+"="+e)},window.dolismq.control.showCommentUnsaved=function(o){$(this).hasClass("show-comment-unsaved-message")||($(this).after('

Commentaire non enregistré

'),$(this).addClass("show-comment-unsaved-message")),window.dolismq.control.updateButtonsStatus()},window.dolismq.control.updateButtonsStatus=function(){$("#saveButton").removeClass("butActionRefused"),$("#saveButton").addClass("butAction"),$("#saveButton").attr("onclick",'$("#saveControl").submit()'),$("#validateButton").removeClass("butAction"),$("#validateButton").addClass("butActionRefused")},window.dolismq.control.reloadProductLot=function(o){var t=$(".id-container").find('input[name="token"]').val(),e=document.getElementById("createControlForm"),e=new FormData(e),n=e.get("fk_sheet"),e=e.get("fk_product"),t=document.URL+(document.URL.match(/\?action=create/)?"":"?action=create")+"&token="+t+"&fk_sheet="+n+"&fk_product="+e;$.ajax({url:t,type:"POST",processData:!1,contentType:!1,success:function(o){$(".lot-container").html($(o).find(".lot-content"))},error:function(){}})},window.dolismq.control.reloadTask=function(o){var t=document.getElementById("createControlForm"),t=new FormData(t),e=t.get("fk_sheet"),t=t.get("fk_project"),n=$(".id-container").find('input[name="token"]').val(),n=document.URL+(document.URL.match(/\?action=create/)?"":"?action=create")+"&token="+n+"&fk_sheet="+e+"&fk_project="+t;$.ajax({url:n,type:"POST",processData:!1,contentType:!1,success:function(o){$(".task-container").html($(o).find(".task-content"))},error:function(){}})},window.dolismq.control.reloadContact=function(o){var t=document.getElementById("createControlForm"),t=new FormData(t),e=t.get("fk_soc"),t=t.get("fk_sheet"),n=$(".id-container").find('input[name="token"]').val(),n=document.URL+(document.URL.match(/\?action=create/)?"":"?action=create")+"&token="+n+"&fk_sheet="+t+"&fk_soc="+e;$.ajax({url:n,type:"POST",processData:!1,contentType:!1,success:function(o){$("#fk_contact").html($(o).find("#fk_contact").children())},error:function(){}})},window.dolismq.control.getAnswerCounter=function(o){let t=0;jQuery("#tablelines").children().each(function(){0<$(this).find(".answer.active").length&&(t+=1)}),document.cookie="answerCounter="+t},window.dolismq.control.showSelectObjectLinked=function(o){var t=document.getElementById("createControlForm"),t=new FormData(t),e=$(".id-container").find('input[name="token"]').val(),n=t.get("fk_sheet"),i=t.get("fk_user_controller"),t=t.get("fk_project"),n=(n=document.URL+(document.URL.match(/\?action=create/)?"":"?action=create")+"&fk_sheet="+n+"&token="+e)+("&fk_project="+t)+("&fk_user_controller="+i);window.saturne.loader.display($(".tabBar.tabBarWithBottom tbody")),$.ajax({url:n,type:"POST",processData:!1,contentType:!1,success:function(o){$(".tabBar.tabBarWithBottom tbody").html($(o).find(".tabBar.tabBarWithBottom tbody").children()),$(".wpeo-loader").removeClass("wpeo-loader")},error:function(){}})},window.dolismq.control.toggleControlInfo=function(o){$(this).hasClass("fa-minus-square")?($(this).removeClass("fa-minus-square").addClass("fa-caret-square-down"),$(this).closest(".fiche").find(".fichecenter.controlInfo").addClass("hidden")):($(this).removeClass("fa-caret-square-down").addClass("fa-minus-square"),$(this).closest(".fiche").find(".fichecenter.controlInfo").removeClass("hidden"))},window.dolismq.question={},window.dolismq.question.init=function(){window.dolismq.question.event()},window.dolismq.question.event=function(){$(document).on("click",".clicked-photo-preview",window.dolismq.question.previewPhoto),$(document).on("click",".ui-dialog-titlebar-close",window.dolismq.question.closePreviewPhoto),$(document).on("click","#show_photo",window.dolismq.question.showPhoto),$(document).on("click",".answer-picto .item, .wpeo-table .item",window.dolismq.question.selectAnswerPicto),$(document).on("input","#pictoSearch",window.dolismq.question.searchPicto)},window.dolismq.question.previewPhoto=function(o){$(this).hasClass("photo-ok")?$("#dialogforpopup").attr("style","border: 10px solid #47e58e"):$(this).hasClass("photo-ko")&&$("#dialogforpopup").attr("style","border: 10px solid #e05353")},window.dolismq.question.closePreviewPhoto=function(o){$("#dialogforpopup").attr("style","border:")},window.dolismq.question.showPhoto=function(){var o=$(this).closest(".question-table").find(".linked-medias");o.hasClass("hidden")?(o.attr("style",""),o.removeClass("hidden")):(o.attr("style","display:none"),o.addClass("hidden"))},window.dolismq.question.selectAnswerPicto=function(o){var t=$(this).closest(".wpeo-dropdown");$(this).closest(".content").removeClass("active"),t.find(".dropdown-toggle span").hide(),t.find(".dropdown-toggle.button-picto").html($(this).closest(".wpeo-tooltip-event").html()),t.find(".input-hidden-picto").val($(this).data("id"))},window.dolismq.question.searchPicto=function(o){let t=$(this).val();$(this).closest(".wpeo-dropdown").find(".item.dropdown-item").each(function(){$(this).data("label").match(t)?$(this).show():$(this).hide()})},window.dolismq.sheet={},window.dolismq.sheet.init=function(){window.dolismq.sheet.event()},window.dolismq.sheet.event=function(){}; \ No newline at end of file diff --git a/js/modules/question.js b/js/modules/question.js index d6c9170a..6030f128 100644 --- a/js/modules/question.js +++ b/js/modules/question.js @@ -32,6 +32,7 @@ window.dolismq.question.event = function() { $( document ).on( 'click', '.ui-dialog-titlebar-close', window.dolismq.question.closePreviewPhoto ); $( document ).on( 'click', '#show_photo', window.dolismq.question.showPhoto ); $( document ).on( 'click', '.answer-picto .item, .wpeo-table .item', window.dolismq.question.selectAnswerPicto ); + $( document ).on( 'input', '#pictoSearch', window.dolismq.question.searchPicto ); }; /** @@ -85,7 +86,7 @@ window.dolismq.question.showPhoto = function() { }; /** - * Lors du clic sur un picto de réponse, remplace le contenu du toggle et met l'image du picto sélectionné. + * Lors de la recherche dans la liste des pictogrammes, filtre dynamiquement la liste des pictos affichés * * @since 1.0.0 * @version 1.0.0 @@ -100,3 +101,21 @@ window.dolismq.question.selectAnswerPicto = function( event ) { element.find('.dropdown-toggle.button-picto').html($(this).closest('.wpeo-tooltip-event').html()); element.find('.input-hidden-picto').val($(this).data('id')); }; + +/** + * Lors du clic sur un picto de réponse, remplace le contenu du toggle et met l'image du picto sélectionné. + * + * @since 1.0.0 + * @version 1.0.0 + * + * @param {MouseEvent} event [description] + * @return {void} + */ +window.dolismq.question.searchPicto = function( event ) { + let searchQuery = $(this).val() + let pictos = $(this).closest('.wpeo-dropdown').find('.item.dropdown-item') + + pictos.each(function( ) { + $( this ).data('label').match(searchQuery) ? $(this).show() : $(this).hide() + }); +}; diff --git a/lib/dolismq_answer.lib.php b/lib/dolismq_answer.lib.php index e5b8f096..d207fb8c 100644 --- a/lib/dolismq_answer.lib.php +++ b/lib/dolismq_answer.lib.php @@ -45,6 +45,7 @@ function answer_pictos_dropdown($selected = -1): string } $out .= ''; $out .= '