From a5d6663342680821722346af3497e75fd51fcc1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=8D=8E=E4=BC=9F?= Date: Mon, 18 Apr 2022 10:55:42 +0800 Subject: [PATCH] * Fix bug #20316. --- module/branch/control.php | 14 ++++---------- module/branch/model.php | 12 +++++++++++- module/tree/control.php | 4 ++-- module/tree/view/edit.html.php | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/module/branch/control.php b/module/branch/control.php index f779ad5497..d68b02f74f 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -257,20 +257,14 @@ class branch extends control * @access public * @return void */ - public function ajaxGetBranches($productID, $oldBranch = 0, $param = 'all', $projectID = 0, $withMainBranch = true) + public function ajaxGetBranches($productID, $oldBranch = 0, $param = '', $projectID = 0, $withMainBranch = true) { $product = $this->loadModel('product')->getById($productID); if(empty($product) or $product->type == 'normal') return; - $branches = $this->loadModel('branch')->getList($productID, $projectID, $param, 'order', null, $withMainBranch); - $branchOption = array(); - $branchTagOption = array(); - foreach($branches as $branchInfo) - { - $branchOption[$branchInfo->id] = $branchInfo->name; - $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - } - return print(html::select('branch', strpos($param, 'active') !== false ? $branchOption : $branchTagOption, $oldBranch, "class='form-control' onchange='loadBranch(this)'")); + $branches = $this->loadModel('branch')->getPairs($productID, $param); + + return print(html::select('branch', $branches, $oldBranch, "class='form-control' onchange='loadBranch(this)'")); } /** diff --git a/module/branch/model.php b/module/branch/model.php index 9d60ac7372..5ea7207c1f 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -96,7 +96,7 @@ class branchModel extends model * Get pairs. * * @param int $productID - * @param string $params + * @param string $params active|noempty|all|withClosed * @param int $executionID * @param string $mergedBranches * @access public @@ -141,6 +141,16 @@ class branchModel extends model { $branches = array('all' => $this->lang->branch->all) + $branches; } + + if(strpos($params, 'withClosed') !== false) + { + $closedBranches = $this->dao->select('id')->from(TABLE_BRANCH)->where('product')->eq($productID)->andWhere('status')->eq('closed')->fetchPairs(); + + if(!empty($closedBranches)) + { + foreach($closedBranches as $closedBranch) $branches[$closedBranch] .= ' (' . $this->lang->branch->statusList['closed'] . ')'; + } + } return $branches; } diff --git a/module/tree/control.php b/module/tree/control.php index c826a7df18..430eb4bcc8 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -58,7 +58,7 @@ class tree extends control if(!empty($product->type) && $product->type != 'normal') { - $branches = $this->loadModel('branch')->getPairs($product->id); + $branches = $this->loadModel('branch')->getPairs($product->id, 'withClosed'); if($currentModuleID) { $currentModuleBranch = $this->dao->select('branch')->from(TABLE_MODULE)->where('id')->eq($currentModuleID)->fetch('branch'); @@ -335,7 +335,7 @@ class tree extends control if($showProduct) { $product = $this->loadModel('product')->getById($module->root); - if($product->type != 'normal') $this->view->branches = $this->loadModel('branch')->getPairs($module->root, 'active'); + if($product->type != 'normal') $this->view->branches = $this->loadModel('branch')->getPairs($module->root, 'withClosed'); $this->view->product = $product; $this->view->products = $this->product->getPairs('', $product->program); } diff --git a/module/tree/view/edit.html.php b/module/tree/view/edit.html.php index e34672e2bc..e4018a81ca 100644 --- a/module/tree/view/edit.html.php +++ b/module/tree/view/edit.html.php @@ -160,7 +160,7 @@ function loadBranches(obj) var $inputGroup = $(obj).closest('.input-group'); $inputGroup.find('#branch').remove(); $inputGroup.find('#branch_chosen').remove(); - $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID), function(data) + $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID + "&oldBranch=0¶m=withClosed"), function(data) { if(data) {