feat(tickets): add tenant-aware server-side sorting

This commit is contained in:
2026-08-31 13:45:57 -03:00
parent 636e39e98e
commit d179a0f74e
5 changed files with 251 additions and 22 deletions

View File

@@ -8,7 +8,7 @@ class AdminAppTicketColumnService
{
private const FIESTA_FUTBOL_INFANTIL = 'fiesta_futbol_infantil';
/** @return list<array{key: string, label: string, type: string, sortable: bool, width: string, excel_width: int}> */
/** @return list<array{key: string, label: string, type: string, sortable: bool, sort_param: string, width: string, excel_width: int}> */
public function columns(Tenant $tenant): array
{
$keys = $tenant->codigo === self::FIESTA_FUTBOL_INFANTIL
@@ -38,7 +38,7 @@ class AdminAppTicketColumnService
return $columns;
}
/** @return list<array{key: string, label: string, type: string, sortable: bool, width: string}> */
/** @return list<array{key: string, label: string, type: string, sortable: bool, sort_param: string, width: string}> */
public function publicColumns(Tenant $tenant): array
{
return array_map(function (array $column): array {
@@ -48,7 +48,16 @@ class AdminAppTicketColumnService
}, $this->columns($tenant));
}
/** @return array<string, array{key: string, label: string, type: string, sortable: bool, width: string, excel_width: int}> */
/** @return list<string> */
public function sortableKeys(Tenant $tenant): array
{
return array_values(array_map(
fn (array $column): string => $column['sort_param'],
array_filter($this->columns($tenant), fn (array $column): bool => $column['sortable']),
));
}
/** @return array<string, array{key: string, label: string, type: string, sortable: bool, sort_param: string, width: string, excel_width: int}> */
private function definitions(): array
{
return [
@@ -65,7 +74,7 @@ class AdminAppTicketColumnService
];
}
/** @return array{key: string, label: string, type: string, sortable: bool, width: string, excel_width: int} */
/** @return array{key: string, label: string, type: string, sortable: bool, sort_param: string, width: string, excel_width: int} */
private function column(
string $key,
string $label,
@@ -78,6 +87,7 @@ class AdminAppTicketColumnService
'label' => $label,
'type' => $type,
'sortable' => true,
'sort_param' => $key,
'width' => $width,
'excel_width' => $excelWidth,
];