From c45326cca4badce63de5af934b992437b3b51cd4 Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Wed, 21 Oct 2015 10:32:07 +0800 Subject: [PATCH] * finish task #2359. --- module/bug/control.php | 32 ++++++++++++++++++++++++++++---- module/bug/js/create.js | 14 +++++++++++++- module/bug/lang/zh-cn.php | 1 + module/bug/view/create.html.php | 3 ++- module/product/model.php | 21 +++++++++++++++++++++ 5 files changed, 65 insertions(+), 6 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index cf7613ad98..d506a5d7f8 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -317,6 +317,17 @@ class bug extends control $stories = $this->story->getProductStoryPairs($productID); } + /* Set team members of the latest project as assignedTo list. */ + $latestProjectID = $this->product->getLatestProject($productID); + if(!empty($latestProjectID)) + { + $projectMembers = $this->loadModel('project')->getTeamMemberPairs($latestProjectID, 'nodeleted'); + } + else + { + $projectMembers = $this->view->users; + } + $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->create; $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]); $this->view->position[] = $this->lang->bug->create; @@ -340,6 +351,7 @@ class bug extends control $this->view->steps = htmlspecialchars($steps); $this->view->os = $os; $this->view->browser = $browser; + $this->view->projectMembers = $projectMembers; $this->view->assignedTo = $assignedTo; $this->view->mailto = $mailto; $this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote'); @@ -1028,7 +1040,7 @@ class bug extends control } /** - * AJAX: get assignedTo list, make sure the members of the project at the first. + * AJAX: get team members of the project as assignedTo list. * * @param int $projectID * @param string $selectedUser @@ -1037,11 +1049,23 @@ class bug extends control */ public function ajaxLoadAssignedTo($projectID, $selectedUser = '') { - $allUsers = $this->loadModel('user')->getPairs('nodeleted, devfirst'); $projectMembers = $this->loadModel('project')->getTeamMemberPairs($projectID); - $assignedToList = array_merge($projectMembers, $allUsers); - die(html::select('assignedTo', $assignedToList, $selectedUser, 'class="form-control"')); + die(html::select('assignedTo', $projectMembers, $selectedUser, 'class="form-control"')); + } + + /** + * AJAX: get all users as assignedTo list. + * + * @param string $selectedUser + * @access public + * @return string + */ + public function ajaxLoadAllUsers($selectedUser = '') + { + $allUsers = $this->loadModel('user')->getPairs('nodeleted, devfirst'); + + die(html::select('assignedTo', $allUsers, $selectedUser, 'class="form-control"')); } /** diff --git a/module/bug/js/create.js b/module/bug/js/create.js index c964160a86..3a38d8b89a 100644 --- a/module/bug/js/create.js +++ b/module/bug/js/create.js @@ -1,5 +1,5 @@ /** - * Load assginedTo list, make use the members of this project at first. + * Load team members of the project as assignedTo list. * * @param int $projectID * @access public @@ -11,6 +11,18 @@ function loadAssignedTo(projectID) $('#assignedToBox').load(link, function(){$('#assignedTo').chosen(defaultChosenOptions);}); } +/** + * Load all users as assignedTo list. + * + * @access public + * @return void + */ +function loadAllUsers() +{ + link = createLink('bug', 'ajaxLoadAllUsers', 'selectedUser=' + $('#assignedTo').val()); + $('#assignedToBox').load(link, function(){$('#assignedTo').chosen(defaultChosenOptions);}); +} + /** * load assignedTo and stories of module. * diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php index 48e2f8227f..3e981aad0d 100644 --- a/module/bug/lang/zh-cn.php +++ b/module/bug/lang/zh-cn.php @@ -129,6 +129,7 @@ $lang->bug->lblLastEdited = '最后修改'; $lang->bug->lblResolved = '由谁解决'; $lang->bug->lblAllFields = '所有字段'; $lang->bug->lblCustomFields = '自定义字段'; +$lang->bug->allUsers = '所有用户'; /* legend列表。*/ $lang->bug->legendBasicInfo = '基本信息'; diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php index bdf27ba64b..0326986bdb 100644 --- a/module/bug/view/create.html.php +++ b/module/bug/view/create.html.php @@ -64,7 +64,8 @@ js::set('refresh', $lang->refresh); bug->lblAssignedTo;?> - + + bug->allUsers, "onclick='loadAllUsers()'");?> bug->type;?> diff --git a/module/product/model.php b/module/product/model.php index d2b851e951..9b6572ad90 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -711,4 +711,25 @@ class productModel extends model $this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($newOrder)->where('id')->eq($id)->exec(); } } + + /** + * get the latest project of the product. + * + * @param int $productID + * @access public + * @return int + */ + public function getLatestProject($productID) + { + $projectList = array_keys($this->loadModel('project')->getPairs()); + $projects = $this->dao->select('t2.id, t2.name, t2.begin') + ->from(TABLE_PROJECTPRODUCT)->alias('t1')->leftJoin(TABLE_PROJECT)->alias('t2') + ->on('t1.project = t2.id') + ->where('t1.product')->eq((int)$productID) + ->andWhere('t2.id')->in($projectList) + ->orderBy('t2.begin desc') + ->fetchAll('id'); + + return key($projects); + } }