mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-25 11:18:51 +02:00
Improved the rendering of a part instock change log entry
This commit is contained in:
parent
4c94d9c150
commit
5d6b7a9470
3 changed files with 72 additions and 1 deletions
|
@ -37,6 +37,7 @@ use App\Entity\LogSystem\CollectionElementDeleted;
|
|||
use App\Entity\LogSystem\ElementCreatedLogEntry;
|
||||
use App\Entity\LogSystem\ElementDeletedLogEntry;
|
||||
use App\Entity\LogSystem\ElementEditedLogEntry;
|
||||
use App\Entity\LogSystem\PartStockChangedLogEntry;
|
||||
use App\Entity\UserSystem\Group;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Exceptions\EntityNotSupportedException;
|
||||
|
@ -190,7 +191,16 @@ class LogDataTable implements DataTableTypeInterface
|
|||
'label' => $this->translator->trans('log.type'),
|
||||
'propertyPath' => 'type',
|
||||
'render' => function (string $value, AbstractLogEntry $context) {
|
||||
return $this->translator->trans('log.type.'.$value);
|
||||
$text = $this->translator->trans('log.type.'.$value);
|
||||
|
||||
if ($context instanceof PartStockChangedLogEntry) {
|
||||
$text .= sprintf(
|
||||
' (%s)',
|
||||
$this->translator->trans('log.part_stock_changed.' . $context->getInstockChangeType())
|
||||
);
|
||||
}
|
||||
|
||||
return $text;
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
|
@ -32,10 +32,12 @@ use App\Entity\LogSystem\ElementDeletedLogEntry;
|
|||
use App\Entity\LogSystem\ElementEditedLogEntry;
|
||||
use App\Entity\LogSystem\ExceptionLogEntry;
|
||||
use App\Entity\LogSystem\LegacyInstockChangedLogEntry;
|
||||
use App\Entity\LogSystem\PartStockChangedLogEntry;
|
||||
use App\Entity\LogSystem\SecurityEventLogEntry;
|
||||
use App\Entity\LogSystem\UserLoginLogEntry;
|
||||
use App\Entity\LogSystem\UserLogoutLogEntry;
|
||||
use App\Entity\LogSystem\UserNotAllowedLogEntry;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Services\ElementTypeNameGenerator;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
|
@ -179,6 +181,23 @@ class LogEntryExtraFormatter
|
|||
$array[] = htmlspecialchars($context->getMessage());
|
||||
}
|
||||
|
||||
if ($context instanceof PartStockChangedLogEntry) {
|
||||
$array['log.part_stock_changed.change'] = sprintf("%s %s %s (%s)",
|
||||
$context->getOldStock(),
|
||||
'<i class="fa-solid fa-right-long"></i>',
|
||||
$context->getNewStock(),
|
||||
($context->getNewStock() > $context->getOldStock() ? '+' : '-'). $context->getChangeAmount(),
|
||||
);
|
||||
if (!empty($context->getComment())) {
|
||||
$array['log.part_stock_changed.comment'] = htmlspecialchars($context->getComment());
|
||||
}
|
||||
if ($context->getInstockChangeType() === PartStockChangedLogEntry::TYPE_MOVE) {
|
||||
$array['log.part_stock_changed.move_target'] =
|
||||
$this->elementTypeNameGenerator->getLocalizedTypeLabel(PartLot::class)
|
||||
.' ' . $context->getMoveToTargetID();
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10223,5 +10223,47 @@ Element 3</target>
|
|||
<target>The permission schema of your user were upgraded to the latest version.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="OohNh_M" name="log.type.part_stock_changed">
|
||||
<segment>
|
||||
<source>log.type.part_stock_changed</source>
|
||||
<target>Part Stock changed</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="ZIcw_8V" name="log.part_stock_changed.withdraw">
|
||||
<segment>
|
||||
<source>log.part_stock_changed.withdraw</source>
|
||||
<target>Stock withdrawn</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="jIm.ZAZ" name="log.part_stock_changed.add">
|
||||
<segment>
|
||||
<source>log.part_stock_changed.add</source>
|
||||
<target>Stock added</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="Q8itu0n" name="log.part_stock_changed.move">
|
||||
<segment>
|
||||
<source>log.part_stock_changed.move</source>
|
||||
<target>Stock moved</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="Z_uM8dG" name="log.part_stock_changed.comment">
|
||||
<segment>
|
||||
<source>log.part_stock_changed.comment</source>
|
||||
<target>Comment</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="vEWZ248" name="log.part_stock_changed.change">
|
||||
<segment>
|
||||
<source>log.part_stock_changed.change</source>
|
||||
<target>Change</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="8kmtQLq" name="log.part_stock_changed.move_target">
|
||||
<segment>
|
||||
<source>log.part_stock_changed.move_target</source>
|
||||
<target>Move target</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue