From f9f8a11b901e2c714b8bd419a02e8f6d08292473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=BB=B6=E4=B9=89?= Date: Mon, 10 Oct 2022 13:57:56 +0800 Subject: [PATCH] * Finish task #71903. --- module/productplan/control.php | 3 ++ module/productplan/js/view.js | 42 +++++++++++++++++++++++++++ module/productplan/view/view.html.php | 7 +++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/module/productplan/control.php b/module/productplan/control.php index 559c0d5c85..a7c42d0fbd 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -440,10 +440,12 @@ class productplan extends control if($plan->branch > 0) $this->view->branchStatus = $this->loadModel('branch')->getById($plan->branch, $plan->product, 'status'); + $storyIdList = array(); $modulePairs = $this->loadModel('tree')->getOptionMenu($plan->product, 'story', 0, 'all'); foreach($planStories as $story) { if(!isset($modulePairs[$story->module])) $modulePairs += $this->tree->getModulesName($story->module); + $storyIdList[] = $story->id; } $this->loadModel('datatable'); @@ -466,6 +468,7 @@ class productplan extends control $this->view->storyPager = $storyPager; $this->view->bugPager = $bugPager; $this->view->canBeChanged = $canBeChanged; + $this->view->storyCases = $storyCases = $this->loadModel('testcase')->getStoryCaseCounts($storyIdList);; if($this->app->getViewType() == 'json') { diff --git a/module/productplan/js/view.js b/module/productplan/js/view.js index 012a26ee42..2e551d56a4 100644 --- a/module/productplan/js/view.js +++ b/module/productplan/js/view.js @@ -84,4 +84,46 @@ $(function() history.pushState({}, 0, createLink('productplan', 'view', "planID=" + planID + '&type=story&orderBy=' + order)); }); }); + + $('.table-story').table( + { + statisticCreator: function(table) + { + var $checkedRows = table.getTable().find(table.isDataTable ? '.datatable-row-left.checked' : 'tbody>tr.checked'); + var $originTable = table.isDataTable ? table.$.find('.datatable-origin') : null; + var checkedTotal = $checkedRows.length; + if(!checkedTotal) return; + + var checkedEstimate = 0; + var checkedCase = 0; + var rateCount = checkedTotal; + $checkedRows.each(function() + { + var $row = $(this); + if($originTable) + { + $row = $originTable.find('tbody>tr[data-id="' + $row.data('id') + '"]'); + } + var data = $row.data(); + checkedEstimate += data.estimate; + + if(data.cases > 0) + { + checkedCase += 1; + } + else if(data.children != undefined && data.children > 0) + { + rateCount -= 1; + } + }); + + var rate = '0%'; + if(rateCount) rate = Math.round(checkedCase / rateCount * 10000 / 100) + '' + '%'; + + if(checkedTotal == 0) return storySummary; + return checkedSummary.replace('%total%', checkedTotal) + .replace('%estimate%', checkedEstimate.toFixed(1)) + .replace('%rate%', rate); + } + }); }); diff --git a/module/productplan/view/view.html.php b/module/productplan/view/view.html.php index dfc20fdf79..44f4e5c692 100644 --- a/module/productplan/view/view.html.php +++ b/module/productplan/view/view.html.php @@ -20,6 +20,9 @@ pageID);?> recPerPage);?> recTotal);?> + +SRCommon);?> +SRCommon, $lang->product->checkedSummary));?>