Added button to revert part to a given timestamp.

This commit is contained in:
Jan Böhmer 2020-03-01 20:30:23 +01:00
parent 5a5d7b24be
commit 654c5bd59f
4 changed files with 74 additions and 15 deletions

View file

@ -48,22 +48,39 @@ class RevertLogColumn extends AbstractColumn
public function render($value, $context)
{
if ($context instanceof ElementDeletedLogEntry || $context instanceof CollectionElementDeleted) {
$revertable = true;
if (
$context instanceof CollectionElementDeleted
|| ($context instanceof ElementDeletedLogEntry && $context->hasOldDataInformations())
) {
$icon = 'fa-trash-restore';
$title = $this->translator->trans('log.undo.undelete');
} elseif ($context instanceof ElementEditedLogEntry || $context instanceof ElementCreatedLogEntry) {
} elseif (
$context instanceof ElementCreatedLogEntry
|| ($context instanceof ElementEditedLogEntry && $context->hasOldDataInformations())
) {
$icon = 'fa-undo';
$title = $this->translator->trans('log.undo.undo');
} else {
return '';
}
return sprintf(
'<button type="submit" class="btn btn-outline-secondary btn-sm" name="undo" value="%d"><i class="fas fa-fw %s" title="%s"></i></button>',
$tmp = '<div class="btn-group btn-group-sm">';
$tmp .= sprintf(
'<button type="submit" class="btn btn-outline-secondary" name="undo" value="%d"><i class="fas fa-fw %s" title="%s"></i></button>',
$context->getID(),
$icon,
$title
);
$tmp .= sprintf(
'<button type="submit" class="btn btn-outline-secondary" name="revert" value="%d"><i class="fas fa-fw fa-backward" title="%s"></i></button>',
$context->getID(),
$this->translator->trans('log.undo.revert')
);
$tmp .= '</div>';
return $tmp;
}
}