2
0
forked from Wavyzz/dolibarr

FIX : Ergonomic fail part02 (#29373)

* Fix ergo fail

* Fix read more

* Fix read more

* Update functions.lib.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
John BOTELLA
2024-04-22 14:32:07 +02:00
committed by GitHub
parent 6303bceecd
commit cbed0292d1
3 changed files with 56 additions and 1 deletions

View File

@@ -13351,7 +13351,23 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n
&& $actionstatic->code != 'AC_TICKET_MODIFY'
) {
$out .= '<div class="timeline-body" >';
$out .= $histo[$key]['message'];
$truncateLines = getDolGlobalInt('MAIN_TRUNCATE_TIMELINE_MESSAGE', 3);
$truncatedText = dolGetFirstLineOfText($histo[$key]['message'], $truncateLines);
if ($truncateLines > 0 && strlen($histo[$key]['message']) > strlen($truncatedText)) {
$out .= '<div class="readmore-block --closed" >';
$out .= ' <div class="readmore-block__excerpt" >';
$out .= $truncatedText ;
$out .= ' <a class="read-more-link" data-read-more-action="open" href="'.DOL_MAIN_URL_ROOT.'/comm/action/card.php?id='.$actionstatic->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'" >'.$langs->trans("ReadMore").' <span class="fa fa-chevron-right" aria-hidden="true"></span></a>';
$out .= ' </div>';
$out .= ' <div class="readmore-block__full-text" >';
$out .= $histo[$key]['message'];
$out .= ' <a class="read-less-link" data-read-more-action="close" href="#" ><span class="fa fa-chevron-up" aria-hidden="true"></span> '.$langs->trans("ReadLess").'</a>';
$out .= ' </div>';
$out .= '</div>';
} else {
$out .= $histo[$key]['message'];
}
$out .= '</div>';
}
@@ -13447,6 +13463,26 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n
$out .= "</ul>\n";
$out .= '<script>
jQuery(document).ready(function () {
$(document).on("click", "[data-read-more-action]", function(e){
let readMoreBloc = $(this).closest(".readmore-block");
if(readMoreBloc.length > 0){
e.preventDefault();
if($(this).attr("data-read-more-action") == "close"){
readMoreBloc.addClass("--closed").removeClass("--open");
$("html, body").animate({
scrollTop: readMoreBloc.offset().top - 200
}, 100);
}else{
readMoreBloc.addClass("--open").removeClass("--closed");
}
}
});
});
</script>';
if (empty($histo)) {
$out .= '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
}