diff --git a/module/bug/js/batchcreate.js b/module/bug/js/batchcreate.js index 96f0618678..8f26d5ee4e 100644 --- a/module/bug/js/batchcreate.js +++ b/module/bug/js/batchcreate.js @@ -5,25 +5,49 @@ $(function() }) /** - * Load project builds - * - * @param int $productID - * @param int $projectID - * @param int $index + * Set branch related. + * + * @param int $branchID + * @param int $productID + * @param int $num * @access public * @return void */ -function loadProjectBuilds(productID, projectID, index) +function setBranchRelated(branchID, productID, num) { - if(projectID) + moduleLink = createLink('tree', 'ajaxGetModules', 'productID=' + productID + '&viewType=bug&branch=' + branchID + '&num=' + num); + $.get(moduleLink, function(modules) { - link = createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + "&varName=openedBuilds&build=&branch=" + branch + "&index=" + index); - } - else - { - link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + "&varName=openedBuilds&build=&branch=" + branch + "&index=" + index); - } + if(!modules) modules = ''; + $('#modules' + num).replaceWith(modules); + $("#modules" + num + "_chosen").remove(); + $("#modules" + num).chosen(defaultChosenOptions); + }); + projectLink = createLink('product', 'ajaxGetProjects', 'productID=' + productID + '&projectID=0&branch=' + branchID + '&num=' + num); + $.get(projectLink, function(projects) + { + if(!projects) projects = ''; + $('#projects' + num).replaceWith(projects); + $("#projects" + num + "_chosen").remove(); + $("#projects" + num).chosen(defaultChosenOptions); + }); + + buildLink = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + "&varName=openedBuilds&build=&branch=" + branchID + "&index=" + num); + + setOpenedBuilds(buildLink, num); +} + +/** + * Set opened builds. + * + * @param string $link + * @param int $index + * @access public + * @return void + */ +function setOpenedBuilds(link, index) +{ $.get(link, function(builds) { var row = $('#buildBox' + index).closest('tbody').find('tr').size() @@ -45,6 +69,29 @@ function loadProjectBuilds(productID, projectID, index) }); } +/** + * Load project builds + * + * @param int $productID + * @param int $projectID + * @param int $index + * @access public + * @return void + */ +function loadProjectBuilds(productID, projectID, index) +{ + if(projectID) + { + link = createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + "&varName=openedBuilds&build=&branch=" + branch + "&index=" + index); + } + else + { + link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + "&varName=openedBuilds&build=&branch=" + branch + "&index=" + index); + } + + setOpenedBuilds(link, index); +} + $(document).on('click', '.chosen-with-drop', function() { var select = $(this).prev('select'); diff --git a/module/bug/view/batchcreate.html.php b/module/bug/view/batchcreate.html.php index 95841f6b1b..3612c58d77 100644 --- a/module/bug/view/batchcreate.html.php +++ b/module/bug/view/batchcreate.html.php @@ -79,7 +79,7 @@ foreach(explode(',', $showFields) as $field) ?> - '> + '> ' style='overflow:visible'> ' style='overflow:visible'> @@ -112,7 +112,7 @@ foreach(explode(',', $showFields) as $field) ?> - '> + '> ' style='overflow:visible'> ' style='overflow:visible'> @@ -141,7 +141,7 @@ foreach(explode(',', $showFields) as $field) %s - '> + '> ' style='overflow:visible'> ' style='overflow:visible'> diff --git a/module/product/control.php b/module/product/control.php index 38a6f5f199..df95368e02 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -489,10 +489,11 @@ class product extends control * * @param int $productID * @param int $projectID + * @param string $number * @access public * @return void */ - public function ajaxGetProjects($productID, $projectID = 0, $branch = 0) + public function ajaxGetProjects($productID, $projectID = 0, $branch = 0, $number = '') { if($productID == 0) { @@ -504,7 +505,16 @@ class product extends control } if($this->app->getViewType() == 'json') die(json_encode($projects)); - die(html::select('project', $projects, $projectID, 'class=form-control onchange=loadProjectRelated(this.value)')); + if($number === '') + { + die(html::select('project', $projects, $projectID, 'class=form-control onchange=loadProjectRelated(this.value)')); + } + else + { + $projectName = "projects[$number]"; + $projects = empty($projects) ? array('' => '') : $projects; + die(html::select($projectName, $projects, '', "class='form-control' onchange='loadProjectRelated(this.value, $productID, $number)'")); + } } /** diff --git a/module/productplan/control.php b/module/productplan/control.php index d364bb4e28..34a939c320 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -242,13 +242,17 @@ class productplan extends control * Ajax: Get product plans. * * @param int $productID + * @param string $number * @access public * @return void */ - public function ajaxGetProductplans($productID, $branch = 0) + public function ajaxGetProductplans($productID, $branch = 0, $number = '') { $plans = $this->productplan->getPairs($productID, $branch); - die(html::select('plan', $plans, '', "class='form-control'")); + + $planName = $number === '' ? 'plan' : "plan[$number]"; + $plans = empty($plans) ? array('' => '') : $plans; + die(html::select($planName, $plans, '', "class='form-control'")); } /** diff --git a/module/story/js/batchcreate.js b/module/story/js/batchcreate.js index f24ca75ac0..c53a0a7816 100644 --- a/module/story/js/batchcreate.js +++ b/module/story/js/batchcreate.js @@ -43,3 +43,33 @@ if(navigator.userAgent.indexOf("Firefox") < 0) this.style.height = (this.scrollHeight + 2) + "px"; }); } + +/** + * Set modules and plans. + * + * @param int $branchID + * @param int $productID + * @param int $num + * @access public + * @return void + */ +function setModuleAndPlan(branchID, productID, num) +{ + moduleLink = createLink('tree', 'ajaxGetModules', 'productID=' + productID + '&viewType=story&branch=' + branchID + '&num=' + num); + $.get(moduleLink, function(modules) + { + if(!modules) modules = ''; + $('#module' + num).replaceWith(modules); + $("#module" + num + "_chosen").remove(); + $("#module" + num).chosen(defaultChosenOptions); + }); + + planLink = createLink('productPlan', 'ajaxGetProductPlans', 'productID=' + productID + '&branch=' + branchID + '&num=' + num); + $.get(planLink, function(plans) + { + if(!plans) plans = ''; + $('#plan' + num).replaceWith(plans); + $("#plan" + num + "_chosen").remove(); + $("#plan" + num).chosen(defaultChosenOptions); + }); +} diff --git a/module/story/view/batchcreate.html.php b/module/story/view/batchcreate.html.php index 40b5553c8c..644ee606f6 100644 --- a/module/story/view/batchcreate.html.php +++ b/module/story/view/batchcreate.html.php @@ -61,7 +61,7 @@ if($this->story->checkForceReview()) unset($visibleFields['review']); - '> + '> ' style='overflow:visible'> ' style='overflow:visible'> @@ -90,7 +90,7 @@ if($this->story->checkForceReview()) unset($visibleFields['review']); - '> + '> ' style='overflow:visible'> ' style='overflow:visible'> @@ -115,7 +115,7 @@ if($this->story->checkForceReview()) unset($visibleFields['review']); %s - '> + '> ' style='overflow:visible'> ' style='overflow:visible'> diff --git a/module/testcase/control.php b/module/testcase/control.php index 3762c61a6a..a773edc55e 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -389,8 +389,8 @@ class testcase extends control $showFields = $this->config->testcase->custom->batchCreateFields; if($product->type == 'normal') { - str_replace(array(0 => ",branch,", 1 => ",platform,"), '', $showFields); - trim($showFields, ','); + $showFields = str_replace(array(0 => ",branch,", 1 => ",platform,"), '', ",$showFields,"); + $showFields = trim($showFields, ','); } $this->view->customFields = $customFields; $this->view->showFields = $showFields; diff --git a/module/testcase/js/batchcreate.js b/module/testcase/js/batchcreate.js index 1c4bd40f02..0291853257 100644 --- a/module/testcase/js/batchcreate.js +++ b/module/testcase/js/batchcreate.js @@ -10,6 +10,7 @@ $(document).ready(function() { index = id.substring(5); module = $('#module' + index).val(); + branch = $('#branch' + index).val(); if(module == 'ditto') { for(var i = index - 1; i >=0; i--) @@ -57,3 +58,24 @@ $(document).ready(function() } }); }); + +/** + * Set modules. + * + * @param int $branchID + * @param int $productID + * @param int $num + * @access public + * @return void + */ +function setModules(branchID, productID, num) +{ + moduleLink = createLink('tree', 'ajaxGetModules', 'productID=' + productID + '&viewType=story&branch=' + branchID + '&num=' + num); + $.get(moduleLink, function(modules) + { + if(!modules) modules = ''; + $('#module' + num).replaceWith(modules); + $("#module" + num + "_chosen").remove(); + $("#module" + num).chosen(defaultChosenOptions); + }); +} diff --git a/module/testcase/view/batchcreate.html.php b/module/testcase/view/batchcreate.html.php index f093e3029f..290ac840de 100644 --- a/module/testcase/view/batchcreate.html.php +++ b/module/testcase/view/batchcreate.html.php @@ -35,7 +35,7 @@ $visibleFields = array(); foreach(explode(',', $showFields) as $field) { - if($field)$visibleFields[$field] = ''; + if($field) $visibleFields[$field] = ''; } $colspan = count($visibleFields) + 3; $hiddenStory = (isonlybody() and $story) ? ' hidden' : ''; @@ -69,7 +69,7 @@ if($hiddenStory and isset($visibleFields['story'])) $colspan -= 1; ?> - '> + '> ' style='overflow:visible'> ' style='overflow:visible'> id : '', 'class="form-control chosen"');?> @@ -94,7 +94,7 @@ if($hiddenStory and isset($visibleFields['story'])) $colspan -= 1; %s - '> + '> ' style='overflow:visible'> ' style='overflow:visible'> diff --git a/module/tree/control.php b/module/tree/control.php index 8b37e0c617..c44fc6bcad 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -323,6 +323,25 @@ class tree extends control if($returnType == 'json') die(json_encode($optionMenu)); } + /** + * AJAX: get modules. + * + * @param int $productID + * @param string $viewType + * @param int $branchID + * @param int $number + * @access public + * @return string the html select string. + */ + public function ajaxGetModules($productID, $viewType = 'story', $branchID, $number) + { + $modules = $this->tree->getOptionMenu($productID, $viewType, $startModuleID = 0, $branchID); + + $moduleName = $viewType == 'bug' ? "modules[$number]" : "module[$number]"; + $modules = empty($modules) ? array('' => '') : $modules; + die(html::select($moduleName, $modules, '', 'class=form-control')); + } + /** * AJAX: get a module's son modules. *