* finish task #2877.

This commit is contained in:
chenfeiCF
2017-01-13 13:22:28 +08:00
parent eb24478bd0
commit 2d60b14e21
6 changed files with 136 additions and 12 deletions
+45 -9
View File
@@ -1111,19 +1111,55 @@ class bugModel extends model
/**
* Get bugs of a project.
*
* @param int $projectID
* @param string $orderBy
* @param object $pager
* @param int $projectID
* @param int $build
* @param string $type
* @param int $param
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getProjectBugs($projectID, $orderBy = 'id_desc', $pager = null, $build = 0)
public function getProjectBugs($projectID, $build = 0, $type = '', $param = 0, $orderBy = 'id_desc', $pager = null)
{
$bugs = $this->dao->select('*')->from(TABLE_BUG)
->where('deleted')->eq(0)
->beginIF(empty($build))->andWhere('project')->eq($projectID)->fi()
->beginIF($build)->andWhere("CONCAT(',', openedBuild, ',') like '%,$build,%'")->fi()
->orderBy($orderBy)->page($pager)->fetchAll();
if($type == 'bySearch')
{
$queryID = (int)$param;
$products = $this->loadModel('project')->getProducts($projectID);
if($this->session->projectBugQuery == false) $this->session->set('projectBugQuery', ' 1 = 1');
if($queryID)
{
$query = $this->loadModel('search')->getQuery($queryID);
if($query)
{
$this->session->set('projectBugQuery', $query->sql);
$this->session->set('projectBugForm', $query->form);
}
}
$allProduct = "`product` = 'all'";
$bugQuery = $this->session->projectBugQuery;
if(strpos($this->session->projectBugQuery, $allProduct) !== false)
{
$bugQuery = str_replace($allProduct, '1', $this->session->projectBugQuery);
}
$bugs = $this->dao->select('*')->from(TABLE_BUG)
->where($bugQuery)
->andWhere('project')->eq((int)$projectID)
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
}
else
{
$bugs = $this->dao->select('*')->from(TABLE_BUG)
->where('deleted')->eq(0)
->beginIF(empty($build))->andWhere('project')->eq($projectID)->fi()
->beginIF($build)->andWhere("CONCAT(',', openedBuild, ',') like '%,$build,%'")->fi()
->orderBy($orderBy)->page($pager)->fetchAll();
}
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug');
+1 -1
View File
@@ -148,7 +148,7 @@ class build extends control
$this->view->title = "BUILD #$build->id $build->name - " . $projects[$build->project];
$this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $projects[$build->project]);
$this->view->position[] = $this->lang->build->view;
$this->view->generatedBugs = $this->bug->getProjectBugs($build->project, 'status_desc,id_desc', null, $build->id);
$this->view->generatedBugs = $this->bug->getProjectBugs($build->project, $build->id, '', 0, 'status_desc,id_desc', null);
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->view->build = $build;
$this->view->stories = $stories;
+10 -2
View File
@@ -608,13 +608,16 @@ class project extends control
*
* @param int $projectID
* @param string $orderBy
* @param int $build
* @param string $type
* @param int $param
* @param int $recTotal
* @param int $recPerPage
* @param int $pageID
* @access public
* @return void
*/
public function bug($projectID = 0, $orderBy = 'status,id_desc', $build = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function bug($projectID = 0, $orderBy = 'status,id_desc', $build = 0, $type = '', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
/* Load these two models. */
$this->loadModel('bug');
@@ -623,6 +626,7 @@ class project extends control
/* Save session. */
$this->session->set('bugList', $this->app->getURI(true));
$queryID = ($type == 'bySearch') ? (int)$param : 0;
$project = $this->commonAction($projectID);
$projectID = $project->id;
$products = $this->project->getProducts($project->id);
@@ -638,7 +642,7 @@ class project extends control
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
$sort = $this->loadModel('common')->appendOrder($orderBy);
$bugs = $this->bug->getProjectBugs($projectID, $sort, $pager, $build);
$bugs = $this->bug->getProjectBugs($projectID, $build, $type, $param, $sort, $pager);
$users = $this->user->getPairs('noletter');
/* team member pairs. */
@@ -649,6 +653,10 @@ class project extends control
$memberPairs[$key] = $member->realname;
}
/* Build the search form. */
$actionURL = $this->createLink('project', 'bug', "projectID=$projectID&orderBy=$orderBy&build=$build&type=bySearch&queryID=myQueryID");
$this->project->buildBugSearchForm($products, $queryID, $actionURL);
/* Assign. */
$this->view->title = $title;
$this->view->position = $position;
+1
View File
@@ -14,6 +14,7 @@ $(document).ready(function()
$option.toggleClass('hide', $option.text().toString().toLowerCase().indexOf(val) < 0 && $option.data('key').toString().toLowerCase().indexOf(val) < 0);
});
});
ajaxGetSearchForm();
fixedTfootAction('#projectBugForm');
fixedTheadOfList('#bugList');
});
+78
View File
@@ -1952,6 +1952,84 @@ class projectModel extends model
return $productBranchPairs;
}
/**
* Build bug search form.
*
* @param int $products
* @param int $queryID
* @param int $actionURL
* @access public
* @return void
*/
public function buildBugSearchForm($products, $queryID, $actionURL)
{
$modules = array();
$builds = array('' => '', 'trunk' => 'Trunk');
foreach($products as $product)
{
$productModules = $this->loadModel('tree')->getOptionMenu($product->id);
$productBuilds = $this->loadModel('build')->getProductBuildPairs($product->id, 0, $params = 'noempty|notrunk');
foreach($productModules as $moduleID => $moduleName)
{
$modules[$moduleID] = ((count($products) >= 2 and $moduleID) ? $product->name : '') . $moduleName;
}
foreach($productBuilds as $buildID => $buildName)
{
$builds[$buildID] = ((count($products) >= 2 and $buildID) ? $product->name . '/' : '') . $buildName;
}
}
$branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noempty');
$branchPairs = array();
$productType = 'normal';
$productNum = count($products);
$productPairs = array(0 => '');
foreach($products as $product)
{
$productPairs[$product->id] = $product->name;
if($product->type != 'normal')
{
$productType = $product->type;
if($product->branch)
{
$branchPairs[$product->branch] = (count($products) > 1 ? $product->name . '/' : '') . $branchGroups[$product->id][$product->branch];
}
else
{
$productBranches = isset($branchGroups[$product->id]) ? $branchGroups[$product->id] : array(0);
if(count($products) > 1)
{
foreach($productBranches as $branchID => $branchName) $productBranches[$branchID] = $product->name . '/' . $branchName;
}
$branchPairs += $productBranches;
}
}
}
$this->config->bug->search['module'] = 'projectBug';
$this->config->bug->search['actionURL'] = $actionURL;
$this->config->bug->search['queryID'] = $queryID;
unset($this->config->bug->search['fields']['project']);
$this->config->bug->search['params']['product']['values'] = $productPairs + array('all' => $this->lang->product->allProductsOfProject);
$this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts($products);
$this->config->bug->search['params']['module']['values'] = $modules;
$this->config->bug->search['params']['openedBuild']['values'] = $builds;
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values'];
if($productType == 'normal')
{
unset($this->config->bug->search['fields']['branch']);
unset($this->config->bug->search['params']['branch']);
}
else
{
$this->config->bug->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$productType]);
$this->config->bug->search['params']['branch']['values'] = array('' => '') + $branchPairs;
}
$this->config->bug->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $this->lang->bug->statusList);
$this->loadModel('search')->setSearchParams($this->config->bug->search);
}
/**
* Build task search form.
*
+1
View File
@@ -20,6 +20,7 @@
<?php common::printIcon('bug', 'export', "productID=$productID&orderBy=$orderBy", '', 'button', '', '', "export iframe");?>
<?php common::printIcon('bug', 'create', "productID=$productID&branch=$branchID&extra=projectID=$project->id");?>
</div>
<div id='querybox' class='show'></div>
</div>
<form method='post' id='projectBugForm'>
<table class='table table-condensed table-hover table-striped tablesorter table-fixed table-selectable' id='bugList'>