Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/dolismq.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion js/modules/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
};

/**
Expand Down Expand Up @@ -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
Expand All @@ -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()
});
};
73 changes: 46 additions & 27 deletions lib/dolismq_answer.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function answer_pictos_dropdown($selected = -1): string
}
$out .= '</div>';
$out .= '<ul class="dropdown-content wpeo-gridlayout grid-5 grid-gap-0">';
$out .= '<input class="picto-search" id="pictoSearch">';
if ( ! empty($pictosArray) ) {
foreach ($pictosArray as $picto) {
$out .= '<li class="item dropdown-item wpeo-tooltip-event" data-is-preset="" data-id="'. $picto['position'] .'" aria-label="'. $picto['name'].'">';
Expand All @@ -70,33 +71,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' => '<i class="fas fa-check"></i>',
'position' => 1
],
[
'name' => $langs->transnoentities('Ko'),
'picto_source' => '<i class="fas fa-times"></i>',
'position' => 2
],
[
'name' => $langs->transnoentities('ToFix'),
'picto_source' => '<i class="fas fa-tools"></i>',
'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[$pictoName] = [
'name' => $pictoName,
'picto_source' => '<i class="fas fa-'. $pictoName .'"></i>',
'position' => $position,
];

$position++;
}
}
//
// $pictosArray = [
// [
// 'name' => $langs->transnoentities('None'),
// 'picto_source' => $langs->transnoentities('None'),
// 'position' => 0,
// ],
// [
// 'name' => $langs->transnoentities('Ok'),
// 'picto_source' => '<i class="fas fa-check"></i>',
// 'position' => 1
// ],
// [
// 'name' => $langs->transnoentities('Ko'),
// 'picto_source' => '<i class="fas fa-times"></i>',
// 'position' => 2
// ],
// [
// 'name' => $langs->transnoentities('ToFix'),
// 'picto_source' => '<i class="fas fa-tools"></i>',
// 'position' => 3
// ],
// [
// 'name' => $langs->transnoentities('NonApplicable'),
// 'picto_source' => 'N/A',
// 'position' => 4
// ],
// ];
return $pictosArray;
}

Expand Down