diff --git a/module/bug/js/batchcreate.ui.js b/module/bug/js/batchcreate.ui.js
index e58af3acf6..451f336d82 100644
--- a/module/bug/js/batchcreate.ui.js
+++ b/module/bug/js/batchcreate.ui.js
@@ -1,42 +1,44 @@
function loadExecutionBuilds(event)
{
- var executionID = $(event.target).val();
- var index = $(event.target).closest('tr').attr('data-index');
- var branch = $('#branches_' + index).val() ? $('#branches_' + index).val() : 0;
-
+ const $target = $(event.target);
+ const $currentRow = $target.closest('tr');
+ const executionID = $target.val();
+ const branch = $currentRow.find('.form-batch-input[data-name="branch"]').val() || '0'; // Branch ID (from same row).
const productID = $('[name="product"]').val();
if(executionID != 0)
{
- var link = $.createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + "&varName=openedBuilds&build=&branch=" + branch + "&index=" + index);
+ var link = $.createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + "&varName=openedBuilds&build=&branch=" + branch);
}
else
{
- var link = $.createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + "&varName=openedBuilds&build=&branch=" + branch + "&index=" + index);
+ var link = $.createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + "&varName=openedBuilds&build=&branch=" + branch);
}
- setOpenedBuilds(link, index);
+ setOpenedBuilds(link, $currentRow);
}
-function setOpenedBuilds(link, index)
+function setOpenedBuilds(link, $currentRow)
{
- $.get(link, function(builds)
+ $.getJSON(link, function(builds)
{
- var row = $('#openedBuilds_' + index).closest('tbody').find('tr').length;
- do
- {
- var selected = $('#openedBuilds_' + index).val();
- $buildBox = $('#openedBuilds_' + index).parent();
- $buildBox.html(builds);
- $buildBox.find('select').val(selected);
- $buildBox.find('select').removeClass('select-3');
- $buildBox.find('select').addClass('select-1');
- $buildBox.find('select').attr('name','openedBuilds[' + index + '][]');
- $buildBox.find('select').attr('id','openedBuilds_' + index);
+ if(!builds) return;
+ builds = JSON.parse(builds);
- index++;
- if($('#branches_' + index).closest('.form-batch-control').attr('data-ditto') != 'on') break;
- }while(index < row)
+ let $row = $currentRow;
+ while($row.length)
+ {
+ const $build = $row.find('.form-batch-input[data-name="openedBuild"]').empty();
+
+ $.each(builds, function(value, text)
+ {
+ $build.append('');
+ });
+
+ $row = $row.next('tr');
+
+ if(!$row.find('td[data-name="openedBuild"][data-ditto="on"]').length || !$row.find('td[data-name="branch"][data-ditto="on"]').length) break;
+ }
});
}
@@ -46,10 +48,25 @@ function setLane(event)
var num = $(event.target).closest('tr').attr('data-index');
laneLink = $.createLink('kanban', 'ajaxGetLanes', 'regionID=' + regionID + '&type=bug&field=lanes&i=' + num);
- $.get(laneLink, function(lanes)
+ $.getJSON(laneLink, function(lanes)
{
- if(!lanes) lanes = '';
- $('#lanes_' + num).replaceWith(lanes);
+ if(!lanes) return;
+ lanes = JSON.parse(builds);
+
+ let $row = $currentRow;
+ while($row.length)
+ {
+ const $lane = $row.find('.form-batch-input[data-name="laneID"]').empty();
+
+ $.each(lanes, function(value, text)
+ {
+ $lane.append('');
+ });
+
+ $row = $row.next('tr');
+
+ if(!$row.find('td[data-name="laneID"][data-ditto="on"]').length || !$row.find('td[data-name="branch"][data-ditto="on"]').length) break;
+ }
});
}
diff --git a/module/bug/js/common.ui.js b/module/bug/js/common.ui.js
index 95afccaf7f..d338581492 100644
--- a/module/bug/js/common.ui.js
+++ b/module/bug/js/common.ui.js
@@ -460,48 +460,86 @@ function loadAllUsers(event)
function setBranchRelated(event)
{
- var branchID = $(event.target).val();
- var num = $(event.target).closest('tr').attr('data-index');
-
- const productID = $('[name="product"]').val();
-
- var currentModuleID = config.currentMethod == 'batchedit' ? $('#modules_' + num).val() : 0;
- var moduleLink = $.createLink('tree', 'ajaxGetModules', 'productID=' + productID + '&viewType=bug&branch=' + branchID + '&num=' + num + '¤tModuleID=' + currentModuleID);
- $.get(moduleLink, function(modules)
+ const $target = $(event.target);
+ const $currentRow = $target.closest('tr');
+ const branchID = $target.val();
+ const productID = $('[name= "product"]').val();
+ const moduleID = $currentRow.find('.form-batch-input[data-name="module"]').val() || '0';
+ const moduleLink = $.createLink('tree', 'ajaxGetModules', 'productID=' + productID + '&viewType=bug&branch=' + branchID + '&num=0¤tModuleID=' + moduleID);
+ $.getJson(moduleLink, function(data)
{
- if(!modules) modules = '';
- $('#modules_' + num).replaceWith(modules);
+ if(!data || !data.modules) return;
+
+ let $row = $currentRow;
+ while($row.length)
+ {
+ const $module = $row.find('.form-batch-input[data-name="module"]').empty();
+ $.each(data.modules, function(value, text)
+ {
+ $module.append('');
+ });
+
+ $row = $row.next('tr');
+
+ if(!$row.find('td[data-name="module"][data-ditto="on"]').length) break;
+ }
});
- var projectLink = $.createLink('product', 'ajaxGetProjectsByBranch', 'productID=' + productID + '&branch=' + branchID + '&num=' + num);
- $.get(projectLink, function(projects)
+ var projectLink = $.createLink('product', 'ajaxGetProjectsByBranch', 'productID=' + productID + '&branch=' + branchID);
+ $.getJson(projectLink, function(projects)
{
- if(!projects) projects = '';
- $('#projects_' + num).replaceWith(projects);
+ if(!projects) return;
+
+ let $row = $currentRow;
+ while($row.length)
+ {
+ const $project = $row.find('.form-batch-input[data-name="project"]').empty();
+ $.each(projects, function(value, text)
+ {
+ $project.append('');
+ });
+
+ $row = $row.next('tr');
+
+ if(!$row.find('td[data-name="project"][data-ditto="on"]').length) break;
+ }
});
- var executionLink = $.createLink('product', 'ajaxGetExecutions', 'productID=' + productID + '&projectID=0&branch=' + branchID + '&num=' + num);
- $.get(executionLink, function(executions)
+ var executionLink = $.createLink('product', 'ajaxGetExecutions', 'productID=' + productID + '&projectID=0&branch=' + branchID);
+ $.getJson(executionLink, function(executions)
{
- if(!executions) executions = '';
- $('#executions_' + num).replaceWith(executions);
+ if(!executions) return;
+
+ executions = JSON.parse(executions);
+
+ let $row = $currentRow;
+ while($row.length)
+ {
+ const $execution = $row.find('.form-batch-input[data-name="execution"]').empty();
+ $.each(executions, function(value, text)
+ {
+ $execution.append('');
+ });
+
+ $row = $row.next('tr');
+
+ if(!$row.find('td[data-name="execution"][data-ditto="on"]').length) break;
+ }
});
/* If the branch of the current row is inconsistent with the one below, clear the module and execution of the nex row. */
if(config.currentMethod == 'batchcreate')
{
- var nextBranchID = $('#branches_' + (num + 1)).val();
+ let $nextRow = $currentRow.next('tr');
+ let nextBranchID = $nextRow.find('td[data-name="branch"]').val();
if(nextBranchID != branchID)
{
- $('#modules_' + (num + 1)).closest('.form-batch-control').attr('data-ditto', 'off');
- $('#modules_' + (num + 1)).trigger("chosen:updated");
-
- $('#executions_' + (num + 1)).closest('.form-batch-control').attr('data-ditto', 'off');
- $('#executions_' + (num + 1)).trigger("chosen:updated");
+ $nextRow.find('td[data-name="branch"]').attr('data-ditto', 'off');
+ $nextRow.find('td[data-name="execution"]').attr('data-ditto', 'off');
}
- var buildLink = $.createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + "&varName=openedBuilds&build=&branch=" + branchID + "&index=" + num);
- setOpenedBuilds(buildLink, num);
+ var buildLink = $.createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + "&varName=openedBuilds&build=&branch=" + branchID);
+ setOpenedBuilds(buildLink, $currentRow);
}
if(config.currentMethod == 'batchedit')
diff --git a/module/bug/ui/batchcreate.html.php b/module/bug/ui/batchcreate.html.php
index 7a74f0afc3..65e258539d 100644
--- a/module/bug/ui/batchcreate.html.php
+++ b/module/bug/ui/batchcreate.html.php
@@ -55,7 +55,6 @@ $items[] = array
(
'name' => 'module',
'label' => $lang->bug->module,
- 'hidden' => zget($visibleFields, 'module', true, false),
'control' => 'select',
'items' => $moduleOptionMenu,
'value' => $moduleID,
@@ -241,10 +240,10 @@ $items[] = array
formBatchPanel
(
set::items($items),
- on::change('[data-name="branches"]', 'setBranchRelated'),
+ on::change('[data-name="branch"]', 'setBranchRelated'),
on::change('[data-name="project"]', 'loadProductExecutionsByProject'),
- on::change('[data-name="executions"]', 'loadExecutionBuilds'),
- on::change('[data-name="regions"]', 'setLane'),
+ on::change('[data-name="execution"]', 'loadExecutionBuilds'),
+ on::change('[data-name="region"]', 'setLane'),
formHidden('product', $productID),
);
diff --git a/module/bug/zen.php b/module/bug/zen.php
index d1744dccd0..91efbf4f8c 100644
--- a/module/bug/zen.php
+++ b/module/bug/zen.php
@@ -1770,7 +1770,7 @@ class bugZen extends bug
/* Get builds, stories and branches of this execution. */
$builds = $this->loadModel('build')->getBuildPairs($product->id, $branch, 'noempty,noreleased', $executionID, 'execution');
$stories = $this->story->getExecutionStoryPairs($executionID);
- $productBranches = $product->type != 'normal' ? $this->execution->getBranchByProduct($product->id, $executionID) : array();
+ $productBranches = $product->type != 'normal' ? $this->loadModel('execution')->getBranchByProduct(array($product->id), $executionID) : array();
$branches = isset($productBranches[$product->id]) ? $productBranches[$product->id] : array();
$branch = key($branches);
@@ -1795,7 +1795,7 @@ class bugZen extends bug
$this->view->projects = array('' => '') + $this->product->getProjectPairsByProduct($product->id, $branch ? "0,{$branch}" : '0');
$this->view->project = $project;
$this->view->projectID = $projectID;
- $this->view->executions = array('' => '') + $this->product->getExecutionPairsByProduct($product->id, $branch ? "0,{$branch}" : '0', $projectID, 'multiple,stagefilter');
+ $this->view->executions = array('' => '') + $this->product->getExecutionPairsByProduct($product->id, $branch ? "0,{$branch}" : '0', (string)$projectID, 'multiple,stagefilter');
$this->view->executionID = $executionID;
$this->view->stories = $stories;
$this->view->builds = $builds;
diff --git a/module/kanban/control.php b/module/kanban/control.php
index ce0ebba760..db7196f11f 100644
--- a/module/kanban/control.php
+++ b/module/kanban/control.php
@@ -1985,8 +1985,9 @@ class kanban extends control
{
$lanes = $this->kanban->getLanePairsByRegion($regionID, $type);
- if($i !== '') return print(html::select($field . "[$i]", $lanes, '', "class='form-control'"));
+ if($this->viewType == 'json') return print($lanes);
+ if($i !== '') return print(html::select($field . "[$i]", $lanes, '', "class='form-control'"));
return print(html::select($field, $lanes, '', "class='form-control'"));
}
diff --git a/module/product/control.php b/module/product/control.php
index 9e6970e45c..2a7c6cf1a0 100755
--- a/module/product/control.php
+++ b/module/product/control.php
@@ -924,6 +924,7 @@ class product extends control
$projects = array('' => '');
$projects += $this->product->getProjectPairsByProduct($productID, $branch);
+ if($this->viewType == 'json') return print($projects);
return print(html::select('projects' . "[$number]", array('' => '') + $projects, 0, "class='form-control' onchange='loadProductExecutionsByProject($productID, this.value, $number)'"));
}
@@ -982,7 +983,7 @@ class product extends control
{
$noMultipleExecutionID = $projectID ? $this->loadModel('execution')->getNoMultipleID($projectID) : '';
- $executions = $this->product->getExecutionPairsByProduct($productID, $branch, $projectID, 'multiple,stagefilter');
+ $executions = $this->product->getExecutionPairsByProduct($productID, $branch, (string)$projectID, 'multiple,stagefilter');
return $this->send(array('executions' => $executions, 'noMultipleExecutionID' => $noMultipleExecutionID));
}
diff --git a/module/tree/control.php b/module/tree/control.php
index 93c3343b04..11e3f0c6c4 100644
--- a/module/tree/control.php
+++ b/module/tree/control.php
@@ -654,9 +654,11 @@ class tree extends control
$currentModuleID = (isset($currentModule->branch) and $currentModule->branch == 0) ? $currentModuleID : 0;
$modules = $this->tree->getOptionMenu($productID, $viewType, $startModuleID = 0, $branchID);
+ $modules = empty($modules) ? array('' => '') : $modules;
+
+ if($this->viewType == 'json') return print(array('modules' => $modules, 'currentModuleID' => $currentModuleID));
$moduleName = ($viewType == 'bug' and $from != 'showImport') ? "modules[$number]" : "module[$number]";
- $modules = empty($modules) ? array('' => '') : $modules;
echo html::select($moduleName, $modules, $currentModuleID, 'class=form-control');
}