* Merge module-execution to Merge184.

This commit is contained in:
chaideqing
2023-11-15 15:25:09 +08:00
parent 48fda5052f
commit 129307a891
3 changed files with 69 additions and 14 deletions
+36 -7
View File
@@ -1546,6 +1546,7 @@ class execution extends control
/* Execution not found to prevent searching for. */
if(!isset($this->executions[$execution->id])) $this->executions = $this->execution->getPairs($execution->project, 'all', 'nocode');
if(!$this->loadModel('common')->checkPrivByObject('execution', $executionID)) return $this->execution->accessDenied();
$execution->projectInfo = $this->loadModel('project')->getByID($execution->project);
$programList = array_filter(explode(',', $execution->projectInfo->path));
@@ -1639,6 +1640,7 @@ class execution extends control
*/
public function taskKanban(int $executionID, string $browseType = 'all', string $orderBy = 'order_asc', string $groupBy = '')
{
if(!$this->loadModel('common')->checkPrivByObject('execution', $executionID)) return $this->execution->accessDenied();
/* Load model and language. */
$this->app->loadLang('task');
$this->app->loadLang('bug');
@@ -2493,6 +2495,29 @@ class execution extends control
*/
public function ajaxGetDropMenu(int $executionID, string $module, string $method, string $extra = '')
{
$this->view->link = $this->executionZen->getLink($module, $method, $extra);
$this->view->module = $module;
$this->view->method = $method;
$this->view->executionID = $executionID;
$this->view->extra = $extra;
$cacheProjectsKey = $this->config->cacheKeys->execution->ajaxGetDropMenuProjects;
$cacheExecutionsKey = $this->config->cacheKeys->execution->ajaxGetDropMenuExecutions;
if(helper::isCacheEnabled())
{
$projects = $this->cache->get($cacheProjectsKey);
$projectExecutions = $this->cache->get($cacheExecutionsKey);
if(!empty($projects) && !empty($projectExecutions))
{
$this->view->projects = $projects;
$this->view->projectExecutions = $projectExecutions;
$this->display();
return;
}
}
$projects = $this->loadModel('program')->getProjectList(0, 'all', 0, 'order_asc', '', true); /* 获取所有项目的列表。*/
$executionGroups = $this->dao->select('*')->from(TABLE_EXECUTION) /* 按照项目分组,获取有权限访问的执行列表。*/
->where('deleted')->eq('0')
@@ -2540,10 +2565,12 @@ class execution extends control
$projectExecutions[$execution->project][] = $execution;
}
$this->view->link = $this->executionZen->getLink($module, $method, $extra);
$this->view->module = $module;
$this->view->method = $method;
$this->view->extra = $extra;
if($this->config->cache->enable)
{
$this->cache->set($cacheProjectsKey, $projectPairs);
$this->cache->set($cacheExecutionsKey, $projectExecutions);
}
$this->view->projects = $projectPairs; /* 项目ID为索引,项目名称为值的数组 [projectID => projectName]。 */
$this->view->projectExecutions = $projectExecutions; /* 项目对应的执行列表 [projectID => execution]。*/
$this->view->executionID = $executionID;
@@ -2667,12 +2694,12 @@ class execution extends control
* @access public
* @return void
*/
public function all(string $status = 'undone', string $orderBy = 'order_asc', int $productID = 0, string $param = '', int $recTotal = 0, int $recPerPage = 100, int $pageID = 1)
public function all(string $status = 'undone', string $orderBy = 'order_asc', int $productID = 0, string $param = '', int $recTotal = 0, int $recPerPage = 20, int $pageID = 1)
{
$this->app->loadLang('my');
$this->app->loadLang('product');
$this->app->loadLang('stage');
$this->app->loadLang('programplan');
$this->loadModel('product');
$this->loadModel('datatable');
$from = $this->app->tab;
@@ -2688,6 +2715,8 @@ class execution extends control
$this->app->loadClass('pager', true);
$pager = new pager($recTotal, $recPerPage, $pageID);
$this->loadModel('program')->refreshStats(); // Refresh stats fields of projects.
$queryID = ($status == 'bySearch') ? (int)$param : 0;
$actionURL = $this->createLink('execution', 'all', "status=bySearch&orderBy=$orderBy&productID=$productID&param=myQueryID");
$this->execution->buildSearchForm($queryID, $actionURL);
@@ -2930,7 +2959,7 @@ class execution extends control
public function treeStory(int $storyID, int $version = 0)
{
$story = $this->loadModel('story')->getById($storyID, $version, true);
$product = $this->dao->findById($story->product)->from(TABLE_PRODUCT)->fields('name,id,`type`,shadow')->fetch();
$product = $this->dao->findById($story->product)->from(TABLE_PRODUCT)->fields('name, id, `type`, shadow')->fetch();
$this->view->story = $story;
$this->view->product = $product;
+32 -6
View File
@@ -24,11 +24,7 @@ class executionModel extends model
*/
public function checkPriv(int $executionID): bool
{
if(empty($executionID)) return false;
/* If is admin, return true. */
if($this->app->user->admin) return true;
return (strpos(",{$this->app->user->view->sprints},", ",{$executionID},") !== false);
return !empty($executionID) && ($this->app->user->admin || (strpos(",{$this->app->user->view->sprints},", ",{$executionID},") !== false));
}
/**
@@ -1463,6 +1459,35 @@ class executionModel extends model
->fetchPairs('id', 'id');
}
/**
* Get execution count.
*
* @param int $projectID
* @param string $browseType all|undone|wait|doing|suspended|closed|involved|review
* @access public
* @return int
*/
public function getExecutionCounts(int $projectID = 0, string $browseType = 'all'): int
{
$executions = $this->dao->select('t1.*,t2.name projectName, t2.model as projectModel')->from(TABLE_EXECUTION)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->where('t1.type')->in('sprint,stage,kanban')
->andWhere('t1.deleted')->eq('0')
->andWhere('t1.vision')->eq($this->config->vision)
->andWhere('t1.multiple')->eq('1')
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->sprints)->fi()
->beginIF($projectID)->andWhere('t1.project')->eq($projectID)->fi()
->beginIF(!in_array($browseType, array('all', 'undone', 'involved', 'review', 'bySearch')))->andWhere('t1.status')->eq($browseType)->fi()
->beginIF($browseType == 'undone')->andWhere('t1.status')->notIN('done,closed')->fi()
->beginIF($browseType == 'review')
->andWhere("FIND_IN_SET('{$this->app->user->account}', t1.reviewers)")
->andWhere('t1.reviewStatus')->eq('doing')
->fi()
->fetchAll('id');
return count($executions);
}
/**
* 获取执行数据。
* Get execution stat data.
@@ -1573,7 +1598,7 @@ class executionModel extends model
->andWhere('t1.multiple')->eq('1')
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->sprints)->fi()
->beginIF(!empty($executionQuery))->andWhere($executionQuery)->fi()
->beginIF($productID)->andWhere('t3.product')->eq((int)$productID)->fi()
->beginIF($productID)->andWhere('t3.product')->eq($productID)->fi()
->beginIF($projectID)->andWhere('t1.project')->eq($projectID)->fi()
->beginIF(!in_array($browseType, array('all', 'undone', 'involved', 'review', 'bySearch')))->andWhere('t1.status')->eq($browseType)->fi()
->beginIF($browseType == 'undone')->andWhere('t1.status')->notIN('done,closed')->fi()
@@ -2259,6 +2284,7 @@ class executionModel extends model
$this->config->product->search['params']['plan']['values'] = $planPairs;
$this->config->product->search['params']['module']['values'] = $modules;
$this->config->product->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $this->lang->story->statusList);
$this->config->product->search['params']['stage']['values'] = array('' => '') + $this->lang->story->stageList;
if($productType == 'normal')
{
unset($this->config->product->search['fields']['branch']);
+1 -1
View File
@@ -37,7 +37,7 @@ js::set('isCNLang', !$this->loadModel('common')->checkNotCN());
<div class='btn-toolBar pull-left'>
<?php if($from == 'project'):?>
<div class='btn-group'>
<?php $viewName = $productID != 0 ? zget($productList,$productID) : $lang->product->allProduct;?>
<?php $viewName = $productID != 0 ? zget($productList, $productID) : $lang->product->allProduct;?>
<a href='javascript:;' class='btn btn-link btn-limit' data-toggle='dropdown'><span class='text' title='<?php echo $viewName;?>'><?php echo $viewName;?></span> <span class='caret'></span></a>
<ul class='dropdown-menu' style='max-height:240px; max-width: 300px; overflow-y:auto'>
<?php