* Code for task#78669.
This commit is contained in:
@@ -1008,20 +1008,26 @@ class productplan extends control
|
||||
/**
|
||||
* AJAX: Get parent branches.
|
||||
*
|
||||
* @param int $parentID
|
||||
* @param int $productID
|
||||
* @param int $parentID
|
||||
* @param string $currentBranches
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetParentBranches($productID = 0, $parentID = 0)
|
||||
public function ajaxGetParentBranches($productID = 0, $parentID = 0, $currentBranches = '')
|
||||
{
|
||||
$branchPairs = $this->loadModel('branch')->getPairs($productID, 'active');
|
||||
if(!empty($parentID))
|
||||
{
|
||||
$parentBranches = array();
|
||||
$parentPlan = $this->productplan->getByID($parentID);
|
||||
foreach(explode(',', $parentPlan->branch) as $parentBranchID) $parentBranches[$parentBranchID] = $branchPairs[$parentBranchID];
|
||||
foreach(explode(',', $parentPlan->branch) as $parentBranchID)
|
||||
{
|
||||
$parentBranches[$parentBranchID] = $branchPairs[$parentBranchID];
|
||||
if(!empty($currentBranches) and strpos(",$currentBranches,", ",$parentBranchID,") === false) $currentBranches = str_replace(",$parentBranchID,", ',', $currentBranches);
|
||||
}
|
||||
}
|
||||
return print(html::select('branch[]', empty($parentID) ? $branchPairs : $parentBranches, '', "class='form-control chosen' multiple required"));
|
||||
return print(html::select('branch[]', empty($parentID) ? $branchPairs : $parentBranches, trim($currentBranches, ','), "class='form-control chosen' multiple required"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,12 +65,14 @@ $('#future').on('change', function()
|
||||
|
||||
$('#parent').change(function()
|
||||
{
|
||||
var parentID = $(this).val();
|
||||
$.post(createLink('productplan', 'ajaxGetParentBranches', "productID=" + productID + "&parentID=" + parentID), function(data)
|
||||
var parentID = $(this).val();
|
||||
var currentBranches = $('#branch').val() ? $('#branch').val().toString() : '';
|
||||
$.post(createLink('productplan', 'ajaxGetParentBranches', "productID=" + productID + "&parentID=" + parentID + "¤tBranches=" + currentBranches), function(data)
|
||||
{
|
||||
$('#branch').replaceWith(data);
|
||||
$('#branch_chosen').remove();
|
||||
$('#branch').chosen();
|
||||
$('#branch').change();
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ $('#dataform').on('change', '#branch', function()
|
||||
var result = confirm(conflictStories) ? true : false;
|
||||
if(!result)
|
||||
{
|
||||
newBranch = oldBranch[planID];
|
||||
$('#branch').val(oldBranch[planID].split(','));
|
||||
$('#branch').trigger("chosen:updated");
|
||||
}
|
||||
@@ -59,8 +58,9 @@ function computeEndDate(delta)
|
||||
|
||||
$('#parent').change(function()
|
||||
{
|
||||
var parentID = $(this).val();
|
||||
$.post(createLink('productplan', 'ajaxGetParentBranches', "productID=" + productID + "&parentID=" + parentID), function(data)
|
||||
var parentID = $(this).val();
|
||||
var currentBranches = $('#branch').val() ? $('#branch').val().toString() : '';
|
||||
$.post(createLink('productplan', 'ajaxGetParentBranches', "productID=" + productID + "&parentID=" + parentID + "¤tBranches=" + currentBranches), function(data)
|
||||
{
|
||||
$('#branch').replaceWith(data);
|
||||
$('#branch_chosen').remove();
|
||||
|
||||
Reference in New Issue
Block a user