From 26f37ec09c6360bf249dad8b794fcd9c531b7f64 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 27 Jun 2022 15:38:33 +0800 Subject: [PATCH 1/4] * Finish task #58560. --- module/bug/control.php | 140 +++++++++++++++++++++-------- module/bug/js/common.js | 44 ++++++++- module/bug/js/create.js | 28 ------ module/bug/model.php | 7 +- module/bug/view/batchedit.html.php | 22 ++++- module/bug/view/browse.html.php | 3 + module/bug/view/edit.html.php | 2 +- module/project/control.php | 3 - 8 files changed, 172 insertions(+), 77 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 1d353355ac..db23d73b6a 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -553,14 +553,10 @@ class bug extends control $moduleOwner = $this->bug->getModuleOwner($moduleID, $productID); - /* Set team members of the latest execution as assignedTo list. */ - $productMembers = $this->bug->getProductMemberPairs($productID); + /* Get all project team members linked with this product. */ + $productMembers = $this->bug->getProductMemberPairs($productID, $branch); + $productMembers = array_filter($productMembers); if(empty($productMembers)) $productMembers = $this->view->users; - if($assignedTo and !isset($productMembers[$assignedTo])) - { - $user = $this->loadModel('user')->getById($assignedTo); - if($user) $productMembers[$assignedTo] = $user->realname; - } $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, ($branch === 'all' or !isset($branches[$branch])) ? 0 : $branch); if(empty($moduleOptionMenu)) return print(js::locate(helper::createLink('tree', 'browse', "productID=$productID&view=story"))); @@ -577,7 +573,7 @@ class bug extends control if($projectID) { $project = $this->loadModel('project')->getByID($projectID); - if(empty($bugID) or $this->app->tab != 'qa') $projects = array($projectID => $project->name); + if(empty($bugID) or $this->app->tab != 'qa') $projects += array($projectID => $project->name); } } elseif($projectID) @@ -1090,6 +1086,22 @@ class bug extends control $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $bug->branch); if(!isset($moduleOptionMenu[$bug->module])) $moduleOptionMenu += $this->tree->getModulesName($bug->module); + /* Get assigned to member. */ + if($bug->execution) + { + $assignedToList = $this->user->getTeamMemberPairs($bug->execution, 'execution'); + } + elseif($bug->project) + { + $assignedToList = $this->loadModel('project')->getTeamMemberPairs($bug->project); + } + else + { + $assignedToList = $this->bug->getProductMemberPairs($bug->product, $bug->branch); + $assignedToList = array_filter($assignedToList); + if(empty($assignedToList)) $assignedToList = $this->user->getPairs('devfirst|noclosed'); + } + $this->view->bug = $bug; $this->view->productID = $productID; $this->view->product = $product; @@ -1105,6 +1117,7 @@ class bug extends control $this->view->tasks = $this->task->getExecutionTaskPairs($bug->execution); $this->view->testtasks = $this->loadModel('testtask')->getPairs($bug->product, $bug->execution, $bug->testtask); $this->view->users = $this->user->getPairs('', "$bug->assignedTo,$bug->resolvedBy,$bug->closedBy,$bug->openedBy"); + $this->view->assignedToList = $assignedToList; $this->view->openedBuilds = $openedBuilds; $this->view->resolvedBuilds = array('' => '') + $openedBuilds + $oldResolvedBuild; $this->view->actions = $this->action->getList('bug', $bugID); @@ -1234,35 +1247,80 @@ class bug extends control $this->view->customFields = $customFields; $this->view->showFields = $this->config->bug->custom->batchEditFields; - /* Set users. */ - $appendUsers = array(); + $branchIdList = array(); + $projectIdList = array(); + $executionIdList = array(); foreach($bugs as $bug) { - $appendUsers[$bug->assignedTo] = $bug->assignedTo; - $appendUsers[$bug->resolvedBy] = $bug->resolvedBy; + $projectIdList[$bug->project] = $bug->project; + $executionIdList[$bug->execution] = $bug->execution; + + $branchIdList[$bug->product][$bug->branch] = $bug->branch; if(!isset($modules[$bug->product][$bug->branch])) $modules[$bug->product][$bug->branch] = $modules[$bug->product][0] + $this->tree->getModulesName($bug->module); } - $users = $this->user->getPairs('devfirst', $appendUsers, $this->config->maxCount); + + /* Get assigned to member. */ + $this->loadModel('project'); + $this->loadModel('execution'); + + $productMembers = array(); + $projectMembers = array(); + $executionMembers = array(); + if($productID) + { + $branchList = zget($branchIdList, $productID, array()); + foreach($branchList as $branchID) + { + $members = $this->bug->getProductMemberPairs($productID, $branchID); + $productMembers[$productID][$branchID] = array_filter($members); + } + } + else + { + foreach($productIdList as $id) + { + $branchList = zget($branchIdList, $id, array()); + foreach($branchList as $branchID) + { + $members = $this->bug->getProductMemberPairs($id, $branchID); + $productMembers[$id][$branchID] = array_filter($members); + } + } + } + + foreach($projectIdList as $projectID) + { + $projectMembers[$projectID] = $this->project->getTeamMemberPairs($projectID); + } + + foreach($executionIdList as $executionID) + { + $executionMembers[$executionID] = $this->user->getTeamMemberPairs($executionID, 'execution'); + } + + /* Set users. */ + $users = $this->user->getPairs('devfirst', '', $this->config->maxCount); $users = array('' => '', 'ditto' => $this->lang->bug->ditto) + $users; /* Assign. */ - $this->view->position[] = $this->lang->bug->common; - $this->view->position[] = $this->lang->bug->batchEdit; - $this->view->productID = $productID; - $this->view->branchProduct = $branchProduct; - $this->view->severityList = array('ditto' => $this->lang->bug->ditto) + $this->lang->bug->severityList; - $this->view->typeList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->typeList; - $this->view->priList = array('0' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->priList; - $this->view->resolutionList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->resolutionList; - $this->view->statusList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->statusList; - $this->view->osList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->osList; - $this->view->browserList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->browserList; - $this->view->bugs = $bugs; - $this->view->branch = $branch; - $this->view->users = $users; - $this->view->modules = $modules; - $this->view->branchTagOption = $branchTagOption; + $this->view->productID = $productID; + $this->view->branchProduct = $branchProduct; + $this->view->severityList = array('ditto' => $this->lang->bug->ditto) + $this->lang->bug->severityList; + $this->view->typeList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->typeList; + $this->view->priList = array('0' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->priList; + $this->view->resolutionList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->resolutionList; + $this->view->statusList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->statusList; + $this->view->osList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->osList; + $this->view->browserList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->browserList; + $this->view->bugs = $bugs; + $this->view->branch = $branch; + $this->view->users = $users; + $this->view->productMembers = $productMembers; + $this->view->projectMembers = $projectMembers; + $this->view->executionMembers = $executionMembers; + $this->view->modules = $modules; + $this->view->branchTagOption = $branchTagOption; $this->display(); } @@ -1320,17 +1378,20 @@ class bug extends control } } - if($this->app->tab == 'project') + /* Get assigned to member. */ + if($bug->execution) { - $users = $this->user->getTeamMemberPairs($bug->project, 'project', 'nodeleted', $bug->assignedTo); + $users = $this->user->getTeamMemberPairs($bug->execution, 'execution'); } - elseif($this->app->tab == 'execution') + elseif($bug->project) { - $users = $this->user->getTeamMemberPairs($bug->execution, 'execution', 'nodeleted', $bug->assignedTo); + $users = $this->loadModel('project')->getTeamMemberPairs($bug->project); } else { - $users = $this->user->getPairs('noclosed', $bug->assignedTo); + $users = $this->bug->getProductMemberPairs($bug->product, $bug->branch); + $users = array_filter($users); + if(empty($users)) $users = $this->user->getPairs('devfirst|noclosed'); } $this->view->title = $this->products[$bug->product] . $this->lang->colon . $this->lang->bug->assignedTo; @@ -2029,7 +2090,7 @@ class bug extends control */ public function ajaxLoadAssignedTo($executionID, $selectedUser = '') { - $executionMembers = $this->user->getTeamMemberPairs($executionID, 'execution', '', $selectedUser); + $executionMembers = $this->user->getTeamMemberPairs($executionID, 'execution'); $execution = $this->loadModel('execution')->getByID($executionID); if(empty($selectedUser)) $selectedUser = $execution->QD; @@ -2351,12 +2412,15 @@ class bug extends control * * @param int $productID * @param string $selectedUser + * @param int $branchID * @access public * @return string */ - public function ajaxGetProductMembers($productID, $selectedUser = '') + public function ajaxGetProductMembers($productID, $selectedUser = '', $branchID = '') { - $productMembers = $this->bug->getProductMemberPairs($productID); + $productMembers = $this->bug->getProductMemberPairs($productID, $branchID); + $productMembers = array_filter($productMembers); + if(empty($productMembers)) $productMembers = $this->loadModel('user')->getPairs('devfirst|noclosed'); return print(html::select('assignedTo', $productMembers, $selectedUser, 'class="form-control"')); } @@ -2365,7 +2429,7 @@ class bug extends control * Ajax get project team members. * * @param int $projectID - * @param string $$selectedUser + * @param string $selectedUser * @access public * @return string */ diff --git a/module/bug/js/common.js b/module/bug/js/common.js index 8410c771b3..0bf2d55c71 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -130,6 +130,7 @@ function loadBranch() loadProductBuilds(productID); loadProductplans(productID); loadProductStories(productID); + loadProductMembers(productID); } /** @@ -333,12 +334,44 @@ function loadProductExecutions(productID, projectID = 0) $(this).find('select').chosen(); if(typeof(bugExecution) == 'string' && systemMode != 'classic') $('#executionIdBox').prepend("" + bugExecution + ""); if(required) $(this).find('#execution_chosen').addClass('required'); - if(page != 'edit') changeAssignedTo(projectID); + changeAssignedTo(projectID); }); projectID != 0 ? loadProjectBuilds(projectID) : loadProductBuilds(productID); } +/** + * Ajax change execution name. + * + * @param int $projectID + * @access public + * @return void + */ +function changeAssignedTo(projectID) +{ + if(parseInt(projectID)) + { + loadProjectTeamMembers(projectID); + if(page == 'create') + { + var link = createLink('bug', 'ajaxGetExecutionLang', 'projectID=' + projectID); + $.post(link, function(executionLang) + { + $('#executionBox').html(executionLang); + }) + } + } + else if($('#execution').val() != 0) + { + loadAssignedTo($('#execution').val()); + } + else + { + var productID = $('#product').val(); + loadProductMembers(productID); + } +} + /** * Load executions of product and project. * @@ -441,13 +474,13 @@ function loadExecutionRelated(executionID) } else { - var currentProjectID = $('#project').val(); + var currentProjectID = $('#project').val() == 'undefined' ? 0 : $('#project').val(); var currentProductID = $('#product').val(); $('#taskIdBox').innerHTML = ''; // Reset the task. loadProductStories(currentProductID); loadTestTasks(currentProductID); - if(typeof(currentProjectID) == 'undefined') + if(currentProjectID == 0) { loadProductMembers(currentProductID); } @@ -593,7 +626,9 @@ function loadExecutionBuilds(executionID, num) */ function loadProductMembers(productID) { - link = createLink('bug', 'ajaxGetProductMembers', 'productID=' + productID + '&selectedUser=' + $('#assignedTo').val()); + var branchID = $('#branch').val() == undefined ? '' : $('#branch').val(); + + var link = createLink('bug', 'ajaxGetProductMembers', 'productID=' + productID + '&selectedUser=' + $('#assignedTo').val() + '&branchID=' + branchID); $.get(link, function(data) { if(!data) data = ''; @@ -678,6 +713,7 @@ function loadProductBranches(productID, param) loadProductProjects(productID); loadProductplans(productID); loadProductStories(productID); + loadProductMembers(productID); }) } diff --git a/module/bug/js/create.js b/module/bug/js/create.js index 68d406da31..b804a98e40 100644 --- a/module/bug/js/create.js +++ b/module/bug/js/create.js @@ -125,34 +125,6 @@ $(function() }); }); -/** - * Ajax change execution name. - * - * @param int $projectID - * @access public - * @return void - */ -function changeAssignedTo(projectID) -{ - if(parseInt(projectID)) - { - loadProjectTeamMembers(projectID); - var link = createLink('bug', 'ajaxGetExecutionLang', 'projectID=' + projectID); - $.post(link, function(executionLang) - { - $('#executionBox').html(executionLang); - }) - } - else if($('#execution').val() != 0) - { - loadAssignedTo($('#execution').val()); - } - else - { - setAssignedTo(); - } -} - $(window).unload(function(){ if(blockID) window.parent.refreshBlock($('#block' + blockID)); }); diff --git a/module/bug/model.php b/module/bug/model.php index ef747cb7ef..236f66bef3 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -460,6 +460,8 @@ class bugModel extends model echo(js::alert($this->lang->bug->executionAccessDenied)); $loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login"; if(strpos($this->server->http_referer, $loginLink) !== false) return print(js::locate(helper::createLink('bug', 'index', ''))); + if($this->app->tab == 'my') print(js::reload('parent')); + return print(js::locate('back')); } } @@ -1898,14 +1900,15 @@ class bugModel extends model * get Product member pairs. * * @param int $productID + * @param int $branchID * @access public * @return void */ - public function getProductMemberPairs($productID) + public function getProductMemberPairs($productID, $branchID = '') { if(defined('TUTORIAL')) return $this->loadModel('tutorial')->getTeamMembersPairs(); - $projects = $this->loadModel('product')->getProjectPairsByProduct($productID); + $projects = $this->loadModel('product')->getProjectPairsByProduct($productID, $branchID); $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') diff --git a/module/bug/view/batchedit.html.php b/module/bug/view/batchedit.html.php index 5a7252c532..c15db2a9b3 100644 --- a/module/bug/view/batchedit.html.php +++ b/module/bug/view/batchedit.html.php @@ -102,7 +102,27 @@ product][$bug->branch]) ? $modules[$bug->product][$bug->branch] : array(0 => '/'), $bug->module, "class='form-control picker-select' data-drop-width='auto'");?> ' style='overflow:visible'>plan, "class='form-control picker-select' data-drop-width='auto'");?> - ' style='overflow:visible'>assignedTo, "class='form-control picker-select' data-drop-width='auto'");?> + execution) + { + $assignedToList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $executionMembers[$bug->execution]; + } + elseif($bug->project) + { + $assignedToList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $projectMembers[$bug->project]; + } + else + { + $assignedToList = $productMembers[$bug->product][$bug->branch]; + if(empty($assignedToList)) + { + $assignedToList = $users; + unset($assignedToList['closed']); + } + } + ?> + ' style='overflow:visible'>assignedTo, "class='form-control picker-select' data-drop-width='135px'");?> ' style='overflow:visible'>deadline, "class='form-control form-date'");?> >os, 'class=form-control');?> >browser, 'class=form-control');?> diff --git a/module/bug/view/browse.html.php b/module/bug/view/browse.html.php index 1088484bd1..a6c5bae27a 100644 --- a/module/bug/view/browse.html.php +++ b/module/bug/view/browse.html.php @@ -490,6 +490,9 @@ $(function(){$('#bugForm').table();}) qa->homepage) and $config->qa->homepage != 'browse' and $config->global->flow == 'full'):?> $(function(){$('#modulemenu .nav li:last').after("
  • homepage?>
  • ")}); + +$('#bugForm .table-footer .table-actions #assignedTo').closest('.btn-group.dropup').removeClass('dropup').addClass('dropdown'); + function handleLinkButtonClick() { var xxcUrl = "xxc:openInApp/zentao-integrated/" + encodeURIComponent(window.location.href.replace(/.display=card/, '').replace(/\.xhtml/, '.html')); diff --git a/module/bug/view/edit.html.php b/module/bug/view/edit.html.php index 61d52d2fec..4d986c8e82 100644 --- a/module/bug/view/edit.html.php +++ b/module/bug/view/edit.html.php @@ -153,7 +153,7 @@ if($this->app->tab == 'project') js::set('objectID', $bug->project); bug->assignedTo;?>
    - assignedTo, "class='form-control chosen'");?> + assignedTo, "class='form-control chosen'");?> bug->allUsers, "class='btn btn-default' onclick='loadAllUsers()' data-toggle='tooltip'");?>
    diff --git a/module/project/control.php b/module/project/control.php index e62ada520e..d1f2b55358 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -1023,7 +1023,6 @@ class project extends control $pager = new pager($recTotal, $recPerPage, $pageID); $sort = common::appendOrder($orderBy); $bugs = $this->bug->getProjectBugs($projectID, $productID, $build, $type, $param, $sort, '', $pager); - $users = $this->user->getPairs('noletter'); /* team member pairs. */ $memberPairs = array(); @@ -1073,7 +1072,6 @@ class project extends control $this->view->buildID = $this->view->build ? $this->view->build->id : 0; $this->view->pager = $pager; $this->view->orderBy = $orderBy; - $this->view->users = $users; $this->view->productID = $productID; $this->view->project = $this->project->getById($projectID); $this->view->branchID = empty($this->view->build->branch) ? $branchID : $this->view->build->branch; @@ -1082,7 +1080,6 @@ class project extends control $this->view->param = $param; $this->view->builds = $this->loadModel('build')->getBuildPairs($productID); $this->view->users = $this->user->getPairs('noletter'); - $this->view->memberPairs = $this->user->getPairs('noletter|noclosed'); $this->view->branchOption = $branchOption; $this->view->branchTagOption = $branchTagOption; $this->view->executions = $executions; From 6be580345313fcdb0f864c8f31a3599aeded3dc6 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 28 Jun 2022 10:43:33 +0800 Subject: [PATCH 2/4] * Delete extra blank lines. --- module/bug/js/common.js | 1 - 1 file changed, 1 deletion(-) diff --git a/module/bug/js/common.js b/module/bug/js/common.js index 0bf2d55c71..166e71d0d1 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -627,7 +627,6 @@ function loadExecutionBuilds(executionID, num) function loadProductMembers(productID) { var branchID = $('#branch').val() == undefined ? '' : $('#branch').val(); - var link = createLink('bug', 'ajaxGetProductMembers', 'productID=' + productID + '&selectedUser=' + $('#assignedTo').val() + '&branchID=' + branchID); $.get(link, function(data) { From 3a380aee1db87d6af2f5746e0e15db0e5a8f324b Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 28 Jun 2022 11:23:20 +0800 Subject: [PATCH 3/4] * Finish task #58560.* Finish task #58560.* Finish task #58560.* Finish task #58560.* Finish task #58560.* Finish task #58560.* Finish task #58560.* Finish task #58560. --- module/bug/control.php | 18 ++++++++++++++++-- module/project/model.php | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index db23d73b6a..0c73dd434f 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1289,14 +1289,28 @@ class bug extends control } } + $projectMemberGroup = $this->project->getTeamMemberGroup($projectIdList); + $projectMembers = array(); foreach($projectIdList as $projectID) { - $projectMembers[$projectID] = $this->project->getTeamMemberPairs($projectID); + $projectTeam = zget($projectMemberGroup, $projectID, array()); + if(empty($projectTeam)) $projectMembers[$projectID] = array(); + foreach($projectTeam as $user) + { + $projectMembers[$projectID][$user->account] = $user->realname; + } } + $executionMemberGroup = $this->execution->getMembersByIdList($executionIdList); + $executionMembers = array(); foreach($executionIdList as $executionID) { - $executionMembers[$executionID] = $this->user->getTeamMemberPairs($executionID, 'execution'); + $executionTeam = zget($executionMemberGroup, $executionID, array()); + if(empty($executionTeam)) $executionMemberGroup[$executionID] = array(); + foreach($executionTeam as $user) + { + $executionMembers[$executionID][$user->account] = $user->realname; + } } /* Set users. */ diff --git a/module/project/model.php b/module/project/model.php index 5087ab26de..f70e233c57 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -2225,6 +2225,26 @@ class projectModel extends model return array('' => '') + $members; } + /** + * Get team member group. + * + * @param array|string $projectIdList + * @access public + * @return array + */ + public function getTeamMemberGroup($projectIdList) + { + if(empty($projectIdList)) return array(); + + return $this->dao->select("t1.account, if(t2.deleted='0', t2.realname, t1.account) as realname, t1.root as project")->from(TABLE_TEAM)->alias('t1') + ->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account') + ->where('t1.root')->in($projectIdList) + ->andWhere('t1.type')->eq('project') + ->andWhere('t2.deleted')->eq('0') + ->beginIF($this->config->vision)->andWhere("CONCAT(',', t2.visions, ',')")->like("%,{$this->config->vision},%")->fi() + ->fetchGroup('project', 'account'); + } + /** * Get members of a project who can be imported. * From 1cacd3245357f104062a6522fcb262eca9a7428c Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 28 Jun 2022 11:27:15 +0800 Subject: [PATCH 4/4] * Finish task #58560. --- module/bug/control.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 0c73dd434f..2e11fc511c 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1289,8 +1289,8 @@ class bug extends control } } - $projectMemberGroup = $this->project->getTeamMemberGroup($projectIdList); - $projectMembers = array(); + $projectMemberGroup = $this->project->getTeamMemberGroup($projectIdList); + $projectMembers = array(); foreach($projectIdList as $projectID) { $projectTeam = zget($projectMemberGroup, $projectID, array());