mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-01-23 15:18:36 +00:00
Initial support for sort by applied status (Ref #21)
This commit is contained in:
parent
b9f440e0fc
commit
c1b0b499cc
@ -45,10 +45,7 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
if (empty($config['filter_fields']))
|
if (empty($config['filter_fields']))
|
||||||
{
|
{
|
||||||
$config['filter_fields'] = array(
|
$config['filter_fields'] = array(
|
||||||
'id', 'id',
|
'id', 'title', 'updated_at', 'user', 'applied'
|
||||||
'title', 'title',
|
|
||||||
'updated_at', 'updated_at',
|
|
||||||
'user', 'user'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,6 +229,7 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$pulls = $this->github->pulls->getList($this->getState('github_user'), $this->getState('github_repo'), 'open', $page);
|
$pulls = $this->github->pulls->getList($this->getState('github_user'), $this->getState('github_repo'), 'open', $page);
|
||||||
|
$pulls = $this->mergeAppliedData($pulls);
|
||||||
usort($pulls, array($this, 'sortItems'));
|
usort($pulls, array($this, 'sortItems'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,6 +302,9 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
case 'title' :
|
case 'title' :
|
||||||
return ($this->orderDir == 'asc') ? strcasecmp($a->title, $b->title) : strcasecmp($b->title, $a->title);
|
return ($this->orderDir == 'asc') ? strcasecmp($a->title, $b->title) : strcasecmp($b->title, $a->title);
|
||||||
|
|
||||||
|
case 'applied' :
|
||||||
|
return ($this->orderDir == 'asc') ? $b->applied > $a->applied : $b->applied < $a->applied;
|
||||||
|
|
||||||
case 'number' :
|
case 'number' :
|
||||||
default :
|
default :
|
||||||
return ($this->orderDir == 'asc') ? $b->number < $a->number : $b->number > $a->number;
|
return ($this->orderDir == 'asc') ? $b->number < $a->number : $b->number > $a->number;
|
||||||
@ -328,4 +329,34 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flags pull requests as having been applied in the current environment
|
||||||
|
*
|
||||||
|
* @param array $pulls Array of pull data
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
protected function mergeAppliedData($pulls)
|
||||||
|
{
|
||||||
|
// Fetch the applied patches
|
||||||
|
$appliedData = $this->getAppliedPatches();
|
||||||
|
|
||||||
|
// Loop through the pulls and add an applied flag
|
||||||
|
foreach ($pulls as $pull)
|
||||||
|
{
|
||||||
|
if (array_key_exists($pull->number, $appliedData))
|
||||||
|
{
|
||||||
|
$pull->applied = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pull->applied = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pulls;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<license>GNU General Public License version 2 or later</license>
|
<license>GNU General Public License version 2 or later</license>
|
||||||
<authorEmail>admin@joomla.org</authorEmail>
|
<authorEmail>admin@joomla.org</authorEmail>
|
||||||
<authorUrl>http://www.joomla.org</authorUrl>
|
<authorUrl>http://www.joomla.org</authorUrl>
|
||||||
<version>2.0.0.beta</version>
|
<version>2.0.0.beta2.dev</version>
|
||||||
<description>COM_PATCHTESTER_XML_DESCRIPTION</description>
|
<description>COM_PATCHTESTER_XML_DESCRIPTION</description>
|
||||||
<scriptfile>script.php</scriptfile>
|
<scriptfile>script.php</scriptfile>
|
||||||
<install>
|
<install>
|
||||||
|
@ -56,7 +56,7 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
|||||||
<?php echo JText::_('COM_PATCHTESTER_JOOMLACODE_ISSUE'); ?>
|
<?php echo JText::_('COM_PATCHTESTER_JOOMLACODE_ISSUE'); ?>
|
||||||
</th>
|
</th>
|
||||||
<th width="20%" class="nowrap center">
|
<th width="20%" class="nowrap center">
|
||||||
<?php echo JText::_('JSTATUS'); ?>
|
<?php echo JHtml::_('grid.sort', 'JSTATUS', 'applied', $listDirn, $listOrder); ?>
|
||||||
</th>
|
</th>
|
||||||
<th width="20%" class="nowrap center">
|
<th width="20%" class="nowrap center">
|
||||||
<?php echo JText::_('COM_PATCHTESTER_TEST_THIS_PATCH'); ?>
|
<?php echo JText::_('COM_PATCHTESTER_TEST_THIS_PATCH'); ?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user