From d29861df2fe199499a736571cd4d40ff957b599d Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Tue, 27 Aug 2019 19:44:51 -0500 Subject: [PATCH] Change Atum layouts for the newest incarnation of the template, adjust filtering logic a bit so it's closer to core search tools implementation --- .../Controller/DisplayController.php | 45 +++++---- .../PatchTester/Model/PullsModel.php | 12 +-- .../PatchTester/View/Pulls/PullsHtmlView.php | 33 ++++++- .../PatchTester/View/Pulls/tmpl/default.php | 24 ++--- .../View/Pulls/tmpl/default_items.php | 4 +- .../language/en-GB/en-GB.com_patchtester.ini | 7 +- .../html/com_patchtester/fetch/default.php | 26 ++++++ .../html/com_patchtester/pulls/default.php | 92 +++++++++---------- .../com_patchtester/pulls/default_items.php | 49 +++++----- media/com_patchtester/js/fetcher.js | 10 +- media/com_patchtester/js/patchtester.js | 18 ---- 11 files changed, 172 insertions(+), 148 deletions(-) create mode 100644 administrator/templates/atum/html/com_patchtester/fetch/default.php diff --git a/administrator/components/com_patchtester/PatchTester/Controller/DisplayController.php b/administrator/components/com_patchtester/PatchTester/Controller/DisplayController.php index acd4d88..a475482 100644 --- a/administrator/components/com_patchtester/PatchTester/Controller/DisplayController.php +++ b/administrator/components/com_patchtester/PatchTester/Controller/DisplayController.php @@ -19,20 +19,12 @@ use Joomla\Registry\Registry; class DisplayController extends AbstractController { /** - * Default ordering column + * Default ordering value * * @var string - * @since 2.0 + * @since __DEPLOY_VERSION__ */ - protected $defaultOrderColumn = 'a.pull_id'; - - /** - * Default sort direction - * - * @var string - * @since 2.0 - */ - protected $defaultDirection = 'DESC'; + protected $defaultFullOrdering = 'a.pull_id DESC'; /** * Execute the controller. @@ -117,27 +109,34 @@ class DisplayController extends AbstractController $limit = $this->getApplication()->getUserStateFromRequest('global.list.limit', 'limit', $this->getApplication()->get('list_limit', 20), 'uint'); $state->set('list.limit', $limit); - // Check if the ordering field is in the white list, otherwise use the incoming value. - $value = $this->getApplication()->getUserStateFromRequest($this->context . '.ordercol', 'filter_order', $this->defaultOrderColumn); + $fullOrdering = $this->getApplication()->getUserStateFromRequest($this->context . '.fullorder', 'list_fullordering', $this->defaultFullOrdering); - if (!in_array($value, $model->getSortFields())) + $orderingParts = explode(' ', $fullOrdering); + + if (count($orderingParts) !== 2) { - $value = $this->defaultOrderColumn; - $this->getApplication()->setUserState($this->context . '.ordercol', $value); + $fullOrdering = $this->defaultFullOrdering; + + $orderingParts = explode(' ', $fullOrdering); } - $state->set('list.ordering', $value); + $state->set('list.fullordering', $fullOrdering); - // Check if the ordering direction is valid, otherwise use the incoming value. - $value = $this->getApplication()->getUserStateFromRequest($this->context . '.orderdirn', 'filter_order_Dir', $this->defaultDirection); + // The 2nd part will be considered the direction + $direction = $orderingParts[array_key_last($orderingParts)]; - if (!in_array(strtoupper($value), array('ASC', 'DESC', ''))) + if (in_array(strtoupper($direction), array('ASC', 'DESC', ''))) { - $value = $this->defaultDirection; - $this->getApplication()->setUserState($this->context . '.orderdirn', $value); + $state->set('list.direction', $direction); } - $state->set('list.direction', $value); + // The 1st part will be the ordering + $ordering = $orderingParts[array_key_first($orderingParts)]; + + if (in_array($ordering, $model->getSortFields())) + { + $state->set('list.ordering', $ordering); + } $value = $this->getApplication()->getUserStateFromRequest($this->context . '.limitstart', 'limitstart', 0); $limitstart = ($limit != 0 ? (floor($value / $limit) * $limit) : 0); diff --git a/administrator/components/com_patchtester/PatchTester/Model/PullsModel.php b/administrator/components/com_patchtester/PatchTester/Model/PullsModel.php index 83e8ee0..22868cb 100644 --- a/administrator/components/com_patchtester/PatchTester/Model/PullsModel.php +++ b/administrator/components/com_patchtester/PatchTester/Model/PullsModel.php @@ -34,7 +34,7 @@ class PullsModel extends \JModelDatabase * @var array * @since 2.0 */ - protected $sortFields = array('a.pull_id', 'a.title', 'applied'); + protected $sortFields = array('a.pull_id', 'a.title'); /** * Instantiate the model. @@ -169,20 +169,14 @@ class PullsModel extends \JModelDatabase } // Handle the list ordering. - $ordering = $this->getState()->get('list.ordering'); - $direction = $this->getState()->get('list.direction'); + $ordering = $this->getState()->get('list.ordering', 'a.pull_id'); + $direction = $this->getState()->get('list.direction', 'DESC'); if (!empty($ordering)) { $query->order($db->escape($ordering) . ' ' . $db->escape($direction)); } - // If $ordering is by applied patches, then append sort on pull_id also - if ($ordering === 'applied') - { - $query->order('a.pull_id ' . $db->escape($direction)); - } - return $query; } diff --git a/administrator/components/com_patchtester/PatchTester/View/Pulls/PullsHtmlView.php b/administrator/components/com_patchtester/PatchTester/View/Pulls/PullsHtmlView.php index f2258fb..a61af07 100644 --- a/administrator/components/com_patchtester/PatchTester/View/Pulls/PullsHtmlView.php +++ b/administrator/components/com_patchtester/PatchTester/View/Pulls/PullsHtmlView.php @@ -156,19 +156,44 @@ class PullsHtmlView extends DefaultHtmlView \JToolbarHelper::preferences('com_patchtester'); } + /** + * Returns an array of values to be used for pagination limits + * + * @return array + * + * @since __DEPLOY_VERSION__ + */ + protected function getLimitOptions() + { + return array( + 5 => \JText::_('J5'), + 10 => \JText::_('J10'), + 15 => \JText::_('J15'), + 20 => \JText::_('J20'), + 25 => \JText::_('J25'), + 30 => \JText::_('J30'), + 50 => \JText::_('J50'), + 100 => \JText::_('J100'), + 200 => \JText::_('J200'), + 500 => \JText::_('J500'), + 0 => \JText::_('JALL'), + ); + } + /** * Returns an array of fields the table can be sorted by * - * @return array Array containing the field name to sort by as the key and display text as value + * @return array * * @since 2.0 */ protected function getSortFields() { return array( - 'a.title' => \JText::_('JGLOBAL_TITLE'), - 'a.pull_id' => \JText::_('COM_PATCHTESTER_PULL_ID'), - 'applied' => \JText::_('JSTATUS') + 'a.title ASC' => \JText::_('JGLOBAL_TITLE_ASC'), + 'a.title DESC' => \JText::_('JGLOBAL_TITLE_DESC'), + 'a.pull_id ASC' => \JText::_('COM_PATCHTESTER_PULL_ID_ASC'), + 'a.pull_id DESC' => \JText::_('COM_PATCHTESTER_PULL_ID_DESC'), ); } } diff --git a/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default.php b/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default.php index 896c67b..43309d6 100644 --- a/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default.php +++ b/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default.php @@ -11,15 +11,13 @@ \JHtml::_('behavior.core'); \JHtml::_('bootstrap.tooltip'); \JHtml::_('formbehavior.chosen', 'select'); -\JHtml::_('stylesheet', 'com_patchtester/octicons.css', array('version' => 'auto', 'relative' => true)); +\JHtml::_('stylesheet', 'com_patchtester/octicons.css', array('version' => '3.5.0', 'relative' => true)); \JHtml::_('script', 'com_patchtester/patchtester.js', array('version' => 'auto', 'relative' => true)); -$listOrder = $this->escape($this->state->get('list.ordering')); -$listDirn = $this->escape($this->state->get('list.direction')); +$listOrder = $this->escape($this->state->get('list.fullordering', 'a.pull_id 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 ? 8 : 7; ?>
@@ -36,17 +34,9 @@ $colSpan = $this->trackerAlias !== false ? 8 : 7; pagination->getLimitBox(); ?>
-
- - -
- - getSortFields(), 'value', 'text', $listOrder);?> @@ -90,10 +80,10 @@ $colSpan = $this->trackerAlias !== false ? 8 : 7; - + - + @@ -123,8 +113,6 @@ $colSpan = $this->trackerAlias !== false ? 8 : 7; - -
diff --git a/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php b/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php index 7bd4e4c..3dbdca5 100644 --- a/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php +++ b/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php @@ -27,10 +27,10 @@ foreach ($this->items as $i => $item) : - + escape($item->branch); ?> - + is_rtc) : ?> diff --git a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini index 4ec0eaf..609779c 100644 --- a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini +++ b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini @@ -71,12 +71,15 @@ COM_PATCHTESTER_GITHUB="GitHub" COM_PATCHTESTER_HEADING_FETCH_DATA="Fetching GitHub Data" COM_PATCHTESTER_JISSUE="J! Issue" COM_PATCHTESTER_JISSUES="Issue Tracker" -COM_PATCHTESTER_PULL_ID="Pull ID" COM_PATCHTESTER_NO_CREDENTIALS="You have not entered your user credentials in the Options. This will limit you to only 60 requests to the GitHub API per hour. Adding your credentials will allow 5,000 requests per hour." COM_PATCHTESTER_NO_FILES_TO_PATCH="There are no files to patch from this pull request. This may mean that the files in the pull request are not present in your installation." COM_PATCHTESTER_NO_ITEMS="No data has been retrieved from GitHub, please click the 'Fetch Data' button in the toolbar to retrieve the open pull requests." COM_PATCHTESTER_NOT_APPLIED="Not Applied" COM_PATCHTESTER_NOT_RTC="Not RTC" +COM_PATCHTESTER_PULL_ID="Pull ID" +COM_PATCHTESTER_PULL_ID_ASC="Pull ID ascending" +COM_PATCHTESTER_PULL_ID_DESC="Pull ID descending" +COM_PATCHTESTER_PULLS_TABLE_CAPTION="Table of Pull Requests" COM_PATCHTESTER_READY_TO_COMMIT="Ready to Commit" COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the repository is missing" COM_PATCHTESTER_REQUIREMENT_HTTPS="HTTPS wrappers must be enabled" @@ -91,3 +94,5 @@ COM_PATCHTESTER_RTC="RTC" COM_PATCHTESTER_TEST_THIS_PATCH="Test This Patch" COM_PATCHTESTER_TOOLBAR_FETCH_DATA="Fetch Data" COM_PATCHTESTER_TOOLBAR_RESET="Reset" +COM_PATCHTESTER_VIEW_ON_GITHUB="View on GitHub" +COM_PATCHTESTER_VIEW_ON_JOOMLA_ISSUE_TRACKER="View on Joomla! Issue Tracker" diff --git a/administrator/templates/atum/html/com_patchtester/fetch/default.php b/administrator/templates/atum/html/com_patchtester/fetch/default.php new file mode 100644 index 0000000..c1ede9e --- /dev/null +++ b/administrator/templates/atum/html/com_patchtester/fetch/default.php @@ -0,0 +1,26 @@ + 'auto', 'relative' => true)); + +?> + +
+

+

+
+
+
+ +
diff --git a/administrator/templates/atum/html/com_patchtester/pulls/default.php b/administrator/templates/atum/html/com_patchtester/pulls/default.php index 6ff4a83..bd042b3 100644 --- a/administrator/templates/atum/html/com_patchtester/pulls/default.php +++ b/administrator/templates/atum/html/com_patchtester/pulls/default.php @@ -15,73 +15,75 @@ $searchToolsOptions = array( 'searchFieldSelector' => '#filter_search', 'selectorFieldName' => 'client_id', 'showSelector' => false, - 'orderFieldSelector' => '#sortTable', + 'orderFieldSelector' => '#list_fullordering', 'showNoResults' => false, 'noResultsText' => '', 'formSelector' => '#adminForm', ); \JHtml::_('behavior.core'); -\JHtml::_('bootstrap.tooltip'); \JHtml::_('searchtools.form', '#adminForm', $searchToolsOptions); -\JHtml::_('stylesheet', 'com_patchtester/octicons.css', array('version' => 'auto', 'relative' => true)); +\JHtml::_('stylesheet', 'com_patchtester/octicons.css', array('version' => '3.5.0', 'relative' => true)); \JHtml::_('script', 'com_patchtester/patchtester.js', array('version' => 'auto', 'relative' => true)); -$listOrder = $this->escape($this->state->get('list.ordering')); -$listDirn = $this->escape($this->state->get('list.direction', 'desc')); +$listOrder = $this->escape($this->state->get('list.fullordering', 'a.pull_id DESC')); +$listLimit = (int) ($this->state->get('list.limit')); $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 ? 8 : 7; ?> -
+