From 834aee0f273626babbbe5c27cc61f22d5dcbca8f Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Tue, 3 Nov 2015 16:58:32 +0800 Subject: [PATCH 1/4] * adjust the code. --- module/bug/control.php | 12 ++++++------ module/product/model.php | 15 ++++++--------- module/report/control.php | 8 +++++--- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 31235a9572..4f30e9046f 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -330,10 +330,10 @@ class bug extends control } /* Set team members of the latest project as assignedTo list. */ - $latestProjectID = $this->product->getLatestProject($productID); - if(!empty($latestProjectID)) + $latestProject = $this->product->getLatestProject($productID); + if(!empty($latestProject)) { - $projectMembers = $this->loadModel('project')->getTeamMemberPairs($latestProjectID, 'nodeleted'); + $projectMembers = $this->loadModel('project')->getTeamMemberPairs($latestProject->id, 'nodeleted'); } else { @@ -1102,10 +1102,10 @@ class bug extends control */ public function ajaxLoadProjectTeamMembers($productID, $selectedUser = '') { - $latestProjectID = $this->product->getLatestProject($productID); - if(!empty($latestProjectID)) + $latestProject = $this->product->getLatestProject($productID); + if(!empty($latestProject)) { - $projectMembers = $this->loadModel('project')->getTeamMemberPairs($latestProjectID, 'nodeleted'); + $projectMembers = $this->loadModel('project')->getTeamMemberPairs($latestProject->id, 'nodeleted'); } else { diff --git a/module/product/model.php b/module/product/model.php index 72385a407d..29dd68ed6d 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -742,19 +742,16 @@ class productModel extends model * * @param int $productID * @access public - * @return int + * @return object */ public function getLatestProject($productID) { - $projectList = array_keys($this->loadModel('project')->getPairs('noclosed')); - $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') + return $this->dao->select('t2.id, t2.name')->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) + ->andWhere('t2.status')->ne('done') ->orderBy('t2.begin desc') - ->fetchAll('id'); - - return key($projects); + ->limit(1) + ->fetch(); } } diff --git a/module/report/control.php b/module/report/control.php index c5281caf05..5eb3deeee2 100644 --- a/module/report/control.php +++ b/module/report/control.php @@ -128,9 +128,11 @@ class report extends control $begin = $begin ? date('Y-m-d', strtotime($begin)) : date('Y-m-d', strtotime('now')); $end = $end ? date('Y-m-d', strtotime($end)) : date('Y-m-d', strtotime('+1 week')); - $diffDays = helper::diffDate($end, $begin); - $diffDays = round($diffDays - ($diffDays / 7 * 2)); - $days = $days ? $days : $diffDays; + if(!$days) + { + $diffDays = helper::diffDate($end, $begin); + $days = round($diffDays - ($diffDays / 7 * 2)); + } $this->view->title = $this->lang->report->workload; $this->view->position[] = $this->lang->report->workload; From 8b082953d02e716afa5778822e1fef3e99a0c2ec Mon Sep 17 00:00:00 2001 From: chujilu Date: Wed, 4 Nov 2015 09:35:30 +0800 Subject: [PATCH 2/4] * Fix bug of sso login 302 url. --- module/sso/control.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/sso/control.php b/module/sso/control.php index 9db9f65f45..7c738193b1 100644 --- a/module/sso/control.php +++ b/module/sso/control.php @@ -21,7 +21,7 @@ class sso extends control public function login($type = 'notify') { $referer = empty($_GET['referer']) ? '' : $this->get->referer; - $locate = empty($referer) ? '/' : base64_decode($referer); + $locate = empty($referer) ? getWebRoot() : base64_decode($referer); if($this->loadModel('user')->isLogon()) die($this->locate($locate)); $this->app->loadConfig('sso'); From a46563dadeec0d6181e6c45cb21cbf3845e79e67 Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Wed, 4 Nov 2015 10:23:20 +0800 Subject: [PATCH 3/4] * adjust the code for task #2357 2358. --- module/bug/control.php | 12 +++---- module/bug/js/common.js | 19 ++++++----- module/build/control.php | 74 +++++++++++++++------------------------- 3 files changed, 41 insertions(+), 64 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 4f30e9046f..eaca227cc6 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -551,15 +551,14 @@ class bug extends control $this->view->position[] = $this->lang->bug->edit; /* Assign. */ + $allBuilds = $this->loadModel('build')->getProductBuildPairs($productID, $branch = 0, 'noempty'); if($projectID) { - $openedBuilds = $this->loadModel('build')->getProjectBuildPairs($projectID, $productID, $bug->branch, 'noempty,noterminate,nodone'); - $allBuilds = $this->loadModel('build')->getProjectBuildPairs($projectID, $productID, $branch = 0, 'noempty'); + $openedBuilds = $this->build->getProjectBuildPairs($projectID, $productID, $bug->branch, 'noempty,noterminate,nodone'); } else { - $openedBuilds = $this->loadModel('build')->getProductBuildPairs($productID, $bug->branch, 'noempty,noterminate,nodone'); - $allBuilds = $this->loadModel('build')->getProductBuildPairs($productID, $branch = 0, 'noempty'); + $openedBuilds = $this->build->getProductBuildPairs($productID, $bug->branch, 'noempty,noterminate,nodone'); } /* Set the openedBuilds list. */ @@ -573,10 +572,7 @@ class bug extends control /* Set the resolvedBuilds list. */ $oldResolvedBuild = array(); - if($bug->resolvedBuild) - { - if(isset($allBuilds[$bug->resolvedBuild])) $oldResolvedBuild[$bug->resolvedBuild] = $allBuilds[$bug->resolvedBuild]; - } + if(($bug->resolvedBuild) and isset($allBuilds[$bug->resolvedBuild])) $oldResolvedBuild[$bug->resolvedBuild] = $allBuilds[$bug->resolvedBuild]; $this->view->bug = $bug; $this->view->productID = $productID; diff --git a/module/bug/js/common.js b/module/bug/js/common.js index 86b2836304..2b8f9175d3 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -84,7 +84,8 @@ function loadAllBuilds(that) { if(page == 'resolve') { - link = createLink('build', 'ajaxGetAllProductBuilds', 'productID=' + productID + '&varName=resolvedBuild&build'); + oldResolvedBuild = $('#resolvedBuild').val() ? $('#resolvedBuild').val() : 0; + link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=0&index=0&type=all'); $('#resolvedBuildBox').load(link, function(){$(this).find('select').chosen(defaultChosenOptions)}); } else @@ -119,20 +120,20 @@ function loadAllProjectBuilds(projectID, productID) if(page == 'create') { oldOpenedBuild = $('#openedBuild').val() ? $('#openedBuild').val() : 0; - link = createLink('build', 'ajaxGetAllProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch); + link = createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&needCreate=true&type=all'); $('#buildBox').load(link, function(){ notice(); $('#openedBuild').chosen(defaultChosenOptions);}); } if(page == 'edit') { if(buildBox == 'openedBuildBox') { - link = createLink('build', 'ajaxGetAllProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch); + link = createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&needCreate=true&type=all'); $('#openedBuildBox').load(link, function(){$(this).find('select').chosen(defaultChosenOptions)}); } if(buildBox == 'resolvedBuildBox') { - buildLink = createLink('build', 'ajaxGetAllProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild); - $('#resolvedBuildBox').load(buildLink, function(){$(this).find('select').chosen(defaultChosenOptions)}); + link = createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=0&index=0&needCreate=true&type=all'); + $('#resolvedBuildBox').load(link, function(){$(this).find('select').chosen(defaultChosenOptions)}); } } } @@ -150,20 +151,20 @@ function loadAllProductBuilds(productID) if(typeof(branch) == 'undefined') branch = 0; if(page == 'create') { - link = createLink('build', 'ajaxGetAllProductBuilds', 'productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch); + link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&type=all'); $('#buildBox').load(link, function(){ notice(); $('#openedBuild').chosen(defaultChosenOptions);}); } if(page == 'edit') { if(buildBox == 'openedBuildBox') { - link = createLink('build', 'ajaxGetAllProductBuilds', 'productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch); + link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&type=all'); $('#openedBuildBox').load(link, function(){$(this).find('select').chosen(defaultChosenOptions)}); } if(buildBox == 'resolvedBuildBox') { - buildLink = createLink('build', 'ajaxGetAllProductBuilds', 'productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild); - $('#resolvedBuildBox').load(buildLink, function(){$(this).find('select').chosen(defaultChosenOptions)}); + link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=0&index=0&type=all'); + $('#resolvedBuildBox').load(link, function(){$(this).find('select').chosen(defaultChosenOptions)}); } } } diff --git a/module/build/control.php b/module/build/control.php index 137d5005e2..54081658a1 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -201,15 +201,25 @@ class build extends control * @param int $productID * @param string $varName the name of the select object to create * @param string $build build to selected + * @param int $branch * @param int $index the index of batch create bug. + * @param string $type get all builds or some builds belong to normal releases and projects are not done. * @access public * @return string */ - public function ajaxGetProductBuilds($productID, $varName, $build = '', $branch = 0, $index = 0) + public function ajaxGetProductBuilds($productID, $varName, $build = '', $branch = 0, $index = 0, $type = 'normal') { - if($varName == 'openedBuild' ) die(html::select($varName . '[]', $this->build->getProductBuildPairs($productID, $branch, 'noempty,release,noterminate,nodone'), $build, 'size=4 class=form-control multiple')); - if($varName == 'openedBuilds' ) die(html::select($varName . "[$index][]", $this->build->getProductBuildPairs($productID, $branch, 'noempty,release'), $build, 'size=4 class=form-control multiple')); - if($varName == 'resolvedBuild') die(html::select($varName, $this->build->getProductBuildPairs($productID, $branch, 'noempty,release,noterminate,nodone'), $build, "class='form-control'")); + if($varName == 'openedBuild' ) + { + $params = ($type == 'all') ? 'noempty' : 'noempty, noterminate, nodone'; + die(html::select($varName . '[]', $this->build->getProductBuildPairs($productID, $branch, $params), $build, 'size=4 class=form-control multiple')); + } + if($varName == 'openedBuilds' ) die(html::select($varName . "[$index][]", $this->build->getProductBuildPairs($productID, $branch, 'noempty'), $build, 'size=4 class=form-control multiple')); + if($varName == 'resolvedBuild') + { + $params = ($type == 'all') ? '' : 'noempty, noterminate, nodone'; + die(html::select($varName, $this->build->getProductBuildPairs($productID, $branch, $params), $build, "class='form-control'")); + } } /** @@ -218,61 +228,31 @@ class build extends control * @param int $projectID * @param string $varName the name of the select object to create * @param string $build build to selected + * @param int $branch * @param int $index the index of batch create bug. * @param bool $needCreate if need to append the link of create build + * @param string $type get all builds or some builds belong to normal releases and projects are not done. * @access public * @return string */ - public function ajaxGetProjectBuilds($projectID, $productID, $varName, $build = '', $branch = 0, $index = 0, $needCreate = false) + public function ajaxGetProjectBuilds($projectID, $productID, $varName, $build = '', $branch = 0, $index = 0, $needCreate = false, $type = 'normal') { if($varName == 'openedBuild') { - $builds = $this->build->getProjectBuildPairs($projectID, $productID, $branch, 'noempty,release,noterminate,nodone'); - $output = html::select($varName . '[]', $builds , $build, 'size=4 class=form-control multiple'); - die($output); + $params = ($type == 'all') ? 'noempty' : 'noempty, noterminate, nodone'; + $builds = $this->build->getProjectBuildPairs($projectID, $productID, $branch, $params); + die(html::select($varName . '[]', $builds , $build, 'size=4 class=form-control multiple')); + } + if($varName == 'openedBuilds') die(html::select($varName . "[$index][]", $this->build->getProjectBuildPairs($projectID, $productID, $branch, 'noempty'), $build, 'size=4 class=form-control multiple')); + if($varName == 'resolvedBuild') + { + $params = ($type == 'all') ? '' : 'noempty, noterminate, nodone'; + die(html::select($varName, $this->build->getProjectBuildPairs($projectID, $productID, $branch, $params), $build, "class='form-control'")); } - if($varName == 'openedBuilds') die(html::select($varName . "[$index][]", $this->build->getProjectBuildPairs($projectID, $productID, $branch, 'noempty'), $build, 'size=4 class=form-control multiple')); - if($varName == 'resolvedBuild') die(html::select($varName, $this->build->getProjectBuildPairs($projectID, $productID, $branch, 'noempty,noterminate,nodone'), $build, "class='form-control'")); if($varName == 'testTaskBuild') die(html::select('build', $this->build->getProjectBuildPairs($projectID, $productID, $branch, 'noempty'), $build, "class='form-control'")); } - /** - * AJAX: get all builds of a product in html select. - * - * @param int $productID - * @param string $varName the name of the select object to create - * @param string $build build to selected - * @access public - * @return string - */ - public function ajaxGetAllProductBuilds($productID, $varName, $build = '', $branch = 0) - { - if($varName == 'openedBuild' ) die(html::select($varName . '[]', $this->build->getProductBuildPairs($productID, $branch, 'noempty'), $build, 'size=4 class=form-control multiple')); - if($varName == 'resolvedBuild') die(html::select($varName, $this->build->getProductBuildPairs($productID, $branch), $build, "class='form-control'")); - } - - /** - * AJAX: get all builds of a project in html select. - * - * @param int $projectID - * @param int $productID - * @param string $varName the name of the select object to create - * @param string $build build to selected - * @access public - * @return string - */ - public function ajaxGetAllProjectBuilds($projectID, $productID, $varName, $build = '', $branch = 0) - { - if($varName == 'openedBuild') - { - $builds = $this->build->getProjectBuildPairs($projectID, $productID, $branch, 'noempty'); - $output = html::select($varName . '[]', $builds , $build, 'size=4 class=form-control multiple'); - die($output); - } - if($varName == 'resolvedBuild') die(html::select($varName, $this->build->getProjectBuildPairs($projectID, $productID, $branch), $build, "class='form-control'")); - } - - /** + /** * AJAX: get builds of a branch in html select. * * @param int $productID From 85cbdbb6b718a488af39a4b1a9a3a4ffd2a54985 Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Wed, 4 Nov 2015 10:59:19 +0800 Subject: [PATCH 4/4] * adjust the code. --- module/bug/css/browse.css | 13 ++++--------- module/bug/js/browse.js | 22 ++++------------------ module/bug/view/browse.html.php | 8 ++++---- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/module/bug/css/browse.css b/module/bug/css/browse.css index 99c40aca21..8a01602e3b 100644 --- a/module/bug/css/browse.css +++ b/module/bug/css/browse.css @@ -5,12 +5,7 @@ .confirm1 {color:green; font-size:9px} .red{color:red;} -.assign-menu {min-width: 150px; overflow: hidden; max-height: 305px} -.assign-menu.with-search {padding-bottom: 34px;} -.assign-menu > .assign-search {padding: 0; position: absolute; z-index: 0; bottom: 0; left: 0; right: 0} -.assign-menu > .assign-search .input-group-addon {position: absolute; right: 10px; top: 0; z-index: 10; background: none; border: none; color: #666} - -.fix-menu {min-width: 150px; overflow: hidden} -.fix-menu.with-search {padding-bottom: 35px;} -.fix-menu > .fix-search {padding: 0; position: absolute; z-index: 0; bottom: 0; left: 0; right: 0} -.fix-menu > .fix-search .input-group-addon {position: absolute; right: 10px; top: 0; z-index: 10; background: none; border: none; color: #666} +.dropdown-menu.with-search {padding-bottom: 34px; min-width: 150px; overflow: hidden; max-height: 305px} +.dropdown-menu > .menu-search {padding: 0; position: absolute; z-index: 0; bottom: 0; left: 0; right: 0} +.dropdown-menu > .menu-search .input-group {width:100%;} +.dropdown-menu > .menu-search .input-group-addon {position: absolute; right: 10px; top: 0; z-index: 10; background: none; border: none; color: #666} diff --git a/module/bug/js/browse.js b/module/bug/js/browse.js index a4feb3c15f..807e065633 100644 --- a/module/bug/js/browse.js +++ b/module/bug/js/browse.js @@ -4,30 +4,16 @@ $(document).ready(function() $('#module' + moduleID).addClass('active'); if(browseType == 'bysearch') ajaxGetSearchForm(); - $('.assign-search').click(function(e) + $('.dropdown-menu .with-search .menu-search').click(function(e) { e.stopPropagation(); return false; }).on('keyup change paste', 'input', function() { var val = $(this).val().toLowerCase(); - if(val == '') return $('.assign-menu > .option').removeClass('hide'); - $('.assign-menu > .option').each(function() - { - var $option = $(this); - $option.toggleClass('hide', $option.text().toString().toLowerCase().indexOf(val) < 0 && $option.data('key').toString().toLowerCase().indexOf(val) < 0); - }); - }); - - $('.fix-search').click(function(e) - { - e.stopPropagation(); - return false; - }).on('keyup change paste', 'input', function() - { - var val = $(this).val().toLowerCase(); - if(val == '') return $('.fix-menu > .option').removeClass('hide'); - $('.fix-menu > .option').each(function() + var $options = $(this).parents('ul.dropdown-menu.with-search').find('.option'); + if(val == '') return $options.removeClass('hide'); + $options.each(function() { var $option = $(this); $option.toggleClass('hide', $option.text().toString().toLowerCase().indexOf(val) < 0 && $option.data('key').toString().toLowerCase().indexOf(val) < 0); diff --git a/module/bug/view/browse.html.php b/module/bug/view/browse.html.php index 05a782fbea..879984383d 100644 --- a/module/bug/view/browse.html.php +++ b/module/bug/view/browse.html.php @@ -207,7 +207,7 @@ js::set('moduleID', $moduleID); $withSearch = count($builds) > 4; echo "