Fixed column ordering

Signed-off-by: Roland Dalmulder <contact@rolandd.com>
This commit is contained in:
Roland Dalmulder 2023-08-25 21:57:29 +02:00
parent d1419dc893
commit 321f60eaee
No known key found for this signature in database
GPG Key ID: 6D30CD38749A5B9E
3 changed files with 10 additions and 3 deletions

View File

@ -86,6 +86,8 @@
name="fullordering"
type="list"
onchange="this.form.submit();"
default="pulls.pull_id DESC"
validate="options"
>
<option value="pulls.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="pulls.title DESC">JGLOBAL_TITLE_DESC</option>

View File

@ -39,6 +39,7 @@ class PullsModel extends ListModel
* @since 2.0
*/
protected $context;
/**
* Array of fields the list can be sorted on
*
@ -75,7 +76,7 @@ class PullsModel extends ListModel
parent::__construct($config);
}
protected function populateState($ordering = 'pulls.pull_id', $direction = 'DESC')
protected function populateState($ordering = null, $direction = null)
{
parent::populateState(
$ordering,
@ -307,6 +308,7 @@ class PullsModel extends ListModel
$ordering = $this->getState()->get('list.ordering', 'pulls.pull_id');
$direction = $this->getState()->get('list.direction', 'DESC');
if (!empty($ordering)) {
$query->order(
$db->escape($ordering) . ' ' . $db->escape($direction)

View File

@ -20,6 +20,9 @@ use Joomla\CMS\Router\Route;
HTMLHelper::_('stylesheet', 'com_patchtester/octicons.css', ['version' => '3.5.0', 'relative' => true]);
HTMLHelper::_('script', 'com_patchtester/patchtester.js', ['version' => 'auto', 'relative' => true]);
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>
<form action="<?php echo Route::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
@ -43,10 +46,10 @@ HTMLHelper::_('script', 'com_patchtester/patchtester.js', ['version' => 'auto',
<thead>
<tr>
<th scope="col" style="width:5%" class="text-center">
<?php echo Text::_('COM_PATCHTESTER_PULL_ID'); ?>
<?php echo HTMLHelper::_('searchtools.sort', 'COM_PATCHTESTER_PULL_ID', 'pulls.pull_id', $listDirn, $listOrder); ?>
</th>
<th scope="col" style="min-width:100px">
<?php echo Text::_('JGLOBAL_TITLE'); ?>
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'pulls.title', $listDirn, $listOrder); ?>
</th>
<th scope="col" style="width:8%" class="d-none d-md-table-cell text-center">
<?php echo Text::_('COM_PATCHTESTER_BRANCH'); ?>