Reduce style variety for comments

refs #5543
This commit is contained in:
Eric Lippmann 2015-10-27 16:05:43 +01:00
parent f951e29269
commit ec9e6152cf
5 changed files with 80 additions and 64 deletions

View File

@ -1,4 +1,4 @@
<span class="comment-header"> <div class="comment-header">
<?php if ($comment->objecttype === 'service'): ?> <?php if ($comment->objecttype === 'service'): ?>
<?= $this->icon('service', $this->translate('Service')) ?> <?= $this->qlink( <?= $this->icon('service', $this->translate('Service')) ?> <?= $this->qlink(
$comment->host_display_name . ': ' . $comment->service_display_name, $comment->host_display_name . ': ' . $comment->service_display_name,
@ -28,27 +28,31 @@
) )
) ?> ) ?>
<?php endif ?> <?php endif ?>
<span class="comment-meta">
<?= $this->translate('by') ?> <?= $this->translate('by') ?>
<?= $this->escape($comment->author) ?> <?= $this->escape($comment->author) ?>
<?= $this->timeAgo($comment->timestamp) ?> <?= $this->timeAgo($comment->timestamp) ?>
<span class="pull-right" data-base-target="_self"> <span class="meta-icons" data-base-target="_self">
<?= $comment->persistent ? $this->icon('attach', 'This comment is persistent.') : '' ?> <?= $comment->persistent ? $this->icon('attach', 'This comment is persistent.') : '' ?>
<?= $comment->expiration ? $this->icon('clock', sprintf( <?= $comment->expiration ? $this->icon('clock', sprintf(
$this->translate('This comment expires %s.'), $this->translate('This comment expires %s.'),
$this->timeUntil($comment->expiration) $this->timeUntil($comment->expiration)
)) : '' ?> )) : '' ?>
<?php if (isset($delCommentForm)) { <?php if (isset($delCommentForm)) {
$delCommentForm = clone $delCommentForm; $deleteButton = clone $delCommentForm;
$delCommentForm->populate( /** @var \Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm $deleteButton */
$deleteButton->setAttrib('class', $deleteButton->getAttrib('class') . ' remove-comment');
$deleteButton->populate(
array( array(
'comment_id' => $comment->id, 'comment_id' => $comment->id,
'comment_is_service' => isset($comment->service_description) 'comment_is_service' => isset($comment->service_description)
) )
); );
echo $delCommentForm; echo $deleteButton;
} ?> } ?>
</span> </span>
</span> </span>
</div>
<p class="comment-text"> <p class="comment-text">
<?= $this->escape($comment->comment) ?> <?= $this->escape($comment->comment) ?>
</p> </p>

View File

@ -1,6 +1,6 @@
<table> <table>
<tr> <tr>
<td class="comment-col"> <td class="icon-col">
<?= $this->render('partials/comment/comment-description.phtml') ?> <?= $this->render('partials/comment/comment-description.phtml') ?>
</td> </td>
<td> <td>

View File

@ -7,7 +7,7 @@
} }
?> ?>
<tr> <tr>
<td class="comment-col"> <td class="icon-col">
<?= $this->partial('partials/comment/comment-description.phtml', array('comment' => $comment)) ?> <?= $this->partial('partials/comment/comment-description.phtml', array('comment' => $comment)) ?>
</td> </td>
<td> <td>

View File

@ -36,37 +36,37 @@ if (empty($object->comments) && ! $addLink) {
<th><?php <th><?php
echo $this->translate('Comments'); echo $this->translate('Comments');
if (! empty($object->comments) && $addLink) { if (! empty($object->comments) && $addLink) {
echo '<br />' . $addLink; echo '<br>' . $addLink;
} }
?></th> ?></th>
<td data-base-target="_self"> <td data-base-target="_self">
<?php if (empty($object->comments)): <?php if (empty($object->comments)):
echo $addLink; echo $addLink;
else: ?> else: ?>
<dl class="feed-list"> <dl class="comment-list">
<?php foreach ($object->comments as $comment): <?php foreach ($object->comments as $comment): ?>
// Form is unset if the current user lacks the respective permission <dt class="comment-header">
if (isset($delCommentForm)) { <?= $this->escape($comment->author) ?>
<span class="comment-meta">
<?= $this->translate('commented') ?>
<?= $this->timeAgo($comment->timestamp) ?>
<?php if (isset($delCommentForm)): // Form is unset if the current user lacks the respective permission ?>
<span class="meta-icons">
<?php
$deleteButton = clone($delCommentForm); $deleteButton = clone($delCommentForm);
/** @var \Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm $deleteButton */ /** @var \Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm $deleteButton */
$deleteButton->setAttrib('class', $deleteButton->getAttrib('class') . ' pull-right'); $deleteButton->setAttrib('class', $deleteButton->getAttrib('class') . ' remove-comment');
$deleteButton->populate( $deleteButton->populate(
array( array(
'comment_id' => $comment->id, 'comment_id' => $comment->id,
'comment_is_service' => isset($comment->service_description) 'comment_is_service' => isset($comment->service_description)
) )
); );
} else { echo $deleteButton;
$deleteButton = '';
}
?> ?>
<dt class="feed-author clearfix"> </span>
<?= $this->escape($comment->author) ?>
<span class="text-small"><?= $this->translate('commented') ?></span>
<?= $this->timeAgo($comment->timestamp) ?>
<?php if ($deleteButton): ?>
<?= $deleteButton ?>
<?php endif ?> <?php endif ?>
</span>
</dt> </dt>
<dd class="comment-text"> <dd class="comment-text">
<?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($comment->comment)) ?> <?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($comment->comment)) ?>

View File

@ -16,11 +16,6 @@
} }
} }
.comment-text {
.text-small();
font-family: @font-family-fixed;
}
.content-centered { .content-centered {
.text-center(); .text-center();
margin: 0 auto; margin: 0 auto;
@ -91,23 +86,15 @@ a:hover > .icon-cancel {
} }
} }
dl.feed-list { .comment-list {
dd { > .comment-header {
// Reset default margin
margin: 0;
}
dt {
border-bottom: 1px solid @gray-lighter; border-bottom: 1px solid @gray-lighter;
margin-top: @vertical-padding; margin-top: @vertical-padding;
.icon-cancel {
display: none;
}
&:hover { &:hover {
background-color: @gray-lightest; background-color: @gray-lightest;
.icon-cancel {
> .comment-meta > .meta-icons > .remove-comment {
display: block; display: block;
} }
} }
@ -115,7 +102,32 @@ dl.feed-list {
&:first-child { &:first-child {
margin-top: 0; margin-top: 0;
} }
> .comment-meta > .meta-icons > .remove-comment {
display: none;
} }
}
}
.comment-header {
.clearfix();
}
.comment-meta {
color: @text-color-light;
font-size: @font-size-small;
vertical-align: middle;
> .meta-icons {
float: right;
margin-top: 0.2em;
}
}
.comment-text {
// Reset margin
margin: 0;
margin-top: @vertical-padding / 2;
} }
dl.name-value-list { dl.name-value-list {