mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-23 18:28:49 +02:00
Color attachments with missing files yellow in attachments datatable
This commit is contained in:
parent
618a6e49dd
commit
6be863d356
1 changed files with 24 additions and 3 deletions
|
@ -26,6 +26,7 @@ use App\DataTables\Column\LocaleDateTimeColumn;
|
|||
use App\DataTables\Column\PrettyBoolColumn;
|
||||
use App\DataTables\Filters\AttachmentFilter;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
use App\Services\Attachments\AttachmentManager;
|
||||
use App\Services\Attachments\AttachmentURLGenerator;
|
||||
use App\Services\ElementTypeNameGenerator;
|
||||
|
@ -59,6 +60,20 @@ final class AttachmentDataTable implements DataTableTypeInterface
|
|||
|
||||
public function configure(DataTable $dataTable, array $options): void
|
||||
{
|
||||
$dataTable->add('$$rowClass', TextColumn::class, [
|
||||
'label' => '',
|
||||
'className' => 'no-colvis',
|
||||
'visible' => false,
|
||||
'render' => function ($value, Attachment $context) {
|
||||
//Mark attachments with missing files yellow
|
||||
if(!$this->attachmentHelper->isFileExisting($context)){
|
||||
return 'table-warning';
|
||||
}
|
||||
|
||||
return ''; //Default coloring otherwise
|
||||
},
|
||||
]);
|
||||
|
||||
$dataTable->add('picture', TextColumn::class, [
|
||||
'label' => '',
|
||||
'className' => 'no-colvis',
|
||||
|
@ -141,12 +156,18 @@ final class AttachmentDataTable implements DataTableTypeInterface
|
|||
$dataTable->add('filesize', TextColumn::class, [
|
||||
'label' => $this->translator->trans('attachment.table.filesize'),
|
||||
'render' => function ($value, Attachment $context) {
|
||||
if ($context->isExternal()) {
|
||||
return sprintf(
|
||||
'<span class="badge bg-primary">
|
||||
<i class="fas fa-globe fa-fw"></i>%s
|
||||
</span>',
|
||||
$this->translator->trans('attachment.external')
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->attachmentHelper->isFileExisting($context)) {
|
||||
return $this->attachmentHelper->getHumanFileSize($context);
|
||||
}
|
||||
if ($context->isExternal()) {
|
||||
return '<i>'.$this->translator->trans('attachment.external').'</i>';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'<span class="badge bg-warning">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue