Made attachment datatable sortable by internal filename and external url

This commit is contained in:
Jan Böhmer 2025-02-22 17:41:41 +01:00
parent 29f92d9bd3
commit 48be9a8098
2 changed files with 5 additions and 6 deletions

View file

@ -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

View file

@ -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(
'<a href="%s" class="link-external">%s</a>',
'<a href="%s" class="link-external" title="%s" target="_blank" rel="noopener">%s</a>',
htmlspecialchars((string) $context->getExternalPath()),
htmlspecialchars($value)
htmlspecialchars((string) $context->getExternalPath()),
htmlspecialchars($value),
);
}