From adb2c12935661d1f65e285176fb95ac18bba70ee Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 29 Nov 2021 15:54:48 +0800 Subject: [PATCH] * Modify the code. --- module/execution/control.php | 14 +++++++------- module/execution/js/common.js | 20 ++++++++++++++++++++ module/execution/model.php | 2 +- module/product/control.php | 3 +-- module/productplan/control.php | 10 +++++----- module/productplan/model.php | 8 ++++---- module/release/control.php | 8 ++++---- 7 files changed, 42 insertions(+), 23 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 7c3e5b42d1..e7682e63c0 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1309,7 +1309,7 @@ class execution extends control ->where('t1.id')->eq($plan->product) ->fetchAll('id'); - $productPlan = $this->loadModel('productplan')->getPairs($plan->product, $plan->branch, 'unexpired'); + $productPlan = $this->loadModel('productplan')->getPairsForStory($plan->product, $plan->branch, 'skipParent|unexpired'); $linkedBranches = array(); $linkedBranches[$plan->product][$plan->branch] = $plan->branch; @@ -2485,10 +2485,10 @@ class execution extends control $queryID = ($browseType == 'bySearch') ? (int)$param : 0; /* Set modules and branches. */ - $modules = array(); - $branchPairs = array(BRANCH_MAIN); - $branches = $this->project->getBranchesByProject($objectID); - $productType = 'normal'; + $modules = array(); + $branchIDList = array(BRANCH_MAIN); + $branches = $this->project->getBranchesByProject($objectID); + $productType = 'normal'; $this->loadModel('tree'); $this->loadModel('branch'); foreach($products as $product) @@ -2503,7 +2503,7 @@ class execution extends control $productType = $product->type; if(isset($branches[$product->id])) { - foreach($branches[$product->id] as $branchID => $branch) $branchPairs[$branchID] = $branchID; + foreach($branches[$product->id] as $branchID => $branch) $branchIDList[$branchID] = $branchID; } } } @@ -2519,7 +2519,7 @@ class execution extends control } else { - $allStories = $this->story->getProductStories(array_keys($products), $branchPairs, $moduleID = '0', $status = 'active', 'story', 'id_desc', $hasParent = false, '', $pager = null); + $allStories = $this->story->getProductStories(array_keys($products), $branchIDList, $moduleID = '0', $status = 'active', 'story', 'id_desc', $hasParent = false, '', $pager = null); } $linkedStories = $this->story->getExecutionStoryPairs($objectID); diff --git a/module/execution/js/common.js b/module/execution/js/common.js index 19313ec0a8..66f811f18b 100644 --- a/module/execution/js/common.js +++ b/module/execution/js/common.js @@ -168,6 +168,14 @@ function loadBranches(product) }); } +/** + * Load plans by product id. + * + * @param int $product + * @param int $branchID + * @access public + * @return void + */ function loadPlans(product, branchID) { if($('#plansBox').size() == 0) return false; @@ -190,6 +198,12 @@ function loadPlans(product, branchID) }); } +/** + * Adjust product box margin. + * + * @access public + * @return void + */ function adjustProductBoxMargin() { var productRows = Math.ceil($('#productsBox > .row > .col-sm-4').length / 3); @@ -202,6 +216,12 @@ function adjustProductBoxMargin() } } +/** + * Adjust plan box margin. + * + * @access public + * @return void + */ function adjustPlanBoxMargin() { var planRows = Math.ceil($('#plansBox > .row > .col-sm-4').length / 3); diff --git a/module/execution/model.php b/module/execution/model.php index 3e4d3cd85d..4db39d6298 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1750,7 +1750,7 @@ class executionModel extends model $plans = $this->productplan->getBranchPlanPairs($productID, array(BRANCH_MAIN) + $product->branches, true); foreach($plans as $plan) $planPairs += $plan; } - $this->config->product->search['params']['plan']['values'] = $planPairs; + $this->config->product->search['params']['plan']['values'] = $planPairs; $this->config->product->search['params']['module']['values'] = $modules; if($productType == 'normal') { diff --git a/module/product/control.php b/module/product/control.php index d31a1099cc..b47e42c88a 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -987,8 +987,7 @@ class product extends control public function ajaxGetPlans($productID, $branch = 0, $planID = 0, $fieldID = '', $needCreate = false, $expired = '', $param = '') { $param = strtolower($param); - $skipParent = strpos($param, 'skipparent') !== false ? true : false; - $plans = $this->loadModel('productplan')->getPairs($productID, $branch, $expired, $skipParent); + $plans = $this->loadModel('productplan')->getPairs($productID, $branch, $expired, strpos($param, 'skipparent') !== false); $field = $fieldID ? "plans[$fieldID]" : 'plan'; $output = ''; $output .= html::select($field, $plans, $planID, "class='form-control chosen'"); diff --git a/module/productplan/control.php b/module/productplan/control.php index 2f899559f5..d4b9af2f32 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -430,8 +430,8 @@ class productplan extends control else { $this->config->product->search['fields']['branch'] = $this->lang->product->branch; - $branches = $this->loadModel('branch')->getPairs($plan->product); - $branches = array('' => '', BRANCH_MAIN => $this->lang->branch->main, $plan->branch => $branches[$plan->branch]); + $branch = $this->loadModel('branch')->getById($plan->branch); + $branches = array('' => '', BRANCH_MAIN => $this->lang->branch->main, $plan->branch => $branch->name); $this->config->product->search['params']['branch']['values'] = $branches; } $this->loadModel('search')->setSearchParams($this->config->product->search); @@ -561,8 +561,8 @@ class productplan extends control $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); $this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($plan->product, 'bug', 0, $plan->branch); + if($this->config->systemMode == 'new') $this->config->bug->search['params']['project']['values'] = $this->product->getProjectPairsByProduct($productID, $plan->branch); unset($this->config->bug->search['fields']['product']); if($this->session->currentProductType == 'normal') @@ -573,8 +573,8 @@ class productplan extends control else { $this->config->bug->search['fields']['branch'] = $this->lang->product->branch; - $branches = $this->loadModel('branch')->getPairs($productID); - $branches = array('' => '', BRANCH_MAIN => $this->lang->branch->main, $plan->branch => $branches[$plan->branch]); + $branch = $this->loadModel('branch')->getById($plan->branch); + $branches = array('' => '', BRANCH_MAIN => $this->lang->branch->main, $plan->branch => $branch->name); $this->config->bug->search['params']['branch']['values'] = $branches; } $this->loadModel('search')->setSearchParams($this->config->bug->search); diff --git a/module/productplan/model.php b/module/productplan/model.php index 568c89058d..c47f74610c 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -171,10 +171,10 @@ class productplanModel extends model /** * Get plan pairs. * - * @param array|int $product - * @param int $branch - * @param string $expired - * @param bool $skipParent + * @param array|int $product + * @param int|string|array $branch + * @param string $expired + * @param bool $skipParent * @access public * @return array */ diff --git a/module/release/control.php b/module/release/control.php index 2b85d3eb10..5e1664b2a6 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -429,8 +429,8 @@ class release extends control else { $this->config->product->search['fields']['branch'] = $this->lang->product->branch; - $branches = $this->loadModel('branch')->getPairs($release->product); - $branches = array('' => '', BRANCH_MAIN => $this->lang->branch->main, $release->branch => $branches[$release->branch]); + $branch = $this->loadModel('branch')->getById($release->branch); + $branches = array('' => '', BRANCH_MAIN => $this->lang->branch->main, $release->branch => $branch->name); $this->config->product->search['params']['branch']['values'] = $branches; } $this->loadModel('search')->setSearchParams($this->config->product->search); @@ -549,8 +549,8 @@ class release extends control else { $this->config->bug->search['fields']['branch'] = $this->lang->product->branch; - $branches = $this->loadModel('branch')->getPairs($release->product); - $branches = array('' => '', BRANCH_MAIN => $this->lang->branch->main, $release->branch => $branches[$release->branch]); + $branch = $this->loadModel('branch')->getById($release->branch); + $branches = array('' => '', BRANCH_MAIN => $this->lang->branch->main, $release->branch => $branch->name); $this->config->bug->search['params']['branch']['values'] = $branches; } $this->loadModel('search')->setSearchParams($this->config->bug->search);