diff --git a/module/bug/control.php b/module/bug/control.php index 265d3d2b18..0f966ad0ee 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -883,6 +883,7 @@ class bug extends control $bug = $this->bug->getById($bugID); $productID = $bug->product; $executionID = $bug->execution; + $projectID = $bug->project; $currentModuleID = $bug->module; $this->bug->checkBugExecutionPriv($bug); @@ -928,6 +929,10 @@ class bug extends control { $openedBuilds = $this->build->getExecutionBuildPairs($executionID, $productID, $bug->branch, 'noempty,noterminate,nodone'); } + elseif($projectID) + { + $openedBuilds = $this->build->getProjectBuildPairs($projectID, $productID, $bug->branch, 'noempty,noterminate,nodone'); + } else { $openedBuilds = $this->build->getProductBuildPairs($productID, $bug->branch, 'noempty,noterminate,nodone'); diff --git a/module/bug/js/common.js b/module/bug/js/common.js index 5f82fb6680..b3db94683d 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -278,6 +278,7 @@ function loadProductExecutions(productID, projectID = 0) if(typeof(bugExecution) == 'string' && systemMode != 'classic') $('#executionIdBox').prepend("" + bugExecution + ""); if(required) $(this).addClass('required'); }); + loadProjectBuilds(projectID); } /** @@ -393,6 +394,44 @@ function loadExecutionStories(executionID) $('#storyIdBox').load(link, function(){$('#story').chosen();}); } +/** + * Load builds of a project. + * + * @param int $projectID + * @access public + * @return void + */ +function loadProjectBuilds(projectID) +{ + var branch = $('#branch').val(); + if(typeof(branch) == 'undefined') branch = 0; + var productID = $('#product').val(); + var oldOpenedBuild = $('#openedBuild').val() ? $('#openedBuild').val() : 0; + + if(page == 'create') + { + var link = createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + "&branch=" + branch); + $.get(link, function(data) + { + if(!data) data = ''; + $('#openedBuild').replaceWith(data); + $('#openedBuild').val(oldOpenedBuild); + $('#openedBuild_chosen').remove(); + $('#openedBuild').next('.picker').remove(); + $("#openedBuild").chosen(); + }) + } + else + { + var link = createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch); + $('#openedBuildBox').load(link, function(){$(this).find('select').val(oldOpenedBuild).chosen()}); + + var oldResolvedBuild = $('#resolvedBuild').val() ? $('#resolvedBuild').val() : 0; + var link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=' + branch); + $('#resolvedBuildBox').load(link, function(){$(this).find('select').val(oldResolvedBuild).chosen()}); + } +} + /** * Load builds of a execution. * diff --git a/module/build/control.php b/module/build/control.php index 46550eaadc..d422615cb4 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -380,6 +380,42 @@ class build extends control } } + /** + * AJAX: get builds of a project in html select. + * + * @param int $projectID + * @param string $varName the name of the select object to create + * @param string $build build to selected + * @param string|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 executions are not done. + * @access public + * @return string + */ + public function ajaxGetProjectBuilds($projectID, $productID, $varName, $build = '', $branch = 'all', $index = 0, $needCreate = false, $type = 'normal') + { + $isJsonView = $this->app->getViewType() == 'json'; + if($varName == 'openedBuild') + { + if(empty($projectID)) $this->ajaxGetProductBuilds($productID, $varName, $build, $branch, $index, $type); + + $params = ($type == 'all') ? 'noempty' : 'noempty, noterminate, nodone'; + $builds = $this->build->getProjectBuildPairs($projectID, $productID, $branch, $params, $build); + if($isJsonView) die(json_encode($builds)); + die(html::select($varName . '[]', $builds , '', 'size=4 class=form-control multiple')); + } + if($varName == 'resolvedBuild') + { + if(empty($projectID)) $this->ajaxGetProductBuilds($productID, $varName, $build, $branch, $index, $type); + + $params = ($type == 'all') ? '' : 'noterminate, nodone'; + $builds = $this->build->getProjectBuildPairs($projectID, $productID, $branch, $params, $build); + if($isJsonView) die(json_encode($builds)); + die(html::select($varName, $builds, $build, "class='form-control'")); + } + } + /** * AJAX: get builds of an execution in html select. *