* Modify the logic of planning related stories and bugs.

This commit is contained in:
tianshujie
2021-11-26 13:37:15 +08:00
parent ba63ff33bf
commit 8bf6c34acd
10 changed files with 37 additions and 53 deletions
+8 -34
View File
@@ -991,41 +991,15 @@ class product extends control
$plans = $this->loadModel('productplan')->getPairs($productID, $branch, $expired, $skipParent);
$field = $fieldID ? "plans[$fieldID]" : 'plan';
$output = '';
if(strpos($param, 'batchedit') !== false)
$output .= html::select($field, $plans, $planID, "class='form-control chosen'");
if(count($plans) == 1 and $needCreate and $needCreate !== 'false')
{
$output = "<div class='table-row'>";
$output .= "<div class='table-col'>";
$output .= html::select($field, $plans, $planID, "class='form-control chosen'");
$output .= "</div>";
if(count($plans) == 1 and $needCreate)
{
$output .= "<div class='table-col'>";
$output .= "<div class='input-group-btn'>";
$output .= html::a($this->createLink('productplan', 'create', "productID=$productID&branch=$branch", '', true), "<i class='icon icon-plus'></i>", '', "class='btn btn-icon' data-toggle='modal' data-type='iframe' data-width='95%' title='{$this->lang->productplan->create}'");
$output .= '</div>';
$output .= '</div>';
$output .= "<div class='table-col'>";
$output .= "<div class='input-group-btn'>";
$output .= html::a("javascript:void(0)", "<i class='icon icon-refresh'></i>", '', "class='btn btn-icon refresh' data-toggle='tooltip' title='{$this->lang->refresh}' onclick='loadProductPlans($productID)'");
$output .= '</div>';
$output .= '</div>';
}
$output .= "</div>";
}
else
{
$output .= html::select($field, $plans, $planID, "class='form-control chosen'");
if(count($plans) == 1 and $needCreate)
{
$output .= "<div class='input-group-btn'>";
$output .= html::a($this->createLink('productplan', 'create', "productID=$productID&branch=$branch", '', true), "<i class='icon icon-plus'></i>", '', "class='btn btn-icon' data-toggle='modal' data-type='iframe' data-width='95%' title='{$this->lang->productplan->create}'");
$output .= '</div>';
$output .= "<div class='input-group-btn'>";
$output .= html::a("javascript:void(0)", "<i class='icon icon-refresh'></i>", '', "class='btn btn-icon refresh' data-toggle='tooltip' title='{$this->lang->refresh}' onclick='loadProductPlans($productID)'");
$output .= '</div>';
}
$output .= "<div class='input-group-btn'>";
$output .= html::a($this->createLink('productplan', 'create', "productID=$productID&branch=$branch", '', true), "<i class='icon icon-plus'></i>", '', "class='btn btn-icon' data-toggle='modal' data-type='iframe' data-width='95%' title='{$this->lang->productplan->create}'");
$output .= '</div>';
$output .= "<div class='input-group-btn'>";
$output .= html::a("javascript:void(0)", "<i class='icon icon-refresh'></i>", '', "class='btn btn-icon refresh' data-toggle='tooltip' title='{$this->lang->refresh}' onclick='loadProductPlans($productID)'");
$output .= '</div>';
}
die($output);
}
+14 -8
View File
@@ -331,12 +331,13 @@ class productplan extends control
* @param int $productID
* @param int $branch
* @param string $number
* @param string $expired
* @access public
* @return void
*/
public function ajaxGetProductplans($productID, $branch = 0, $number = '')
public function ajaxGetProductplans($productID, $branch = 0, $number = '', $expired = '')
{
$plans = $this->productplan->getPairs($productID, $branch, '', true);
$plans = $this->productplan->getPairs($productID, $branch, $expired, true);
$planName = $number === '' ? 'plan' : "plan[$number]";
$plans = empty($plans) ? array('' => '') : $plans;
die(html::select($planName, $plans, '', "class='form-control'"));
@@ -402,8 +403,10 @@ class productplan extends control
$this->config->product->search['queryID'] = $queryID;
$this->config->product->search['style'] = 'simple';
$this->config->product->search['params']['product']['values'] = $products + array('all' => $this->lang->product->allProductsOfProject);
$this->config->product->search['params']['plan']['values'] = $this->productplan->getForProducts(array($plan->product => $plan->product));
$this->config->product->search['params']['module']['values'] = $this->tree->getOptionMenu($plan->product, 'story', 0, 'all');
$this->config->product->search['params']['plan']['values'] = $this->productplan->getPairs($plan->product, $plan->branch, '', true);
$modules = $this->loadModel('tree')->getOptionMenu($plan->product, 'story', 0, $plan->branch ? array(BRANCH_MAIN, $plan->branch) : array(BRANCH_MAIN));
$this->config->product->search['params']['module']['values'] = $plan->branch ? $modules[BRANCH_MAIN] + $modules[$plan->branch] : $modules[BRANCH_MAIN];
$storyStatusList = $this->lang->story->statusList;
unset($storyStatusList['closed']);
$this->config->product->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $storyStatusList);
@@ -425,7 +428,7 @@ class productplan extends control
if($browseType == 'bySearch')
{
$allStories = $this->story->getBySearch($plan->product, $plan->branch ? "0,{$plan->branch}" : 0, $queryID, 'id', '', 'story', array_keys($planStories), $pager);
$allStories = $this->story->getBySearch($plan->product, "0,{$plan->branch}", $queryID, 'id', '', 'story', array_keys($planStories), $pager);
}
else
{
@@ -538,14 +541,17 @@ class productplan extends control
$pager = new pager($recTotal, $recPerPage, $pageID);
/* Build the search form. */
if($this->config->systemMode == 'classic') unset($this->config->bug->search['fields']['project']);
$this->config->bug->search['actionURL'] = $this->createLink('productplan', 'view', "planID=$planID&type=bug&orderBy=$orderBy&link=true&param=" . helper::safe64Encode('&browseType=bySearch&queryID=myQueryID'));
$this->config->bug->search['queryID'] = $queryID;
$this->config->bug->search['style'] = 'simple';
$this->config->bug->search['params']['plan']['values'] = $this->productplan->getForProducts(array($productID => $productID));
$this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($productID, 'bug', 0, 'all');
$this->config->bug->search['params']['project']['values'] = $this->product->getExecutionPairsByProduct($productID);
$this->config->bug->search['params']['plan']['values'] = $this->productplan->getPairs($productID, $plan->branch, '', true);
$this->config->bug->search['params']['execution']['values'] = $this->loadModel('product')->getExecutionPairsByProduct($plan->product, $plan->branch);
$this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getProductBuildPairs($productID, $branch = 0, $params = '');
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->build->getProductBuildPairs($productID, $branch = 0, $params = '');
if($this->config->systemMode == 'new') $this->config->bug->search['params']['project']['values'] = $this->product->getProjectPairsByProduct($productID, $plan->branch);
$modules = $this->loadModel('tree')->getOptionMenu($plan->product, 'bug', 0, $plan->branch ? array(BRANCH_MAIN, $plan->branch) : array(BRANCH_MAIN));
$this->config->bug->search['params']['module']['values'] = $plan->branch ? $modules[BRANCH_MAIN] + $modules[$plan->branch] : $modules[BRANCH_MAIN];
unset($this->config->bug->search['fields']['product']);
if($this->session->currentProductType == 'normal')
+6 -3
View File
@@ -233,7 +233,7 @@ class productplanModel extends model
->where('product')->in($product)
->andWhere('deleted')->eq(0)
->andWhere('end')->lt($date)
->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi()
->beginIF($branch !== 'all' or $branch !== '')->andWhere("branch")->in($branch)->fi()
->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi()
->orderBy('begin desc')
->limit(5)
@@ -417,13 +417,16 @@ class productplanModel extends model
if(!empty($plan->parent))
{
$this->dao->update(TABLE_PRODUCTPLAN)->set('parent')->eq('-1')->where('id')->eq($plan->parent)->andWhere('parent')->eq('0')->exec();
/* Transfer stories and bugs linked with the parent plan to the child plan. */
$this->dao->update(TABLE_PLANSTORY)->set('plan')->eq($planID)->where('plan')->eq($plan->parent)->exec();
$this->dao->update(TABLE_BUG)->set('plan')->eq($planID)->where('plan')->eq($plan->parent)->exec();
$stories = $this->dao->select('*')->from(TABLE_STORY)->where('plan')->like("%{$plan->parent}%")->fetchAll('id');
foreach($stories as $storyID => $story)
{
if(strpos(",$story->plan,", ",{$plan->parent},") === false) continue;
$storyPlan = str_replace(",{$plan->parent},", ",$planID,", ",$story->plan,");
$storyPlan = trim($story->plan, ',');
if(strpos(",$storyPlan,", ",{$plan->parent},") === false) continue;
$storyPlan = str_replace(",{$plan->parent},", ",$planID,", ",$storyPlan,");
$this->dao->update(TABLE_STORY)->set('plan')->eq($storyPlan)->where('id')->eq($storyID)->exec();
}
}
+1 -1
View File
@@ -128,7 +128,7 @@
<?php foreach($extendFields as $extendField) echo "<td>" . $this->loadModel('flow')->getFieldValue($extendField, $plan) . "</td>";?>
<td class='c-actions'>
<?php
if(common::hasPriv('execution', 'create', $plan))
if(common::hasPriv('execution', 'create', $plan) and $plan->parent >= 0)
{
$executionLink = $config->systemMode == 'new' ? '#projects' : $this->createLink('execution', 'create', "projectID=0&executionID=0&copyExecutionID=0&plan=$plan->id&confirm=no&productID=$productID");
if($config->systemMode == 'new')
+1 -1
View File
@@ -46,7 +46,7 @@
<?php echo html::checkbox('stories', array($story->id => sprintf('%03d', $story->id)));?>
</td>
<td><span class='label-pri <?php echo 'label-pri-' . $story->pri;?>' title='<?php echo zget($lang->story->priList, $story->pri, $story->pri)?>'><?php echo zget($lang->story->priList, $story->pri, $story->pri)?></span></td>
<td><?php echo $story->planTitle;?></td>
<td class='c-name' title="<?php echo $story->planTitle;?>"><?php echo $story->planTitle;?></td>
<td title='<?php echo $modules[$story->module]?>' class='text-left'><?php echo $modules[$story->module];?></td>
<td class='text-left nobr' title='<?php echo $story->title?>'>
<?php
+1 -1
View File
@@ -666,7 +666,7 @@ class story extends control
$this->view->stories = $stories;
$this->view->users = $users;
$this->view->product = $product;
$this->view->plans = $this->loadModel('productplan')->getPairsForStory($story->product, $story->branch, true);
$this->view->plans = $this->loadModel('productplan')->getPairs($story->product, $story->branch, '', true);
$this->view->products = $myProducts + $othersProducts;
$this->view->branches = $branches;
$this->view->reviewers = implode(',', $reviewerList);
+1 -1
View File
@@ -58,7 +58,7 @@ function setModuleAndPlan(branchID, productID, num)
$("#module" + num).chosen();
});
planLink = createLink('productPlan', 'ajaxGetProductPlans', 'productID=' + productID + '&branch=' + branchID + '&num=' + num);
planLink = createLink('productPlan', 'ajaxGetProductPlans', 'productID=' + productID + '&branch=' + branchID + '&num=' + num + '&expired=unexpired');
$.get(planLink, function(plans)
{
if(!plans) plans = '<select id="plan' + num + '" name="plan[' + num + ']" class="form-control"></select>';
+2 -2
View File
@@ -34,8 +34,8 @@ function loadBranches(product, branch, storyID)
$('#modules' + storyID).parent('td').load(moduleLink, function(){$('#modules' + storyID).chosen();});
planID = $('#plans' + storyID).val();
planLink = createLink('product', 'ajaxGetPlans', 'productID=' + product + '&branch=' + branch + '&planID=' + planID + '&fieldID=' + storyID + '&needCreate=false&expired=&param=batchEdit,skipParent');
$('#plans' + storyID).closest('td').load(planLink, function(){$('#plans' + storyID).chosen();});
planLink = createLink('product', 'ajaxGetPlans', 'productID=' + product + '&branch=' + branch + '&planID=' + planID + '&fieldID=' + storyID + '&needCreate=false&expired=&param=skipParent');
$('#plans' + storyID).parent('td').load(planLink, function(){$('#plans' + storyID).chosen();});
}
$(function()
+1 -1
View File
@@ -2507,7 +2507,6 @@ class storyModel extends model
->leftJoin(TABLE_PROJECTSTORY)->alias('t2')->on('t1.id=t2.story')
->where($sql)
->beginIF($productID != 'all' and $productID != '')->andWhere('t1.`product`')->eq((int)$productID)->fi()
->beginIF($this->app->rawModule == 'productplan' and $this->app->rawMethod == 'linkstory')->andWhere('t1.`branch`')->in("0,{$this->session->planBranch}")->fi()
->andWhere('t1.deleted')->eq(0)
->andWhere('t1.type')->eq($type)
->orderBy($orderBy)
@@ -2641,6 +2640,7 @@ class storyModel extends model
->beginIF($this->session->storyBrowseType and strpos('changed|', $this->session->storyBrowseType) !== false)->andWhere('t2.status')->in(array_keys($unclosedStatus))->fi()
->beginIF(!empty($branchParam))->andWhere('t2.branch')->eq($branchParam)->fi()
->beginIF($modules)->andWhere('t2.module')->in($modules)->fi()
->beginIF($this->app->rawModule == 'release' and $this->app->rawMethod == 'linkstory')->andWhere('t2.branch')->in($branch)->fi()
->andWhere('t2.deleted')->eq(0)
->orderBy($orderBy)
->page($pager, 't2.id')
+2 -1
View File
@@ -76,7 +76,8 @@ function loadProductPlans(productID, branch)
{
if(typeof(branch) == 'undefined') branch = 0;
if(!branch) branch = 0;
planLink = createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=' + branch + '&planID=' + $('#plan').val() + '&fieldID=&needCreate=true&expired=&param=skipParent');
var expired = config.currentMethod == 'create' ? 'unexpired' : '';
planLink = createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=' + branch + '&planID=' + $('#plan').val() + '&fieldID=&needCreate=true&expired='+ expired +'&param=skipParent');
var $planIdBox = $('#planIdBox');
$planIdBox.load(planLink, function()
{