Skip to content

Commit 48be9a8

Browse files
committed
Made attachment datatable sortable by internal filename and external url
1 parent 29f92d9 commit 48be9a8

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

migrations/Version20250220215048.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66

77
use App\Migration\AbstractMultiPlatformMigration;
88
use Doctrine\DBAL\Schema\Schema;
9-
use Doctrine\Migrations\AbstractMigration;
109

11-
/**
12-
* Auto-generated Migration: Please modify to your needs!
13-
*/
1410
final class Version20250220215048 extends AbstractMultiPlatformMigration
1511
{
1612
public function getDescription(): string

src/DataTables/AttachmentDataTable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public function configure(DataTable $dataTable, array $options): void
119119
$dataTable->add('internal_link', TextColumn::class, [
120120
'label' => 'attachment.table.internal_file',
121121
'propertyPath' => 'filename',
122+
'orderField' => 'NATSORT(attachment.original_filename)',
122123
'render' => function ($value, Attachment $context) {
123124
if ($this->attachmentHelper->isInternalFileExisting($context)) {
124125
return sprintf(
@@ -135,12 +136,14 @@ public function configure(DataTable $dataTable, array $options): void
135136
$dataTable->add('external_link', TextColumn::class, [
136137
'label' => 'attachment.table.external_link',
137138
'propertyPath' => 'host',
139+
'orderField' => 'attachment.external_path',
138140
'render' => function ($value, Attachment $context) {
139141
if ($context->hasExternal()) {
140142
return sprintf(
141-
'<a href="%s" class="link-external">%s</a>',
143+
'<a href="%s" class="link-external" title="%s" target="_blank" rel="noopener">%s</a>',
142144
htmlspecialchars((string) $context->getExternalPath()),
143-
htmlspecialchars($value)
145+
htmlspecialchars((string) $context->getExternalPath()),
146+
htmlspecialchars($value),
144147
);
145148
}
146149

0 commit comments

Comments
 (0)