From 8bf6c34acde568afcfc88cffb066ed4da20d3a13 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 26 Nov 2021 13:37:15 +0800 Subject: [PATCH] * Modify the logic of planning related stories and bugs. --- module/product/control.php | 42 +++++----------------- module/productplan/control.php | 22 +++++++----- module/productplan/model.php | 9 +++-- module/productplan/view/browse.html.php | 2 +- module/productplan/view/linkstory.html.php | 2 +- module/story/control.php | 2 +- module/story/js/batchcreate.js | 2 +- module/story/js/batchedit.js | 4 +-- module/story/model.php | 2 +- module/story/view/header.html.php | 3 +- 10 files changed, 37 insertions(+), 53 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index 6fd021e776..d31a1099cc 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -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 = "
"; - $output .= "
"; - $output .= html::select($field, $plans, $planID, "class='form-control chosen'"); - $output .= "
"; - if(count($plans) == 1 and $needCreate) - { - $output .= "
"; - $output .= "
"; - $output .= html::a($this->createLink('productplan', 'create', "productID=$productID&branch=$branch", '', true), "", '', "class='btn btn-icon' data-toggle='modal' data-type='iframe' data-width='95%' title='{$this->lang->productplan->create}'"); - $output .= '
'; - $output .= '
'; - $output .= "
"; - $output .= "
"; - $output .= html::a("javascript:void(0)", "", '', "class='btn btn-icon refresh' data-toggle='tooltip' title='{$this->lang->refresh}' onclick='loadProductPlans($productID)'"); - $output .= '
'; - $output .= '
'; - } - $output .= "
"; - } - else - { - $output .= html::select($field, $plans, $planID, "class='form-control chosen'"); - if(count($plans) == 1 and $needCreate) - { - $output .= "
"; - $output .= html::a($this->createLink('productplan', 'create', "productID=$productID&branch=$branch", '', true), "", '', "class='btn btn-icon' data-toggle='modal' data-type='iframe' data-width='95%' title='{$this->lang->productplan->create}'"); - $output .= '
'; - $output .= "
"; - $output .= html::a("javascript:void(0)", "", '', "class='btn btn-icon refresh' data-toggle='tooltip' title='{$this->lang->refresh}' onclick='loadProductPlans($productID)'"); - $output .= '
'; - } - + $output .= "
"; + $output .= html::a($this->createLink('productplan', 'create', "productID=$productID&branch=$branch", '', true), "", '', "class='btn btn-icon' data-toggle='modal' data-type='iframe' data-width='95%' title='{$this->lang->productplan->create}'"); + $output .= '
'; + $output .= "
"; + $output .= html::a("javascript:void(0)", "", '', "class='btn btn-icon refresh' data-toggle='tooltip' title='{$this->lang->refresh}' onclick='loadProductPlans($productID)'"); + $output .= '
'; } die($output); } diff --git a/module/productplan/control.php b/module/productplan/control.php index 751e2f822b..ccc6f224b2 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -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¶m=" . 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') diff --git a/module/productplan/model.php b/module/productplan/model.php index 8ae39efd39..180ef591bc 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -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(); } } diff --git a/module/productplan/view/browse.html.php b/module/productplan/view/browse.html.php index b3f2b53651..31e8d00e33 100644 --- a/module/productplan/view/browse.html.php +++ b/module/productplan/view/browse.html.php @@ -128,7 +128,7 @@ " . $this->loadModel('flow')->getFieldValue($extendField, $plan) . "";?> parent >= 0) { $executionLink = $config->systemMode == 'new' ? '#projects' : $this->createLink('execution', 'create', "projectID=0&executionID=0©ExecutionID=0&plan=$plan->id&confirm=no&productID=$productID"); if($config->systemMode == 'new') diff --git a/module/productplan/view/linkstory.html.php b/module/productplan/view/linkstory.html.php index 704c820e86..76abdaf6e8 100644 --- a/module/productplan/view/linkstory.html.php +++ b/module/productplan/view/linkstory.html.php @@ -46,7 +46,7 @@ id => sprintf('%03d', $story->id)));?> pri;?>' title='story->priList, $story->pri, $story->pri)?>'>story->priList, $story->pri, $story->pri)?> - planTitle;?> + planTitle;?> module];?> 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); diff --git a/module/story/js/batchcreate.js b/module/story/js/batchcreate.js index 4ca78022ef..9c513a278a 100644 --- a/module/story/js/batchcreate.js +++ b/module/story/js/batchcreate.js @@ -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 = ''; diff --git a/module/story/js/batchedit.js b/module/story/js/batchedit.js index 06e29abb14..fd823b61f7 100644 --- a/module/story/js/batchedit.js +++ b/module/story/js/batchedit.js @@ -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=¶m=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=¶m=skipParent'); + $('#plans' + storyID).parent('td').load(planLink, function(){$('#plans' + storyID).chosen();}); } $(function() diff --git a/module/story/model.php b/module/story/model.php index 481d9af9b3..174adf1e05 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -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') diff --git a/module/story/view/header.html.php b/module/story/view/header.html.php index ccf27f7cb8..5c9c2f0f6f 100644 --- a/module/story/view/header.html.php +++ b/module/story/view/header.html.php @@ -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=¶m=skipParent'); + var expired = config.currentMethod == 'create' ? 'unexpired' : ''; + planLink = createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=' + branch + '&planID=' + $('#plan').val() + '&fieldID=&needCreate=true&expired='+ expired +'¶m=skipParent'); var $planIdBox = $('#planIdBox'); $planIdBox.load(planLink, function() {