From 4bf464142843c43f59e55b748bb35ecdb280894f Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Wed, 17 Feb 2021 20:38:27 +0100 Subject: [PATCH] Minor refactor of generateColumnHeaders function --- models/GenericTable.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/models/GenericTable.php b/models/GenericTable.php index c7d2ef2..b076df1 100644 --- a/models/GenericTable.php +++ b/models/GenericTable.php @@ -93,10 +93,13 @@ class GenericTable if (empty($column['header'])) continue; + $isSortable = $this->tableIsSortable && !empty($column['is_sortable']); + $sortDirection = $key == $this->sort_order && $this->sort_direction === 'up' ? 'down' : 'up'; + $header = [ 'class' => isset($column['class']) ? $column['class'] : '', 'colspan' => !empty($column['header_colspan']) ? $column['header_colspan'] : 1, - 'href' => !$this->tableIsSortable || empty($column['is_sortable']) ? '' : $this->getLink($this->start, $key, $key == $this->sort_order && $this->sort_direction == 'up' ? 'down' : 'up'), + 'href' => $isSortable ? $this->getLink($this->start, $key, $sortDirection) : null, 'label' => $column['header'], 'scope' => 'col', 'sort_mode' => $key == $this->sort_order ? $this->sort_direction : null,