From 5ef48598192a26bfdb3732fe9a96b0a9a22b643f Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sun, 4 Oct 2015 16:45:40 -0500 Subject: [PATCH] Issue 106: Allow size to be sorted on admin page --- indefero/src/IDF/Project.php | 10 ++++++++++ indefero/src/IDF/Views/Admin.php | 13 ++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/indefero/src/IDF/Project.php b/indefero/src/IDF/Project.php index 3e48e7a..7ec5c94 100644 --- a/indefero/src/IDF/Project.php +++ b/indefero/src/IDF/Project.php @@ -136,7 +136,17 @@ class IDF_Project extends Pluf_Model ); $activityTable = $this->_con->pfx.'idf_projectactivities'; $tagTable = $this->_con->pfx.'idf_project_idf_tag_assoc'; + $confTable = $this->_con->pfx.'idf_conf'; + $thisTable = $this->_con->pfx.'idf_projects'; $this->_a['views'] = array( + 'repo_size' => [ + 'join' => "INNER JOIN $confTable ON $thisTable.id = $confTable.project", + 'select' => $this->getSelect() . ', CAST(vdesc as UNSIGNED) as vdesc', + 'where' => 'vkey = "repository_size"', + 'props' => array( + 'vdesc' => 'vdesc', + ), + ], 'join_activities_and_tags' => array( 'join' => 'LEFT JOIN '.$activityTable.' ON current_activity='.$activityTable.'.id ' diff --git a/indefero/src/IDF/Views/Admin.php b/indefero/src/IDF/Views/Admin.php index 0041cc3..38b4cb4 100644 --- a/indefero/src/IDF/Views/Admin.php +++ b/indefero/src/IDF/Views/Admin.php @@ -81,13 +81,15 @@ class IDF_Views_Admin $pag->action = 'IDF_Views_Admin::projects'; $pag->edit_action = array('IDF_Views_Admin::projectUpdate', 'id'); $pag->sort_order = array('shortname', 'ASC'); + $pag->model_view = "repo_size"; $list_display = array( 'shortname' => __('Short Name'), 'name' => __('Name'), - array('id', 'IDF_Views_Admin_projectSize', __('Repository Size')), + 'vdesc' => ["vdesc", "IDF_Views_Admin_projectSize2", __('Repository Size')], + ); - $pag->configure($list_display, array(), - array('shortname' )); + $pag->configure($list_display, array('shortname', 'shortname'), + array('shortname', 'name', 'vdesc' )); $pag->extra_classes = array('', '', 'right'); $pag->items_per_page = 25; $pag->no_results_text = __('No projects were found.'); @@ -657,6 +659,11 @@ function IDF_Views_Admin_projectSize($field, $project) return Pluf_Utils::prettySize($size); } +function IDF_Views_Admin_projectSize2($field, $project) +{ + return Pluf_Utils::prettySize($project->vdesc); +} + /** * Get a forge size. *