From 4347cc014e468f6eda452c833dd573d145d85f05 Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Tue, 6 Jul 2021 13:16:39 +0800 Subject: [PATCH] * Fix bug#13385. --- module/bug/control.php | 15 +++++++++++++++ module/bug/js/common.js | 21 +++++++++++++++++++++ module/bug/js/create.js | 17 +++++++++++++++-- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 415c6e1118..04d34e3611 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1919,4 +1919,19 @@ class bug extends control $this->view->lines = $this->product->getLinePairs(); $this->display(); } + + /** + * Ajax get project team members. + * + * @param int $projectID + * @access public + * @return void + */ + public function ajaxGetProjectTeamMembers($projectID) + { + $users = $this->loadModel('user')->getPairs('noclosed'); + $teamMembers = empty($projectID) ? array() : $this->loadModel('project')->getTeamMemberPairs($projectID); + foreach($teamMembers as $account => $member) $teamMembers[$account] = $users[$account]; + die(html::select('assignedTo', $teamMembers, '', 'class="form-control"')); + } } diff --git a/module/bug/js/common.js b/module/bug/js/common.js index f44f92dd95..21b9e0fdd8 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -343,6 +343,7 @@ function loadProductBuilds(productID) */ function loadExecutionRelated(executionID) { + executionID = parseInt(executionID); if(executionID) { loadExecutionTasks(executionID); @@ -357,6 +358,7 @@ function loadExecutionRelated(executionID) loadProductStories($('#product').val()); loadProductBuilds($('#product').val()); loadTestTasks($('#product').val()); + loadProjectTeamMembers($('#project').val()); } } @@ -435,6 +437,25 @@ function loadExecutionBuilds(executionID) } } +/** + * Load project members. + * + * @param projectID $projectID + * @access public + * @return void + */ +function loadProjectTeamMembers(projectID) +{ + link = createLink('bug', 'ajaxGetProjectTeamMembers', 'projectID=' + projectID); + $.get(link, function(data) + { + if(!data) data = ''; + $('#assignedTo').replaceWith(data); + $('#assignedTo_chosen').remove(); + $("#assignedTo").chosen(); + }); +} + /** * Set story field. * diff --git a/module/bug/js/create.js b/module/bug/js/create.js index b602586a0a..c9cdc7d5ec 100644 --- a/module/bug/js/create.js +++ b/module/bug/js/create.js @@ -103,11 +103,18 @@ $(function() oldOpenedBuild = ''; oldTaskID = $('#oldTaskID').val() || 0; - if($('#execution').val()) loadExecutionRelated($('#execution').val()); + if(parseInt($('#execution').val())) + { + loadExecutionRelated($('#execution').val()); + } + else + { + if(parseInt($('#project').val())) loadProjectTeamMembers($('#project').val()); + } + if(!assignedto) setTimeout(function(){setAssignedTo(moduleID, productID)}, 500); notice(); - $('[data-toggle=tooltip]').tooltip(); /* Adjust size of bug type input group. */ @@ -150,6 +157,12 @@ $(function() return false; } }); + + $('#project').change(function() + { + var projectID = parseInt($(this).val()); + projectID ? loadProjectTeamMembers(projectID) : loadExecutionTeamMembers($('#product').val()); + }); }); $(window).unload(function(){