Skip to content

Commit

Permalink
Fixed column ordering
Browse files Browse the repository at this point in the history
Signed-off-by: Roland Dalmulder <contact@rolandd.com>
  • Loading branch information
roland-d committed Aug 25, 2023
1 parent d1419dc commit 321f60e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PullsModel extends ListModel
* @since 2.0
*/
protected $context;

/**
* Array of fields the list can be sorted on
*
Expand Down Expand Up @@ -75,7 +76,7 @@ public function __construct($config = [])
parent::__construct($config);
}

protected function populateState($ordering = 'pulls.pull_id', $direction = 'DESC')
protected function populateState($ordering = null, $direction = null)
{
parent::populateState(
$ordering,
Expand Down Expand Up @@ -307,6 +308,7 @@ protected function getListQuery()

$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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

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">
Expand All @@ -43,10 +46,10 @@
<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'); ?>
Expand Down

0 comments on commit 321f60e

Please # to comment.