Merge pull request #7390 from atm-arnaud/FIX_task_comment_design
Fix task comment design
This commit is contained in:
commit
2f80618545
@ -601,29 +601,9 @@ class FormOther
|
|||||||
static function showColor($color, $textifnotdefined='')
|
static function showColor($color, $textifnotdefined='')
|
||||||
{
|
{
|
||||||
$textcolor='FFF';
|
$textcolor='FFF';
|
||||||
if ($color)
|
|
||||||
{
|
|
||||||
$tmp=explode(',', $color);
|
|
||||||
if (count($tmp) > 1) // This is a comma RGB ('255','255','255')
|
|
||||||
{
|
|
||||||
$r = $tmp[0];
|
|
||||||
$g = $tmp[1];
|
|
||||||
$b = $tmp[2];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$hexr=$color[0].$color[1];
|
|
||||||
$hexg=$color[2].$color[3];
|
|
||||||
$hexb=$color[4].$color[5];
|
|
||||||
$r = hexdec($hexr);
|
|
||||||
$g = hexdec($hexg);
|
|
||||||
$b = hexdec($hexb);
|
|
||||||
}
|
|
||||||
$bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
|
|
||||||
if ($bright > 0.6) $textcolor='000';
|
|
||||||
}
|
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
|
if(colorIsLight($color)) $textcolor='000';
|
||||||
|
|
||||||
$color = colorArrayToHex(colorStringToArray($color,array()),'');
|
$color = colorArrayToHex(colorStringToArray($color,array()),'');
|
||||||
|
|
||||||
if ($color) print '<input type="text" class="colorthumb" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value="'.$color.'">';
|
if ($color) print '<input type="text" class="colorthumb" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value="'.$color.'">';
|
||||||
|
|||||||
@ -2150,6 +2150,40 @@ function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88))
|
|||||||
return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3]));
|
return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the color is light
|
||||||
|
*
|
||||||
|
* @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255')
|
||||||
|
* @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light
|
||||||
|
*/
|
||||||
|
function colorIsLight($stringcolor)
|
||||||
|
{
|
||||||
|
$res = -1;
|
||||||
|
if (!empty($stringcolor))
|
||||||
|
{
|
||||||
|
$res = 0;
|
||||||
|
$tmp=explode(',', $stringcolor);
|
||||||
|
if (count($tmp) > 1) // This is a comma RGB ('255','255','255')
|
||||||
|
{
|
||||||
|
$r = $tmp[0];
|
||||||
|
$g = $tmp[1];
|
||||||
|
$b = $tmp[2];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$hexr=$stringcolor[0].$stringcolor[1];
|
||||||
|
$hexg=$stringcolor[2].$stringcolor[3];
|
||||||
|
$hexb=$stringcolor[4].$stringcolor[5];
|
||||||
|
$r = hexdec($hexr);
|
||||||
|
$g = hexdec($hexg);
|
||||||
|
$b = hexdec($hexb);
|
||||||
|
}
|
||||||
|
$bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
|
||||||
|
if ($bright > 0.6) $res = 1;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the Cartesian product algorithm to an array
|
* Applies the Cartesian product algorithm to an array
|
||||||
* Source: http://stackoverflow.com/a/15973172
|
* Source: http://stackoverflow.com/a/15973172
|
||||||
|
|||||||
@ -213,3 +213,5 @@ AllowCommentOnTask=Allow user comments on tasks
|
|||||||
TaskCommentLinks=Comments
|
TaskCommentLinks=Comments
|
||||||
TaskNbComments=Number of comments
|
TaskNbComments=Number of comments
|
||||||
TaskComment=Task's comments space
|
TaskComment=Task's comments space
|
||||||
|
CommentAdded=Comment added
|
||||||
|
CommentDeleted=Comment deleted
|
||||||
|
|||||||
@ -212,3 +212,5 @@ AllowCommentOnTask=Autoriser les commentaires entre utilisateurs sur les tâches
|
|||||||
TaskCommentLinks=Commentaires
|
TaskCommentLinks=Commentaires
|
||||||
TaskNbComments=Nombre de commentaires
|
TaskNbComments=Nombre de commentaires
|
||||||
TaskComment=Tâches espace commentaires
|
TaskComment=Tâches espace commentaires
|
||||||
|
CommentAdded=Commentaire ajouté avec succès
|
||||||
|
CommentDeleted=Commentaire supprimé avec succès
|
||||||
|
|||||||
@ -81,6 +81,7 @@ if ($action == 'addcomment')
|
|||||||
$object->entity = $conf->entity;
|
$object->entity = $conf->entity;
|
||||||
if ($object->create($user) > 0)
|
if ($object->create($user) > 0)
|
||||||
{
|
{
|
||||||
|
setEventMessages($langs->trans("CommentAdded"), null, 'mesgs');
|
||||||
header('Location: '.DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$id.($withproject?'&withproject=1':''));
|
header('Location: '.DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$id.($withproject?'&withproject=1':''));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -97,6 +98,7 @@ if ($action == 'deletecomment')
|
|||||||
{
|
{
|
||||||
if ($object->delete($user) > 0)
|
if ($object->delete($user) > 0)
|
||||||
{
|
{
|
||||||
|
setEventMessages($langs->trans("CommentDeleted"), null, 'mesgs');
|
||||||
header('Location: '.DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$id.($withproject?'&withproject=1':''));
|
header('Location: '.DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$id.($withproject?'&withproject=1':''));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -348,35 +350,53 @@ if ($id > 0 || ! empty($ref))
|
|||||||
// List of comments
|
// List of comments
|
||||||
if(!empty($task->comments)) {
|
if(!empty($task->comments)) {
|
||||||
// Default color for current user
|
// Default color for current user
|
||||||
$TColors = array($user->id => 'efefef');
|
$TColors = array($user->id => array('bgcolor'=>'efefef','color'=>'555'));
|
||||||
$first = true;
|
$first = true;
|
||||||
foreach($task->comments as $comment) {
|
foreach($task->comments as $comment) {
|
||||||
$fk_user = $comment->fk_user;
|
$fk_user = $comment->fk_user;
|
||||||
$userstatic->fetch($fk_user);
|
$userstatic->fetch($fk_user);
|
||||||
if(empty($TColors[$fk_user])) {
|
if(empty($TColors[$fk_user])) {
|
||||||
$TColors[$fk_user] = random_color(180,240);
|
$bgcolor = random_color(180,240);
|
||||||
|
if(!empty($userstatic->color)) {
|
||||||
|
$bgcolor = $userstatic->color;
|
||||||
|
}
|
||||||
|
$color = (colorIsLight($bgcolor))?'555':'fff';
|
||||||
|
$TColors[$fk_user] = array('bgcolor'=>$bgcolor,'color'=>$color);
|
||||||
}
|
}
|
||||||
print '<div class="width100p clearboth">';
|
print '<div class="width100p" style="color:#'.$TColors[$fk_user]['color'].'">';
|
||||||
if($comment->fk_user == $user->id) {
|
if($comment->fk_user == $user->id) {
|
||||||
print '<div class="width25p float"> </div>';
|
print '<div class="width25p float"> </div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<div class="width75p float comment" style="background-color:#'.$TColors[$fk_user].'">';
|
print '<div class="width75p float comment comment-table" style="background-color:#'.$TColors[$fk_user]['bgcolor'].'">';
|
||||||
print '<div class="comment-description">';
|
print '<div class="comment-info comment-cell">';
|
||||||
print $comment->description;
|
if (! empty($user->photo))
|
||||||
print '</div>';
|
{
|
||||||
print '<div class="comment-info">';
|
print Form::showphoto('userphoto', $userstatic, 80, 0, 0, '', 'small', 0, 1).'<br/>';
|
||||||
|
}
|
||||||
print $langs->trans('User').' : '.$userstatic->getNomUrl().'<br/>';
|
print $langs->trans('User').' : '.$userstatic->getNomUrl().'<br/>';
|
||||||
print $langs->trans('Date').' : '.dol_print_date($comment->datec,'dayhoursec');
|
print $langs->trans('Date').' : '.dol_print_date($comment->datec,'dayhoursec');
|
||||||
|
print '</div>'; // End comment-info
|
||||||
|
|
||||||
|
print '<div class="comment-cell comment-right">';
|
||||||
|
print '<div class="comment-table width100p">';
|
||||||
|
print '<div class="comment-description comment-cell">';
|
||||||
|
print $comment->description;
|
||||||
|
print '</div>'; // End comment-description
|
||||||
if(($first && $fk_user == $user->id) || $user->admin == 1) {
|
if(($first && $fk_user == $user->id) || $user->admin == 1) {
|
||||||
print '<br/> <a href="?action=deletecomment&id='.$id.'&withproject=1&idcomment='.$comment->id.'">'.$langs->trans('Delete').'</a>';
|
print '<a class="comment-delete comment-cell" href="'.DOL_URL_ROOT.'/projet/tasks/comment.php?action=deletecomment&id='.$id.'&withproject=1&idcomment='.$comment->id.'" title="'.$langs->trans('Delete').'">';
|
||||||
|
print img_picto('', 'delete.png');
|
||||||
|
print '</a>';
|
||||||
}
|
}
|
||||||
print '</div>';
|
print '</div>'; // End comment-table
|
||||||
print '</div>';
|
print '</div>'; // End comment-right
|
||||||
|
print '</div>'; // End comment
|
||||||
|
|
||||||
if($comment->fk_user != $user->id) {
|
if($comment->fk_user != $user->id) {
|
||||||
print '<div class="width25p float"> </div>';
|
print '<div class="width25p float"> </div>';
|
||||||
}
|
}
|
||||||
|
print '<div class="clearboth"></div>';
|
||||||
|
print '</div>'; // end 100p
|
||||||
|
|
||||||
$first = false;
|
$first = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3818,16 +3818,45 @@ pre#editfilecontentaceeditorid {
|
|||||||
#comment div {
|
#comment div {
|
||||||
box-sizing:border-box;
|
box-sizing:border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
#comment .comment {
|
#comment .comment {
|
||||||
border-radius:7px;
|
border-radius:7px;
|
||||||
padding:7px 10px;
|
|
||||||
margin-bottom:10px;
|
margin-bottom:10px;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
#comment .comment-table {
|
||||||
|
display:table;
|
||||||
|
height:100%;
|
||||||
|
}
|
||||||
|
#comment .comment-cell {
|
||||||
|
display:table-cell;
|
||||||
}
|
}
|
||||||
#comment .comment-info {
|
#comment .comment-info {
|
||||||
font-size:0.8em;
|
font-size:0.8em;
|
||||||
color:#555;
|
border-right:1px solid #dedede;
|
||||||
margin-top:5px;
|
margin-right:10px;
|
||||||
|
width:160px;
|
||||||
|
text-align:center;
|
||||||
|
background:rgba(255,255,255,0.5);
|
||||||
|
vertical-align:middle;
|
||||||
|
padding:10px 2px;
|
||||||
|
}
|
||||||
|
#comment .comment-info a {
|
||||||
|
color:inherit;
|
||||||
|
}
|
||||||
|
#comment .comment-right {
|
||||||
|
vertical-align:top;
|
||||||
|
}
|
||||||
|
#comment .comment-description {
|
||||||
|
padding:10px;
|
||||||
|
vertical-align:top;
|
||||||
|
}
|
||||||
|
#comment .comment-delete {
|
||||||
|
width: 100px;
|
||||||
|
text-align:center;
|
||||||
|
vertical-align:middle;
|
||||||
|
}
|
||||||
|
#comment .comment-delete:hover {
|
||||||
|
background:rgba(250,20,20,0.8);
|
||||||
}
|
}
|
||||||
#comment textarea {
|
#comment textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user