mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Show in log which fields were changed in a ElementEditedLogEntry.
This commit is contained in:
parent
181e0f72ed
commit
2bc6a2be3c
2 changed files with 31 additions and 1 deletions
|
@ -62,6 +62,24 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
|
|||
$this->setTargetElement($changed_element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this log contains infos about which fields has changed.
|
||||
* @return bool
|
||||
*/
|
||||
public function hasChangedFieldsInfo(): bool
|
||||
{
|
||||
return $this->hasOldDataInformations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the names of all fields that were changed during the change.
|
||||
* @return string[]
|
||||
*/
|
||||
public function getChangedFields(): array
|
||||
{
|
||||
return array_keys($this->getOldData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the old data for this entry.
|
||||
* @param array $old_data
|
||||
|
|
|
@ -144,10 +144,22 @@ class LogEntryExtraFormatter
|
|||
}
|
||||
|
||||
if ($context instanceof ElementEditedLogEntry) {
|
||||
$str = '';
|
||||
if ($context->hasComment()) {
|
||||
return htmlspecialchars($context->getComment());
|
||||
$str .= htmlspecialchars($context->getComment());
|
||||
}
|
||||
|
||||
if ($context->hasChangedFieldsInfo()) {
|
||||
if (!empty($str)) {
|
||||
$str .= '; ';
|
||||
}
|
||||
$str .= sprintf(
|
||||
"<i>%s:</i> %s",
|
||||
$this->translator->trans('log.element_edited.changed_fields'),
|
||||
htmlspecialchars(implode(', ', $context->getChangedFields()))
|
||||
);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
if ($context instanceof InstockChangedLogEntry) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue