mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-02-14 01:30:21 +00:00
Ability to filter on branches (Ref #191)
This commit is contained in:
parent
c2f233d572
commit
b4df300946
@ -109,6 +109,7 @@ class DisplayController extends AbstractController
|
||||
// Load the filter state.
|
||||
$state->set('filter.search', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', ''));
|
||||
$state->set('filter.applied', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.applied', 'filter_applied', ''));
|
||||
$state->set('filter.branch', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.branch', 'filter_branch', ''));
|
||||
$state->set('filter.rtc', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.rtc', 'filter_rtc', ''));
|
||||
|
||||
// Pre-fill the limits.
|
||||
|
@ -52,6 +52,28 @@ class PullsModel extends \JModelDatabase
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of branches.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
public function getBranches()
|
||||
{
|
||||
// Create a new query object.
|
||||
$db = $this->getDb();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select distinct branches excluding empty values
|
||||
$query->select('DISTINCT(branch) AS text')
|
||||
->from('#__patchtester_pulls')
|
||||
->where($db->quoteName('branch') . ' != ' . $db->quote(''))
|
||||
->order('branch ASC');
|
||||
|
||||
return $db->setQuery($query)->loadAssocList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of data items.
|
||||
*
|
||||
@ -127,6 +149,14 @@ class PullsModel extends \JModelDatabase
|
||||
$query->where($db->quoteName('applied') . $value);
|
||||
}
|
||||
|
||||
// Filter for branch
|
||||
$branch = $this->getState()->get('filter.branch');
|
||||
|
||||
if (!empty($branch))
|
||||
{
|
||||
$query->where($db->quoteName('branch') . ' = ' . $db->quote($branch));
|
||||
}
|
||||
|
||||
// Filter for RTC patches
|
||||
$applied = $this->getState()->get('filter.rtc');
|
||||
|
||||
|
@ -20,6 +20,14 @@ use PatchTester\View\DefaultHtmlView;
|
||||
*/
|
||||
class PullsHtmlView extends DefaultHtmlView
|
||||
{
|
||||
/**
|
||||
* Array containing the list of branches
|
||||
*
|
||||
* @var array
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
protected $branches = array();
|
||||
|
||||
/**
|
||||
* Array containing environment errors
|
||||
*
|
||||
@ -86,6 +94,7 @@ class PullsHtmlView extends DefaultHtmlView
|
||||
$this->items = $this->model->getItems();
|
||||
$this->pagination = $this->model->getPagination();
|
||||
$this->trackerAlias = TrackerHelper::getTrackerAlias($this->state->get('github_user'), $this->state->get('github_repo'));
|
||||
$this->branches = $this->model->getBranches();
|
||||
}
|
||||
|
||||
// Change the layout if there are environment errors
|
||||
|
@ -17,8 +17,9 @@
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$filterApplied = $this->escape($this->state->get('filter.applied'));
|
||||
$filterBranch = $this->escape($this->state->get('filter.branch'));
|
||||
$filterRtc = $this->escape($this->state->get('filter.rtc'));
|
||||
$colSpan = $this->trackerAlias !== false ? 7 : 6;
|
||||
$colSpan = $this->trackerAlias !== false ? 8 : 7;
|
||||
?>
|
||||
<form action="<?php echo \JRoute::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm" data-order="<?php echo $listOrder; ?>">
|
||||
<div id="j-main-container">
|
||||
@ -39,8 +40,8 @@ $colSpan = $this->trackerAlias !== false ? 7 : 6;
|
||||
<label for="directionTable" class="element-invisible"><?php echo \JText::_('JFIELD_ORDERING_DESC'); ?></label>
|
||||
<select name="directionTable" id="directionTable" class="input-medium" onchange="PatchTester.orderTable()">
|
||||
<option value=""><?php echo \JText::_('JFIELD_ORDERING_DESC');?></option>
|
||||
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo \JText::_('JGLOBAL_ORDER_ASCENDING'); ?></option>
|
||||
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo \JText::_('JGLOBAL_ORDER_DESCENDING'); ?></option>
|
||||
<option value="asc"<?php if ($listDirn == 'asc') echo ' selected="selected"'; ?>><?php echo \JText::_('JGLOBAL_ORDER_ASCENDING'); ?></option>
|
||||
<option value="desc"<?php if ($listDirn == 'desc') echo ' selected="selected"'; ?>><?php echo \JText::_('JGLOBAL_ORDER_DESCENDING'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="btn-group pull-right">
|
||||
@ -66,6 +67,13 @@ $colSpan = $this->trackerAlias !== false ? 7 : 6;
|
||||
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="btn-group pull-right">
|
||||
<label for="filter_branch" class="element-invisible"><?php echo \JText::_('JSEARCH_TOOLS_DESC'); ?></label>
|
||||
<select name="filter_branch" class="input-medium" onchange="this.form.submit();">
|
||||
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></option>
|
||||
<?php echo \JHtml::_('select.options', $this->branches, 'text', 'text', $filterBranch, false);?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (empty($this->items)) : ?>
|
||||
|
@ -64,6 +64,7 @@ COM_PATCHTESTER_FIELDSET_AUTHENTICATION_LABEL="GitHub Authentication"
|
||||
COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S="The file marked for deletion does not exist: %s"
|
||||
COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S="The file marked for modification does not exist: %s"
|
||||
COM_PATCHTESTER_FILTER_APPLIED_PATCHES="Filter Applied Patches"
|
||||
COM_PATCHTESTER_FILTER_BRANCH="Filter Target Branch"
|
||||
COM_PATCHTESTER_FILTER_RTC_PATCHES="Filter RTC Patches"
|
||||
COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION="Search the list by title or prefix with 'id:' to search by Pull ID."
|
||||
COM_PATCHTESTER_GITHUB="GitHub"
|
||||
|
@ -16,8 +16,9 @@
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction', 'desc'));
|
||||
$filterApplied = $this->escape($this->state->get('filter.applied'));
|
||||
$filterBranch = $this->escape($this->state->get('filter.branch'));
|
||||
$filterRtc = $this->escape($this->state->get('filter.rtc'));
|
||||
$colSpan = $this->trackerAlias !== false ? 7 : 6;
|
||||
$colSpan = $this->trackerAlias !== false ? 8 : 7;
|
||||
?>
|
||||
<form action="<?php echo \JRoute::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm" data-order="<?php echo $listOrder; ?>">
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
@ -84,6 +85,13 @@ $colSpan = $this->trackerAlias !== false ? 7 : 6;
|
||||
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="js-stools-field-filter">
|
||||
<label for="filter_branch" class="element-invisible"><?php echo \JText::_('JSEARCH_TOOLS_DESC'); ?></label>
|
||||
<select name="filter_branch" class="custom-select" onchange="this.form.submit();">
|
||||
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></option>
|
||||
<?php echo \JHtml::_('select.options', $this->branches, 'text', 'text', $filterBranch, false);?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -16,8 +16,9 @@
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$filterApplied = $this->escape($this->state->get('filter.applied'));
|
||||
$filterBranch = $this->escape($this->state->get('filter.branch'));
|
||||
$filterRtc = $this->escape($this->state->get('filter.rtc'));
|
||||
$colSpan = $this->trackerAlias !== false ? 7 : 6;
|
||||
$colSpan = $this->trackerAlias !== false ? 8 : 7;
|
||||
|
||||
\JFactory::getDocument()->addStyleDeclaration(
|
||||
'
|
||||
@ -58,6 +59,11 @@ echo \JHtml::_(
|
||||
<option value="yes"<?php if ($filterRtc == 'yes') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_RTC'); ?></option>
|
||||
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
|
||||
</select>
|
||||
<label class="selectlabel" for="filter_branch"><?php echo JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></label>
|
||||
<select name="filter_branch" id="filter_branch">
|
||||
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></option>
|
||||
<?php echo \JHtml::_('select.options', $this->branches, 'text', 'text', $filterBranch, false);?>
|
||||
</select>
|
||||
<button type="submit" id="filter-go"><?php echo \JText::_('JSUBMIT'); ?></button>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
Loading…
x
Reference in New Issue
Block a user