* Adjust getProjectPairs to getExecutionPairsByProduct.

This commit is contained in:
leiyong
2020-11-24 10:40:18 +08:00
parent 3ec0aacb61
commit 8cead79b18
11 changed files with 65 additions and 53 deletions
+4 -4
View File
@@ -451,7 +451,7 @@ class bug extends control
$this->view->productName = $this->products[$productID];
$this->view->moduleOptionMenu = $moduleOptionMenu;
$this->view->stories = $stories;
$this->view->projects = $this->product->getProjectPairs($productID, $branch ? "0,$branch" : 0, $params = 'nodeleted');
$this->view->projects = $this->product->getExecutionPairsByProduct($productID, $branch ? "0,$branch" : 0, $params = 'nodeleted');
$this->view->builds = $builds;
$this->view->moduleID = (int)$moduleID;
$this->view->projectID = $projectID;
@@ -554,7 +554,7 @@ class bug extends control
$this->view->stories = $stories;
$this->view->builds = $builds;
$this->view->users = $this->user->getPairs('devfirst|nodeleted');
$this->view->projects = $this->product->getProjectPairs($productID, $branch ? "0,$branch" : 0, $params = 'nodeleted');
$this->view->projects = $this->product->getExecutionPairsByProduct($productID, $branch ? "0,$branch" : 0, 'nodeleted');
$this->view->projectID = $projectID;
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $branch);
$this->view->moduleID = $moduleID;
@@ -727,7 +727,7 @@ class bug extends control
$this->view->plans = $this->loadModel('productplan')->getPairs($productID, $bug->branch);
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $bug->branch);
$this->view->currentModuleID = $currentModuleID;
$this->view->projects = $this->product->getProjectPairs($bug->product, $bug->branch ? "0,{$bug->branch}" : 0, 'nodeleted');
$this->view->projects = $this->product->getExecutionPairsByProduct($bug->product, $bug->branch ? "0,{$bug->branch}" : 0, 'nodeleted');
$this->view->stories = $bug->project ? $this->story->getProjectStoryPairs($bug->project) : $this->story->getProductStoryPairs($bug->product, $bug->branch);
$this->view->branches = $this->session->currentProductType == 'normal' ? array() : $this->loadModel('branch')->getPairs($bug->product);
$this->view->tasks = $this->task->getProjectTaskPairs($bug->project);
@@ -1100,7 +1100,7 @@ class bug extends control
$this->view->bug = $bug;
$this->view->users = $users;
$this->view->assignedTo = $assignedTo;
$this->view->projects = $this->loadModel('product')->getProjectPairs($productID, $bug->branch ? "0,{$bug->branch}" : 0, $params = 'nodeleted');
$this->view->projects = $this->loadModel('product')->getExecutionPairsByProduct($productID, $bug->branch ? "0,{$bug->branch}" : 0, 'nodeleted');
$this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch = $bug->branch, 'all');
$this->view->actions = $this->action->getList('bug', $bugID);
$this->display();
+1 -1
View File
@@ -1273,7 +1273,7 @@ class bugModel extends model
$this->config->bug->search['params']['product']['values'] = array($productID => $products[$productID], 'all' => $this->lang->bug->allProduct);
$this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairs($productID);
$this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0);
$this->config->bug->search['params']['project']['values'] = $this->product->getProjectPairs($productID);
$this->config->bug->search['params']['project']['values'] = $this->product->getExecutionPairsByProduct($productID);
$this->config->bug->search['params']['severity']['values'] = array(0 => '') + $this->lang->bug->severityList; //Fix bug #939.
$this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getProductBuildPairs($productID, 0, $params = '');
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values'];
+1 -1
View File
@@ -13,7 +13,7 @@ global $lang;
$config->build->search['module'] = 'build';
$config->build->search['fields']['name'] = $lang->build->name;
$config->build->search['fields']['id'] = $lang->build->id;
$config->build->search['fields']['product'] = $lang->story->product;
$config->build->search['fields']['product'] = $lang->build->product;
$config->build->search['fields']['scmPath'] = $lang->build->scmPath;
$config->build->search['fields']['filePath'] = $lang->build->filePath;
$config->build->search['fields']['date'] = $lang->build->date;
+24 -23
View File
@@ -14,22 +14,22 @@ class build extends control
/**
* Create a build.
*
* @param int $projectID
* @param int $executionID
* @param int $productID
* @access public
* @return void
*/
public function create($projectID, $productID = 0)
public function create($executionID, $productID = 0)
{
if(!empty($_POST))
{
$buildID = $this->build->create($projectID);
$buildID = $this->build->create($executionID);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->loadModel('action')->create('build', $buildID, 'opened');
$this->executeHooks($buildID);
if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadProjectBuilds($projectID)"));//Code for task #5126.
if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadProjectBuilds($executionID)"));//Code for task #5126.
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('build', 'view', "buildID=$buildID")));
}
@@ -40,29 +40,30 @@ class build extends control
$this->loadModel('user');
/* Set menu. */
$this->project->setMenu($this->project->getExecutionPairs($this->session->PRJ), $projectID);
$executions = $this->project->getExecutionPairs($this->session->PRJ);
$this->project->setMenu($executions, $executionID);
/* Get stories and bugs. */
$orderBy = 'status_asc, stage_asc, id_desc';
/* Assign. */
$project = $this->loadModel('project')->getById($projectID);
$project = $this->loadModel('project')->getExecutionById($executionID);
$productGroups = $this->project->getProducts($projectID);
$productGroups = $this->project->getProducts($executionID);
$productID = $productID ? $productID : key($productGroups);
$products = array();
foreach($productGroups as $product) $products[$product->id] = $product->name;
$this->view->title = $project->name . $this->lang->colon . $this->lang->build->create;
$this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$projectID"), $project->name);
$this->view->position[] = $this->lang->build->create;
$this->view->title = $project->name . $this->lang->colon . $this->lang->build->create;
$this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$executionID"), $project->name);
$this->view->position[] = $this->lang->build->create;
$this->view->product = isset($productGroups[$productID]) ? $productGroups[$productID] : '';
$this->view->branches = (isset($productGroups[$productID]) and $productGroups[$productID]->type == 'normal') ? array() : $this->loadModel('branch')->getPairs($productID);
$this->view->projectID = $projectID;
$this->view->executionID = $executionID;
$this->view->orderBy = $orderBy;
$this->view->products = $products;
$this->view->lastBuild = $this->build->getLast($projectID);
$this->view->lastBuild = $this->build->getLast($executionID);
$this->view->productGroups = $productGroups;
$this->view->users = $this->user->getPairs('nodeleted|noclosed');
$this->display();
@@ -107,15 +108,15 @@ class build extends control
$orderBy = 'status_asc, stage_asc, id_desc';
/* Assign. */
$project = $this->loadModel('project')->getById($build->project);
if(empty($project))
$execution = $this->loadModel('project')->getExecutionById($build->project);
if(empty($execution))
{
$project = new stdclass();
$project->name = '';
$execution = new stdclass();
$execution->name = '';
}
$projects = $this->loadModel('product')->getProjectPairs($build->product, $build->branch, 'nodeleted');
if(!isset($projects[$build->project])) $projects[$build->project] = $project->name;
$executions = $this->loadModel('product')->getExecutionPairsByProduct($build->product, $build->branch, 'nodeleted');
if(!isset($executions[$build->project])) $executions[$build->project] = $execution->name;
$productGroups = $this->project->getProducts($build->project);
@@ -130,12 +131,12 @@ class build extends control
$products = array();
foreach($productGroups as $product) $products[$product->id] = $product->name;
$this->view->title = $project->name . $this->lang->colon . $this->lang->build->edit;
$this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $project->name);
$this->view->title = $execution->name . $this->lang->colon . $this->lang->build->edit;
$this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $execution->name);
$this->view->position[] = $this->lang->build->edit;
$this->view->product = isset($productGroups[$build->product]) ? $productGroups[$build->product] : '';
$this->view->branches = (isset($productGroups[$build->product]) and $productGroups[$build->product]->type == 'normal') ? array() : $this->loadModel('branch')->getPairs($build->product);
$this->view->projects = $projects;
$this->view->executions = $executions;
$this->view->orderBy = $orderBy;
$this->view->productGroups = $productGroups;
@@ -524,7 +525,7 @@ class build extends control
$this->config->bug->search['style'] = 'simple';
$this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts(array($build->product => $build->product));
$this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($build->product, $viewType = 'bug', $startModuleID = 0);
$this->config->bug->search['params']['project']['values'] = $this->loadModel('product')->getProjectPairs($build->product);
$this->config->bug->search['params']['project']['values'] = $this->loadModel('product')->getExecutionPairsByProduct($build->product);
$this->config->bug->search['params']['openedBuild']['values'] = $this->build->getProductBuildPairs($build->product, $branch = 0, $params = '');
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values'];
+1 -1
View File
@@ -36,7 +36,7 @@
</td>
<td></td>
<?php else:?>
<td class='text-muted' colspan='2'><?php if(empty($products)) printf($lang->build->noProduct, $this->createLink('project', 'manageproducts', "projectID=$projectID&from=buildCreate"));?></td>
<td class='text-muted' colspan='2'><?php printf($lang->build->noProduct, $this->createLink('project', 'manageproducts', "executionID=$executionID&from=buildCreate"));?></td>
<?php endif;?>
</tr>
<tr>
+1 -1
View File
@@ -45,7 +45,7 @@
</tr>
<tr>
<th><?php echo $lang->build->project;?></th>
<td id='projectsBox'><?php echo html::select('project', $projects, $build->project, "class='form-control chosen' required");?></td>
<td id='projectsBox'><?php echo html::select('project', $executions, $build->project, "class='form-control chosen' required");?></td>
</tr>
<tr>
<th><?php echo $lang->build->name;?></th>
+1 -1
View File
@@ -640,7 +640,7 @@ class product extends control
}
else
{
$projects = $this->product->getProjectPairs($productID, $branch ? "0,$branch" : $branch, $params = 'nodeleted');
$projects = $this->product->getExecutionPairsByProduct($productID, $branch ? "0,$branch" : $branch, 'nodeleted');
}
if($this->app->getViewType() == 'json') die(json_encode($projects));
+13 -16
View File
@@ -754,33 +754,30 @@ class productModel extends model
}
/**
* Get projects of a product in pairs.
* Get executions by product and project.
*
* @param int $productID
* @param string $param all|nodeleted
* @param int $branch
* @param string $status all|nodeleted
* @access public
* @return array
*/
public function getProjectPairs($productID, $branch = 0, $param = 'all')
public function getExecutionPairsByProduct($productID, $branch = 0, $status = 'all')
{
$projects = array();
$datas = $this->dao->select('t2.id, t2.name, t2.deleted')->from(TABLE_PROJECTPRODUCT)
if(!$this->session->PRJ) return array();
$executions = $this->dao->select('t2.id, t2.name')->from(TABLE_PROJECTPRODUCT)
->alias('t1')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->where('t1.product')->eq((int)$productID)
->andWhere('t2.project')->eq((int)$this->session->PRJ)
->where('t1.product')->eq($productID)
->andWhere('t2.project')->eq($this->session->PRJ)
->beginIF($branch)->andWhere('t1.branch')->in($branch)->fi()
->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->sprints)->fi()
->andWhere('t2.deleted')->eq(0)
->beginIF($status == 'nodeleted')->andWhere('t2.deleted')->eq('0')->fi()
->orderBy('t1.project desc')
->fetchAll();
->fetchPairs();
foreach($datas as $data)
{
if($param == 'nodeleted' and $data->deleted) continue;
$projects[$data->id] = $data->name;
}
$projects = array('' => '') + $projects;
return $projects;
$executions = array('' => '') + $executions;
return $executions;
}
/**
+15 -1
View File
@@ -1331,7 +1331,7 @@ class projectModel extends model
}
/**
* Get project by id.
* Get the execution by ID.
*
* @param int $projectID
* @param bool $setImgSize
@@ -1380,6 +1380,20 @@ class projectModel extends model
return $project;
}
/**
* Get the execution by ID.
*
* @param int $executionID
* @access public
* @return object
*/
public function getExecutionById($executionID = 0)
{
/* TODO: The getbyid method queries too much information that is not actually needed. */
if(empty($executionID)) return array();
return $this->dao->findById($executionID)->from(TABLE_EXECUTION)->fetch();
}
/**
* Get the default managers for a project from it's related products.
*
+1 -1
View File
@@ -521,7 +521,7 @@ class release extends control
$this->config->bug->search['style'] = 'simple';
$this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts(array($release->product => $release->product));
$this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($release->product, $viewType = 'bug', $startModuleID = 0);
$this->config->bug->search['params']['project']['values'] = $this->loadModel('product')->getProjectPairs($release->product);
$this->config->bug->search['params']['project']['values'] = $this->loadModel('product')->getExecutionPairsByProduct($release->product);
$this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getProductBuildPairs($release->product, $branch = 0, $params = '');
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values'];
if($this->session->currentProductType == 'normal')
+3 -3
View File
@@ -164,7 +164,7 @@ class testtask extends control
/* Create testtask from testtask of test.*/
$productID = $productID ? $productID : key($this->products);
$projects = empty($productID) ? array() : $this->product->getProjectPairs($productID, 0, $params = 'nodeleted');
$projects = empty($productID) ? array() : $this->product->getExecutionPairsByProduct($productID, 0, $params = 'nodeleted');
$builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk', true);
/* Set menu. */
@@ -592,7 +592,7 @@ class testtask extends control
/* Create testtask from testtask of test.*/
$productID = $productID ? $productID : key($this->products);
$projects = empty($productID) ? array() : $this->product->getProjectPairs($productID, 0, $params = 'nodeleted');
$projects = empty($productID) ? array() : $this->product->getExecutionPairsByProduct($productID, 0, $params = 'nodeleted');
$builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk', true);
$this->view->task = $task;
@@ -1162,7 +1162,7 @@ class testtask extends control
$this->app->loadLang('job');
$productID = $productID ? $productID : key($this->products);
$projects = empty($productID) ? array() : $this->product->getProjectPairs($productID, 0, $params = 'nodeleted');
$projects = empty($productID) ? array() : $this->product->getExecutionPairsByProduct($productID, 0, $params = 'nodeleted');
$builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk');
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->importUnitResult;