* task #74142
This commit is contained in:
@@ -260,10 +260,12 @@ class branch extends control
|
||||
* @param string $param
|
||||
* @param int $projectID
|
||||
* @param bool $withMainBranch
|
||||
* @param string $isSiblings
|
||||
* @param string $fieldID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetBranches($productID, $oldBranch = 0, $param = 'all', $projectID = 0, $withMainBranch = true)
|
||||
public function ajaxGetBranches($productID, $oldBranch = 0, $param = 'all', $projectID = 0, $withMainBranch = true, $isSiblings = 'no', $fieldID = '0')
|
||||
{
|
||||
$product = $this->loadModel('product')->getById($productID);
|
||||
if(empty($product) or $product->type == 'normal') return;
|
||||
@@ -280,6 +282,7 @@ class branch extends control
|
||||
$branchTagOption[$oldBranch] = $oldBranch == BRANCH_MAIN ? $branch : ($branch->name . ($branch->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''));
|
||||
}
|
||||
|
||||
if($isSiblings == 'yes') return print(html::select("branches[$fieldID]", $branchTagOption, $oldBranch, "onchange='loadBranchRelation(this.value, $fieldID);' class='form-control chosen control-branch'"));
|
||||
return print(html::select('branch', $branchTagOption, $oldBranch, "class='form-control' onchange='loadBranch(this)'"));
|
||||
}
|
||||
|
||||
|
||||
@@ -959,6 +959,22 @@ class product extends control
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get product by id.
|
||||
*
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetProductById($productID)
|
||||
{
|
||||
$product = $this->product->getById($productID);
|
||||
|
||||
$product->branchSourceName = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
|
||||
$product->branchName = $this->lang->product->branchName[$product->type];
|
||||
echo json_encode($product);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX: get projects of a product in html select.
|
||||
*
|
||||
|
||||
@@ -127,6 +127,12 @@ $(window).unload(function(){
|
||||
$('#plans_i__chosen').remove();
|
||||
$('#plans' + itemIndex).chosen();
|
||||
$('.addBranchesBox' + itemIndex + ' #planIdBox').css('flex', '0 0 ' + gap + 'px');
|
||||
|
||||
loadBranchForSiblings($('#product').val(), 0, itemIndex)
|
||||
loadModuleForSiblings($('#product').val(), 0, itemIndex)
|
||||
loadPlanForSiblings($('#product').val(), 0, itemIndex)
|
||||
$('.addBranchesBox' + itemIndex + ' #branchBox .input-group .input-group-addon').html($.cookie('branchSourceName'))
|
||||
|
||||
itemIndex ++;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,16 +56,14 @@ foreach(explode(',', $config->story->create->requiredFields) as $field)
|
||||
<?php if($branches and $type != 'story') echo html::select('branch', $branches, $branch, "onchange='loadBranch();' class='form-control chosen control-branch'");?>
|
||||
</div>
|
||||
</td>
|
||||
<?php if($branches and $type == 'story'): ?>
|
||||
<td colspan='<?php echo $type == 'story' ? 2 : 1;?>' id='assignedToBox'>
|
||||
<td colspan='2' id='assignedToBox' class='<?php if((!$branches and $type == 'story') or $type == 'requirement') echo "hidden"; ?> switchBranch'>
|
||||
<div class='input-group'>
|
||||
<div class="input-group-addon assignedTo"><?php echo $lang->story->assignedTo;?></div>
|
||||
<?php echo html::select('assignedTo', $users, '', "class='form-control picker-select'");?>
|
||||
</div>
|
||||
</td>
|
||||
<td class='w-60px'></td>
|
||||
<?php else: ?>
|
||||
<td colspan="2">
|
||||
<td class='w-60px <?php if((!$branches and $type == 'story') or $type == 'requirement') echo "hidden"; ?> switchBranch'></td>
|
||||
<td colspan="2" class='<?php if($branches and $type == 'story') echo "hidden"; ?> switchBranch'>
|
||||
<div class='input-group' id='moduleIdBox'>
|
||||
<div class="input-group-addon"><?php echo $lang->story->module;?></div>
|
||||
<?php
|
||||
@@ -81,19 +79,17 @@ foreach(explode(',', $config->story->create->requiredFields) as $field)
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<?php $hiddenSource = strpos(",$showFields,", ',source,') !== false ? '' : 'hidden';?>
|
||||
<?php if($type == 'story'):?>
|
||||
<?php if($branches): ?>
|
||||
<tr>
|
||||
<tr class='<?php if(!$branches) echo 'hidden'; ?> switchBranch' >
|
||||
<th><?php echo $lang->product->branchName[$product->type];?></th>
|
||||
<td colspan="4">
|
||||
<div class='input-group' style='display: flex;'>
|
||||
<div class='table-col' id='branchBox'>
|
||||
<div class='input-group'>
|
||||
<span class='input-group-addon fix-border'><?php echo sprintf($lang->product->branch, $lang->product->branchName[$product->type])?></span>
|
||||
<?php echo html::select('branches[0]', $branches, $branch, "onchange='loadBranchForBranch(this.value, 0);' class='form-control chosen control-branch'");?>
|
||||
<?php echo html::select('branches[0]', $branches, $branch, "onchange='loadBranchRelation(this.value, 0);' class='form-control chosen control-branch'");?>
|
||||
</div>
|
||||
</div>
|
||||
<div class='table-col' id='moduleIdBox'>
|
||||
@@ -116,14 +112,13 @@ foreach(explode(',', $config->story->create->requiredFields) as $field)
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class='<?php if(!$branches) echo "hidden"; ?> switchBranch' >
|
||||
<th></th>
|
||||
<td colspan="4" id="storyNoticeBranch">
|
||||
<i class="icon-exclamation-sign"></i> <?php echo $lang->story->notice->branch;?>
|
||||
<i class="icon-exclamation-sign"></i> <?php echo $lang->story->notice->branch;?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<tr class='<?php if($branches) echo "hidden"; ?> switchBranch'>
|
||||
<th class='planTh'><?php echo $lang->story->planAB;?></th>
|
||||
<td colspan="2">
|
||||
<div class='input-group' id='planIdBox'>
|
||||
@@ -148,7 +143,6 @@ foreach(explode(',', $config->story->create->requiredFields) as $field)
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr class='sourceBox <?php echo $hiddenSource;?>'>
|
||||
<th><?php echo $lang->story->source;?></th>
|
||||
<td colspan='2'>
|
||||
@@ -360,7 +354,7 @@ foreach(explode(',', $config->story->create->requiredFields) as $field)
|
||||
<div class='table-col' id='branchBox' style='flex: 1 0 160px'>
|
||||
<div class='input-group'>
|
||||
<span class='input-group-addon fix-border'><?php echo sprintf($lang->product->branch, $lang->product->branchName[$product->type])?></span>
|
||||
<?php echo html::select("branches[$i]", $branches, $branch, "onchange='loadBranchForBranch(this.value, $i);' class='form-control chosen control-branch'");?>
|
||||
<?php echo html::select("branches[$i]", $branches, $branch, "onchange='loadBranchRelation(this.value, $i);' class='form-control chosen control-branch'");?>
|
||||
</div>
|
||||
</div>
|
||||
<div class='table-col' id='moduleIdBox' style='flex: 1 0 160px'>
|
||||
|
||||
@@ -71,16 +71,59 @@ function loadBranch()
|
||||
/**
|
||||
* Load branch for multi branch or multi platform.
|
||||
*
|
||||
* @param int $branch
|
||||
* @param int $branchIndex
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadBranchForBranch(branch, branchIndex)
|
||||
function loadBranchRelation(branch, branchIndex)
|
||||
{
|
||||
var branch = $('#branches' + branchIndex).val();
|
||||
var productID = $('#product').val();
|
||||
if(typeof(branch) == 'undefined') branch = 0;
|
||||
if(typeof(productID) == 'undefined' && config.currentMethod == 'edit') productID = oldProductID;
|
||||
|
||||
loadModuleForSiblings(productID, branch, branchIndex)
|
||||
loadPlanForSiblings(productID, branch, branchIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Load branch for siblings.
|
||||
*
|
||||
* @paran int $procutID
|
||||
* @param int $branch
|
||||
* @param int $branchIndex
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadBranchForSiblings(productID, branch, branchIndex)
|
||||
{
|
||||
var param = 'all';
|
||||
if(page == 'create') param = 'active';
|
||||
|
||||
var isSiblings = storyType == 'story' ? 'yes' : 'no';
|
||||
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID + "&oldBranch=0¶m=" + param + "&projectID=" + executionID + "&withMainBranch=1&isSiblings=" + isSiblings + "&fieldID=" + branchIndex), function(data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
/* reload branch */
|
||||
$('#branches' + branchIndex).replaceWith(data);
|
||||
$('#branches' + branchIndex + "_chosen").remove();
|
||||
$('#branches' + branchIndex).next('.picker').remove();
|
||||
$('#branches' + branchIndex).chosen();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Load module for siblings.
|
||||
*
|
||||
* @paran int $procutID
|
||||
* @param int $branch
|
||||
* @param int $branchIndex
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadModuleForSiblings(productID, branch, branchIndex)
|
||||
{
|
||||
/* Load module */
|
||||
var currentModule = 0;
|
||||
var moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=story&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=' + branchIndex + '&needManage=true&extra=¤tModuleID=' + currentModule);
|
||||
@@ -90,15 +133,32 @@ function loadBranchForBranch(branch, branchIndex)
|
||||
}
|
||||
else
|
||||
{
|
||||
var $moduleIDBox = $('#moduleIdBox');
|
||||
var $moduleIDBox = $('.switchBranch #moduleIdBox');
|
||||
}
|
||||
$moduleIDBox.load(moduleLink, function()
|
||||
{
|
||||
$moduleIDBox.find('#modules' + branchIndex).chosen();
|
||||
$moduleIDBox.prepend("<span class='input-group-addon fix-border'>" + storyModule + "</span>");
|
||||
if(branchIndex == 0)
|
||||
{
|
||||
$('.switchBranch #moduleIdBox span:first-child').remove()
|
||||
}
|
||||
$moduleIDBox.prepend("<span class='input-group-addon fix-border'>" + storyModule + "</span>" );
|
||||
|
||||
$moduleIDBox.fixInputGroup();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load plan for siblings.
|
||||
*
|
||||
* @paran int $procutID
|
||||
* @param int $branch
|
||||
* @param int $branchIndex
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadPlanForSiblings(productID, branch, branchIndex)
|
||||
{
|
||||
/* Load plan */
|
||||
if(typeof(branch) == 'undefined') branch = 0;
|
||||
if(!branch) branch = 0;
|
||||
@@ -133,20 +193,72 @@ function loadProductBranches(productID)
|
||||
if(page == 'create') param = 'active';
|
||||
$('#branch').remove();
|
||||
$('#branch_chosen').remove();
|
||||
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID + "&oldBranch=0¶m=" + param + "&projectID=" + executionID), function(data)
|
||||
{
|
||||
var $product = $('#product');
|
||||
var $inputGroup = $product.closest('.input-group');
|
||||
$inputGroup.find('.input-group-addon').toggleClass('hidden', !data);
|
||||
if(data)
|
||||
{
|
||||
$inputGroup.append(data);
|
||||
$('#branch').css('width', config.currentMethod == 'create' ? '120px' : '65px').chosen();
|
||||
}
|
||||
$inputGroup.fixInputGroup();
|
||||
|
||||
loadProductModules(productID, $('#branch').val());
|
||||
loadProductPlans(productID, $('#branch').val());
|
||||
var isSiblings = storyType == 'story' ? 'yes' : 'no';
|
||||
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID + "&oldBranch=0¶m=" + param + "&projectID=" + executionID + "&withMainBranch=1&isSiblings=" + isSiblings), function(data)
|
||||
{
|
||||
if(storyType == 'story')
|
||||
{
|
||||
$('.switchBranch').toggleClass('hidden');
|
||||
$('.switchBranch').toggleClass('disable');
|
||||
$('tr[class^="addBranchesBox"]').remove();
|
||||
|
||||
if(data)
|
||||
{
|
||||
$.get(createLink('product', 'ajaxGetProductById', "productID=" + productID), function(data)
|
||||
{
|
||||
$('.switchBranch #branchBox .input-group .input-group-addon').html(data.branchSourceName)
|
||||
$('.switchBranch #branchBox').closest('td').prev().html(data.branchName)
|
||||
$.cookie('branchSourceName', data.branchSourceName)
|
||||
}, 'json')
|
||||
|
||||
|
||||
/* reload branch */
|
||||
$('#branches0').replaceWith(data);
|
||||
$('#branches0' + "_chosen").remove();
|
||||
$('#branches0').next('.picker').remove();
|
||||
$('#branches0').chosen();
|
||||
|
||||
$.get(createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=story&branch=0' + '&rootModuleID=0&returnType=html&fieldID=0' + '&needManage=true&extra=¤tModuleID=0'), function(moduleData)
|
||||
{
|
||||
if(moduleData)
|
||||
{
|
||||
$('#modules0').replaceWith(moduleData);
|
||||
$('#modules0' + "_chosen").remove();
|
||||
$('#modules0').next('.picker').remove();
|
||||
$('#modules0').chosen();
|
||||
}
|
||||
});
|
||||
|
||||
var expired = config.currentMethod == 'create' ? 'unexpired' : '';
|
||||
$.get(createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=0' + '&planID=' + $('#plan').val() + '&fieldID=0' + '&needCreate=true&expired='+ expired +'¶m=skipParent,' + config.currentMethod), function(planData)
|
||||
{
|
||||
if(planData)
|
||||
{
|
||||
$('#plans0').replaceWith(planData);
|
||||
$('#plans0' + "_chosen").remove();
|
||||
$('#plans0').next('.picker').remove();
|
||||
$('#plans0').chosen();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var $product = $('#product');
|
||||
var $inputGroup = $product.closest('.input-group');
|
||||
$inputGroup.find('.input-group-addon').toggleClass('hidden', !data);
|
||||
if(data)
|
||||
{
|
||||
$inputGroup.append(data);
|
||||
$('#branch').css('width', config.currentMethod == 'create' ? '120px' : '65px').chosen();
|
||||
}
|
||||
$inputGroup.fixInputGroup();
|
||||
|
||||
loadProductModules(productID, $('#branch').val());
|
||||
loadProductPlans(productID, $('#branch').val());
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user