* finish task #6650.

This commit is contained in:
wangyidong
2019-12-05 09:13:32 +08:00
parent a4cf41780c
commit 3d68e30c67
3 changed files with 44 additions and 4 deletions
+7 -1
View File
@@ -274,7 +274,13 @@ class tree extends control
$showProduct = strpos('story|bug|case', $type) !== false ? true : false;
$this->view->showProduct = $showProduct;
if($showProduct) $this->view->products = $this->loadModel('product')->getPairs();
if($showProduct)
{
$product = $this->loadModel('product')->getById($module->root);
if($product->type != 'normal') $this->view->branches = $this->loadModel('branch')->getPairs($module->root);
$this->view->product = $product;
$this->view->products = $this->product->getPairs();
}
/* Remove self and childs from the $optionMenu. Because it's parent can't be self or childs. */
$childs = $this->tree->getAllChildId($moduleID);
+3 -2
View File
@@ -1408,8 +1408,9 @@ class treeModel extends model
{
$module = fixer::input('post')->get();
$self = $this->getById($moduleID);
if(!isset($_POST['branch'])) $module->branch = $self->branch;
$repeatName = $this->checkUnique($self, array("id{$self->id}" => $module->name), array("id{$self->id}" => $self->branch));
$repeatName = $this->checkUnique($self, array("id{$self->id}" => $module->name), array("id{$self->id}" => $module->branch));
if($repeatName) die(js::alert(sprintf($this->lang->tree->repeatName, $repeatName)));
$parent = $this->getById($this->post->parent);
@@ -1717,7 +1718,7 @@ class treeModel extends model
{
/* Ignore useless module for task. */
$allModule = (isset($this->config->project->task->allModule) and ($this->config->project->task->allModule == 1));
if($keepModules and !isset($keepModules[$module->id])) continue;
if($keepModules and !isset($keepModules[$module->id]) and !$allModule) continue;
if($viewType == 'task' and empty($keepModules) and !$allModule) continue;
if(isset($parent[$module->id]))
{
+34 -1
View File
@@ -27,7 +27,16 @@ if(isset($pageCSS)) css::internal($pageCSS);
<?php if($showProduct):?>
<tr>
<th class='thWidth'><?php echo $lang->tree->product;?></th>
<td><?php echo html::select('root', $products, $module->root, "class='form-control chosen'");?></td>
<td>
<div class='input-group'>
<?php echo html::select('root', $products, $module->root, "class='form-control chosen' onchange='loadBranches(this)'");?>
<?php if($product->type != 'normal'):?>
<span class='input-group-addon fix-border fix-padding'></span>
<?php echo html::select('branch', $branches, $module->branch, "class='form-control chosen control-branch'");?>
</div>
<?php endif;?>
</div>
</td>
</tr>
<?php endif;?>
<?php $hidden = ($type != 'story' and $module->type == 'story');?>
@@ -116,4 +125,28 @@ $(function()
$('#parent').trigger('chosen:close');
});
})
/**
* Load branches by product.
*
* @param object $obj
* @access public
* @return void
*/
function loadBranches(obj)
{
var productID = $(obj).val();
var $inputGroup = $(obj).closest('.input-group');
$inputGroup.find('#branch').remove();
$inputGroup.find('#branch_chosen').remove();
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID), function(data)
{
if(data)
{
$inputGroup.append(data);
$inputGroup.find('#branch').css('width', '100px').removeAttr('onchange');
$inputGroup.find('#branch').chosen();
}
})
}
</script>