* adjust task #2731.

This commit is contained in:
chenfeiCF
2016-12-04 13:35:40 +08:00
parent cb30979d57
commit a539be0c32
10 changed files with 160 additions and 28 deletions
+60 -13
View File
@@ -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 = '<select id="modules' + num + '" name="modules[' + num + ']" class="form-control"></select>';
$('#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 = '<select id="projects' + num + '" name="projects[' + num + ']" class="form-control"></select>';
$('#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');
+3 -3
View File
@@ -79,7 +79,7 @@ foreach(explode(',', $showFields) as $field)
?>
<tr class='text-center'>
<td><?php echo $i+1;?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branches[$i]", $branches, $branch, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branches[$i]", $branches, $branch, "class='form-control' onchange='setBranchRelated(this.value, $productID, $i)'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'module', ' hidden')?>' style='overflow:visible'><?php echo html::select("modules[$i]", $moduleOptionMenu, $moduleID, "class='form-control chosen'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'project', ' hidden')?>' style='overflow:visible'><?php echo html::select("projects[$i]", $projects, $projectID, "class='form-control chosen' onchange='loadProjectBuilds($productID, this.value, $i)'");?></td>
<td class='text-left' style='overflow:visible' id='buildBox<?php echo $i;?>'><?php echo html::select("openedBuilds[$i][]", $builds, 'trunk', "class='form-control chosen' multiple");?></td>
@@ -112,7 +112,7 @@ foreach(explode(',', $showFields) as $field)
?>
<tr class='text-center'>
<td><?php echo $i+1;?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branches[$i]", $branches, $branch, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branches[$i]", $branches, $branch, "class='form-control' onchange='setBranchRelated(this.value, $productID, $i)'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'module', ' hidden')?>' style='overflow:visible'><?php echo html::select("modules[$i]", $moduleOptionMenu, $moduleID, "class='form-control chosen'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'project', ' hidden')?>' style='overflow:visible'><?php echo html::select("projects[$i]", $projects, $projectID, "class='form-control chosen' onchange='loadProjectBuilds($productID, this.value, $i)'");?></td>
<td class='text-left' style='overflow:visible' id='buildBox<?php echo $i;?>'><?php echo html::select("openedBuilds[$i][]", $builds, '', "class='form-control chosen' multiple");?></td>
@@ -141,7 +141,7 @@ foreach(explode(',', $showFields) as $field)
<tbody>
<tr class='text-center'>
<td>%s</td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branches[%s]", $branches, $branch, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branches[%s]", $branches, $branch, "class='form-control' onchange='setBranchRelated(this.value, $productID, \"%s\")'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'module', ' hidden')?>' style='overflow:visible'><?php echo html::select("modules[%s]", $moduleOptionMenu, $moduleID, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'project', ' hidden')?>' style='overflow:visible'><?php echo html::select("projects[%s]", $projects, $projectID, "class='form-control' onchange='loadProjectBuilds($productID, this.value, \"%s\")'");?></td>
<td class='text-left' style='overflow:visible' id='buildBox%s'><?php echo html::select("openedBuilds[%s][]", $builds, '', "class='form-control' multiple");?></td>
+12 -2
View File
@@ -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)'"));
}
}
/**
+6 -2
View File
@@ -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'"));
}
/**
+30
View File
@@ -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 = '<select id="module' + num + '" name="module[' + num + ']" class="form-control"></select>';
$('#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 = '<select id="plan' + num + '" name="plan[' + num + ']" class="form-control"></select>';
$('#plan' + num).replaceWith(plans);
$("#plan" + num + "_chosen").remove();
$("#plan" + num).chosen(defaultChosenOptions);
});
}
+3 -3
View File
@@ -61,7 +61,7 @@ if($this->story->checkForceReview()) unset($visibleFields['review']);
<?php $source = $i == 0 ? '' : 'ditto';?>
<tr class='text-center'>
<td><?php echo $i+1;?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branch[$i]", $branches, $branch, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branch[$i]", $branches, $branch, "class='form-control' onchange='setModuleAndPlan(this.value, $productID, $i)'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'module', ' hidden')?>' style='overflow:visible'><?php echo html::select("module[$i]", $moduleOptionMenu, $moduleID, "class='form-control chosen'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'plan', ' hidden')?>' style='overflow:visible'><?php echo html::select("plan[$i]", $plans, $planID, "class='form-control chosen'");?></td>
<td style='overflow:visible'>
@@ -90,7 +90,7 @@ if($this->story->checkForceReview()) unset($visibleFields['review']);
<?php $source = $i - $nextStart == 0 ? '' : 'ditto';?>
<tr class='text-center'>
<td><?php echo $i+1;?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branch[$i]", $branches, $branch, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branch[$i]", $branches, $branch, "class='form-control' onchange='setModuleAndPlan(this.value, $productID, $i)'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'module', ' hidden')?>' style='overflow:visible'><?php echo html::select("module[$i]", $moduleOptionMenu, $moduleID, "class='form-control chosen'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'plan', ' hidden')?>' style='overflow:visible'><?php echo html::select("plan[$i]", $plans, $planID, "class='form-control chosen'");?></td>
<td style='overflow:visible'>
@@ -115,7 +115,7 @@ if($this->story->checkForceReview()) unset($visibleFields['review']);
<tbody>
<tr class='text-center'>
<td>%s</td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branch[%s]", $branch, $branch, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branch[%s]", $branch, $branch, "class='form-control' onchange='setModuleAndPlan(this.value, $productID, \"%s\")'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'module', ' hidden')?>' style='overflow:visible'><?php echo html::select("module[%s]", $moduleOptionMenu, $moduleID, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'plan', ' hidden')?>' style='overflow:visible'><?php echo html::select("plan[%s]", $plans, $planID, "class='form-control'");?></td>
<td style='overflow:visible'>
+2 -2
View File
@@ -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;
+22
View File
@@ -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 = '<select id="module' + num + '" name="module[' + num + ']" class="form-control"></select>';
$('#module' + num).replaceWith(modules);
$("#module" + num + "_chosen").remove();
$("#module" + num).chosen(defaultChosenOptions);
});
}
+3 -3
View File
@@ -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;
?>
<tr class='text-center'>
<td><?php echo $i+1;?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branch[$i]", $branches, $branch, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branch[$i]", $branches, $branch, "class='form-control' onchange='setModules(this.value, $productID, $i)'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'module', ' hidden')?>' style='overflow:visible'><?php echo html::select("module[$i]", $moduleOptionMenu, $currentModuleID, "class='form-control chosen'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'story', ' hidden'); echo $hiddenStory;?>' style='overflow:visible'> <?php echo html::select("story[$i]", $storyList, $story ? $story->id : '', 'class="form-control chosen"');?></td>
<td style='overflow:visible'>
@@ -94,7 +94,7 @@ if($hiddenStory and isset($visibleFields['story'])) $colspan -= 1;
<tbody>
<tr class='text-center'>
<td>%s</td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branch[%s]", $branches, $branch, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select("branch[%s]", $branches, $branch, "class='form-control' onchange='setModules(this.value, $productID, \"%s\")'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'module', ' hidden')?>' style='overflow:visible'><?php echo html::select("module[%s]", $moduleOptionMenu, $currentModuleID, "class='form-control'");?></td>
<td class='text-left<?php echo zget($visibleFields, 'story', ' hidden'); echo $hiddenStory;?>' style='overflow:visible'> <?php echo html::select("story[%s]", '', '', 'class="form-control"');?></td>
<td style='overflow:visible'>
+19
View File
@@ -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.
*