From 48be9a8098c94ffa517b899ae574608d06d4f321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 22 Feb 2025 17:41:41 +0100 Subject: [PATCH] Made attachment datatable sortable by internal filename and external url --- migrations/Version20250220215048.php | 4 ---- src/DataTables/AttachmentDataTable.php | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/migrations/Version20250220215048.php b/migrations/Version20250220215048.php index 82e132de..fd4fb9c2 100644 --- a/migrations/Version20250220215048.php +++ b/migrations/Version20250220215048.php @@ -6,11 +6,7 @@ namespace DoctrineMigrations; use App\Migration\AbstractMultiPlatformMigration; use Doctrine\DBAL\Schema\Schema; -use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20250220215048 extends AbstractMultiPlatformMigration { public function getDescription(): string diff --git a/src/DataTables/AttachmentDataTable.php b/src/DataTables/AttachmentDataTable.php index 7973bf8a..16e6a7a7 100644 --- a/src/DataTables/AttachmentDataTable.php +++ b/src/DataTables/AttachmentDataTable.php @@ -119,6 +119,7 @@ final class AttachmentDataTable implements DataTableTypeInterface $dataTable->add('internal_link', TextColumn::class, [ 'label' => 'attachment.table.internal_file', 'propertyPath' => 'filename', + 'orderField' => 'NATSORT(attachment.original_filename)', 'render' => function ($value, Attachment $context) { if ($this->attachmentHelper->isInternalFileExisting($context)) { return sprintf( @@ -135,12 +136,14 @@ final class AttachmentDataTable implements DataTableTypeInterface $dataTable->add('external_link', TextColumn::class, [ 'label' => 'attachment.table.external_link', 'propertyPath' => 'host', + 'orderField' => 'attachment.external_path', 'render' => function ($value, Attachment $context) { if ($context->hasExternal()) { return sprintf( - '%s', + '%s', htmlspecialchars((string) $context->getExternalPath()), - htmlspecialchars($value) + htmlspecialchars((string) $context->getExternalPath()), + htmlspecialchars($value), ); }