Merge pull request #4936 from christianbeeznest/ofaj-21084

Reporting: Fix display of user messages BT#21084
pull/4937/head
christianbeeznest 1 year ago committed by GitHub
commit aa10c5f0e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      assets/css/app.scss
  2. 84
      public/main/inc/lib/display.lib.php
  3. 21
      public/main/inc/lib/message.lib.php

@ -210,6 +210,14 @@
margin-left: 20% !important; margin-left: 20% !important;
} }
.custom-message {
ol,
ul,
menu {
list-style: initial;
}
}
/* **************************************************** /* ****************************************************
CSS SKILL CSS SKILL
**************************************************** */ **************************************************** */

@ -2289,6 +2289,31 @@ class Display
return "$icon "; return "$icon ";
} }
public static function returnPrimeIcon(
$name,
$size = '',
$fixWidth = false,
$additionalClass = ''
) {
$className = "pi pi-$name";
if ($fixWidth) {
$className .= ' pi-fw';
}
if ($size) {
$className .= " pi-$size";
}
if (!empty($additionalClass)) {
$className .= " $additionalClass";
}
$icon = self::tag('i', null, ['class' => $className]);
return "$icon ";
}
/** /**
* @param string $title * @param string $title
* @param string $content * @param string $content
@ -2313,21 +2338,50 @@ class Display
$open = true, $open = true,
$fullClickable = false $fullClickable = false
) { ) {
$javascript = '';
if (!empty($idAccordion)) { if (!empty($idAccordion)) {
$headerClass = $fullClickable ? 'center-block ' : ''; $javascript = '
$headerClass .= $open ? '' : 'collapsed'; <script>
$contentClass = 'panel-collapse collapse '; document.addEventListener("DOMContentLoaded", function() {
$contentClass .= $open ? 'in' : ''; const buttons = document.querySelectorAll("#card_'.$idAccordion.' a");
$ariaExpanded = $open ? 'true' : 'false'; const menus = document.querySelectorAll("#collapse_'.$idAccordion.'");
buttons.forEach((button, index) => {
$html = <<<HTML button.addEventListener("click", function() {
<div class="v-card bg-white mx-2" id="$id"> menus.forEach((menu, menuIndex) => {
<div class="v-card-header text-h5 my-2"> if (index === menuIndex) {
$title menu.classList.toggle("active");
</div> } else {
<div class="v-card-text">$content</div> menu.classList.remove("active");
</div> }
HTML; });
});
});
});
</script>';
$html = '
<div class="mt-4 rounded-lg bg-gray-50 p-2">
<div class="px-4 bg-gray-100 border border-gray-50" id="card_'.$idAccordion.'">
<h5>
<a role="button"
class="cursor-pointer"
data-toggle="collapse"
data-target="#collapse_'.$idAccordion.'"
aria-expanded="'.(($open) ? 'true' : 'false').'"
aria-controls="collapse_'.$idAccordion.'"
>
'.$title.'
</a>
</h5>
</div>
<div
id="collapse_'.$idAccordion.'"
class="px-4 border border-gray-50 bg-white collapse custom-collapse '.(($open) ? 'show' : '').'"
>
<div id="collapse_contant_'.$idAccordion.'" class="card-body ">';
$html .= $content;
$html .= '</div></div></div>';
} else { } else {
if (!empty($id)) { if (!empty($id)) {
$params['id'] = $id; $params['id'] = $id;
@ -2341,7 +2395,7 @@ HTML;
$html = self::div($html, $params); $html = self::div($html, $params);
} }
return $html; return $javascript.$html;
} }
/** /**

@ -37,23 +37,22 @@ class MessageManager
); );
$sender = $message->getSender(); $sender = $message->getSender();
$deleteButton = ''; $deleteLink = '';
if (!empty($url) && $currentUserId === $sender->getId()) { if (!empty($url) && $currentUserId === $sender->getId()) {
$deleteButton = Display::url( $deleteLink = '<a title="'.addslashes(
get_lang('Delete'), get_lang('DeleteMessage')
$url.'&action=delete_message&message_id='.$messageId, ).'" href="'.$url.'&action=delete_message&message_id='.$messageId.'" onclick="javascript:if(!confirm('."'".addslashes(
['class' => 'btn btn--danger'] api_htmlentities(get_lang('ConfirmDeleteMessage'))
); )."'".')) return false;" >&nbsp;&nbsp;&nbsp;&nbsp;'.
Display::returnPrimeIcon('trash', 'lg').'</a>';
} }
$content = $message->getContent().'<br />'.$date.'<br />'. $content = '<div class="custom-message">' . $message->getContent().'<br />'.$date.'<br />'.
get_lang('Author').': '.$sender->getUsername(). get_lang('Author').': '.$sender->getUsername().
'<br />'. '<br /></div>';
$deleteButton
;
$html .= Display::panelCollapse( $html .= Display::panelCollapse(
$localTime.' '.UserManager::formatUserFullName($sender).' '.$message->getTitle(), $localTime.' '.UserManager::formatUserFullName($sender).' '.$message->getTitle().$deleteLink,
$content, $content,
$tag, $tag,
null, null,

Loading…
Cancel
Save