From 4ffef413e99a384efac913a41e8ddfc5ccd36bc1 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Sun, 25 Apr 2021 11:42:32 +0800 Subject: [PATCH] * Fix bug assign logic. --- module/bug/control.php | 24 +++++++----------------- module/bug/js/common.js | 2 +- module/bug/js/create.js | 7 ++++++- module/bug/model.php | 23 +++++++++++++++++++++++ module/bug/view/create.html.php | 2 +- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 36b01fc533..d42ddb861f 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -502,14 +502,12 @@ class bug extends control $moduleOwner = $this->bug->getModuleOwner($moduleID, $productID); /* Set team members of the latest execution as assignedTo list. */ - $latestExecution = $this->product->getLatestProject($productID); - $executionMembers = array(); - if(!empty($latestExecution)) $executionMembers = $this->loadModel('user')->getTeamMemberPairs($latestExecution->id, 'execution', 'nodeleted', $moduleOwner); - if(empty($executionMembers)) $executionMembers = $this->view->users; - if($assignedTo and !isset($executionMembers[$assignedTo])) + $productMembers = $this->bug->getProductMemberPairs($productID); + if(empty($productMembers)) $productMembers = $this->view->users; + if($assignedTo and !isset($productMembers[$assignedTo])) { $user = $this->loadModel('user')->getById($assignedTo); - if($user) $executionMembers[$assignedTo] = $user->realname; + if($user) $productMembers[$assignedTo] = $user->realname; } $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $branch); @@ -583,7 +581,7 @@ class bug extends control $this->view->steps = htmlspecialchars($steps); $this->view->os = $os; $this->view->browser = $browser; - $this->view->executionMembers = $executionMembers; + $this->view->productMembers = $productMembers; $this->view->assignedTo = $assignedTo; $this->view->deadline = $deadline; $this->view->mailto = $mailto; @@ -1613,17 +1611,9 @@ class bug extends control */ public function ajaxLoadExecutionTeamMembers($productID, $selectedUser = '') { - $latestExecution = $this->product->getLatestProject($productID); - if(!empty($latestExecution)) - { - $executionMembers = $this->user->getTeamMemberPairs($latestExecution->id, 'execution', 'nodeleted', $selectedUser); - } - else - { - $executionMembers = $this->user->getPairs('devfirst|noclosed|nodeleted'); - } + $productMembers = $this->bug->getProductMemberPairs($productID); - die(html::select('assignedTo', $executionMembers, $selectedUser, 'class="form-control"')); + die(html::select('assignedTo', $productMembers, $selectedUser, 'class="form-control"')); } /** diff --git a/module/bug/js/common.js b/module/bug/js/common.js index 7a98073c2f..d5dbd1b402 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -60,7 +60,7 @@ function loadAll(productID) loadProductBuilds(productID); loadProductplans(productID); loadProductStories(productID); - loadTestTasks(productID); + //loadTestTasks(productID); } } diff --git a/module/bug/js/create.js b/module/bug/js/create.js index 1e6ce04b0c..6b7e64477e 100644 --- a/module/bug/js/create.js +++ b/module/bug/js/create.js @@ -29,7 +29,12 @@ function loadAllUsers() function loadExecutionTeamMembers(productID) { var link = createLink('bug', 'ajaxLoadExecutionTeamMembers', 'productID=' + productID + '&selectedUser=' + $('#assignedTo').val()); - $('#assignedToBox').load(link, function(){$('#assignedTo').chosen();}); + $.post(link, function(data) + { + $('#assignedTo').replaceWith(data); + $('#assignedTo_chosen').remove(); + $('#assignedTo').chosen(); + }) } /** diff --git a/module/bug/model.php b/module/bug/model.php index 2898b05dc5..152e1b545a 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1592,6 +1592,29 @@ class bugModel extends model return $bugs; } + public function getProductMemberPairs($productID) + { + $projects = $this->loadModel('product')->getProjectPairsByProduct($productID); + + $users = $this->dao->select("t2.id, t2.account, t2.realname")->from(TABLE_TEAM)->alias('t1') + ->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account') + ->where('t1.root')->in(array_keys($projects)) + ->andWhere('t1.type')->eq('project') + ->andWhere('t2.deleted')->eq(0) + ->fi() + ->fetchAll('account'); + + if(!$users) return array('' => ''); + + foreach($users as $account => $user) + { + $firstLetter = ucfirst(substr($user->account, 0, 1)) . ':'; + if(!empty($this->config->isINT)) $firstLetter = ''; + $users[$account] = $firstLetter . ($user->realname ? $user->realname : $user->account); + } + return array('' => '') + $users; + } + /** * Get bugs according to buildID and productID. * diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php index 66253714df..eb8f6ca079 100644 --- a/module/bug/view/create.html.php +++ b/module/bug/view/create.html.php @@ -129,7 +129,7 @@ js::set('blockID', $blockID);