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;
}
.custom-message {
ol,
ul,
menu {
list-style: initial;
}
}
/* ****************************************************
CSS SKILL
**************************************************** */

@ -2289,6 +2289,31 @@ class Display
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 $content
@ -2313,21 +2338,50 @@ class Display
$open = true,
$fullClickable = false
) {
$javascript = '';
if (!empty($idAccordion)) {
$headerClass = $fullClickable ? 'center-block ' : '';
$headerClass .= $open ? '' : 'collapsed';
$contentClass = 'panel-collapse collapse ';
$contentClass .= $open ? 'in' : '';
$ariaExpanded = $open ? 'true' : 'false';
$html = <<<HTML
<div class="v-card bg-white mx-2" id="$id">
<div class="v-card-header text-h5 my-2">
$title
</div>
<div class="v-card-text">$content</div>
</div>
HTML;
$javascript = '
<script>
document.addEventListener("DOMContentLoaded", function() {
const buttons = document.querySelectorAll("#card_'.$idAccordion.' a");
const menus = document.querySelectorAll("#collapse_'.$idAccordion.'");
buttons.forEach((button, index) => {
button.addEventListener("click", function() {
menus.forEach((menu, menuIndex) => {
if (index === menuIndex) {
menu.classList.toggle("active");
} else {
menu.classList.remove("active");
}
});
});
});
});
</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 {
if (!empty($id)) {
$params['id'] = $id;
@ -2341,7 +2395,7 @@ HTML;
$html = self::div($html, $params);
}
return $html;
return $javascript.$html;
}
/**

@ -37,23 +37,22 @@ class MessageManager
);
$sender = $message->getSender();
$deleteButton = '';
$deleteLink = '';
if (!empty($url) && $currentUserId === $sender->getId()) {
$deleteButton = Display::url(
get_lang('Delete'),
$url.'&action=delete_message&message_id='.$messageId,
['class' => 'btn btn--danger']
);
$deleteLink = '<a title="'.addslashes(
get_lang('DeleteMessage')
).'" href="'.$url.'&action=delete_message&message_id='.$messageId.'" onclick="javascript:if(!confirm('."'".addslashes(
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().
'<br />'.
$deleteButton
;
'<br /></div>';
$html .= Display::panelCollapse(
$localTime.' '.UserManager::formatUserFullName($sender).' '.$message->getTitle(),
$localTime.' '.UserManager::formatUserFullName($sender).' '.$message->getTitle().$deleteLink,
$content,
$tag,
null,

Loading…
Cancel
Save