From e9f357731b81885b6ab6ffa68a6f49bae4ea1ac8 Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Tue, 18 Dec 2012 12:28:45 +0000 Subject: [PATCH] * when first load, make sure dev users at first. * when a project selected, make sure members of this project at first. --- module/bug/control.php | 19 ++++++++++++- module/bug/js/create.js | 50 ++++++++++++++++++++++----------- module/bug/view/create.html.php | 2 +- 3 files changed, 53 insertions(+), 18 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index fe8f8034d9..05a53f6385 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -213,7 +213,7 @@ class bug extends control */ public function create($productID, $extras = '') { - $this->view->users = $this->user->getPairs('nodeleted'); + $this->view->users = $this->user->getPairs('nodeleted,devfirst'); if(empty($this->products)) $this->locate($this->createLink('product', 'create')); if(!empty($_POST)) @@ -840,6 +840,23 @@ class bug extends control die($owner); } + /** + * AJAX: get assignedTo list, make sure the members of the project at the first. + * + * @param int $projectID + * @param string $selectedUser + * @access public + * @return string + */ + 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="select-3"')); + } + /** * Send email. * diff --git a/module/bug/js/create.js b/module/bug/js/create.js index deeb12e44d..558efbd753 100644 --- a/module/bug/js/create.js +++ b/module/bug/js/create.js @@ -82,6 +82,7 @@ function loadProjectRelated(projectID) loadProjectTasks(projectID); loadProjectStories(projectID); loadProjectBuilds(projectID); + loadAssignedTo(projectID); } else { @@ -118,18 +119,16 @@ function loadProjectStories(projectID) } /** - * Set the assignedTo field. + * Load assginedTo list, make use the members of this project at first. * + * @param int $projectID * @access public * @return void */ -function setAssignedTo() +function loadAssignedTo(projectID) { - link = createLink('bug', 'ajaxGetModuleOwner', 'moduleID=' + $('#module').val() + '&productID=' + $('#product').val()); - $.get(link, function(owner) - { - $('#assignedTo').val(owner); - }); + link = createLink('bug', 'ajaxLoadAssignedTo', 'projectID=' + projectID + '&selectedUser=' + $('#assignedTo').val()); + $('#assignedToBox').load(link) } /** @@ -147,18 +146,29 @@ function loadProjectBuilds(projectID) $('#buildBox').load(link); } -$(function() { - $("#story").chosen({no_results_text:noResultsMatch}); - $("#task").chosen({no_results_text:noResultsMatch}); - $("#mailto").autocomplete(userList, { multiple: true, mustMatch: true}); - setAssignedTo(); -}) +/** + * Set the assignedTo field. + * + * @access public + * @return void + */ +function setAssignedTo() +{ + link = createLink('bug', 'ajaxGetModuleOwner', 'moduleID=' + $('#module').val() + '&productID=' + $('#product').val()); + $.get(link, function(owner) + { + $('#assignedTo').val(owner); + }); +} /* Save template. */ -KindEditor.plugin('savetemplate', function(K) { +KindEditor.plugin('savetemplate', function(K) +{ var self = this, name = 'savetemplate'; - self.plugin.savetemplate = { - click: function(id) { + self.plugin.savetemplate = + { + click: function(id) + { content = self.html(); jPrompt(setTemplateTitle, '','', function(r) { @@ -189,3 +199,11 @@ function deleteTemplate(templateID) hiddenwin.location.href = createLink('bug', 'deleteTemplate', 'templateID=' + templateID); $('#tplBox' + templateID).addClass('hidden'); } + +$(function() +{ + $("#story").chosen({no_results_text:noResultsMatch}); + $("#task").chosen({no_results_text:noResultsMatch}); + $("#mailto").autocomplete(userList, { multiple: true, mustMatch: true}); + setAssignedTo(); +}) diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php index f4dceb3db7..0afb3cf5f0 100644 --- a/module/bug/view/create.html.php +++ b/module/bug/view/create.html.php @@ -42,7 +42,7 @@ userList = "".split(','); bug->lblAssignedTo;?> - + bug->title;?>