mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 13:34:28 +02:00
Added button to revert part to a given timestamp.
This commit is contained in:
parent
5a5d7b24be
commit
654c5bd59f
4 changed files with 74 additions and 15 deletions
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue