* Finish task #73985.
This commit is contained in:
@@ -162,9 +162,9 @@ function loadBranches(product)
|
||||
}
|
||||
});
|
||||
|
||||
if($('#productsBox .input-group:last select:first').val() != 0)
|
||||
if($('#productsBox .row .input-group:last select:first').val() != 0)
|
||||
{
|
||||
var length = $('#productsBox .input-group').size();
|
||||
var length = $('#productsBox .row .input-group').size();
|
||||
$('#productsBox .row').append('<div class="col-sm-4">' + $('#productsBox .col-sm-4:last').html() + '</div>');
|
||||
if($('#productsBox .input-group:last select').size() >= 2) $('#productsBox .input-group:last select:last').remove();
|
||||
$('#productsBox .input-group:last .chosen-container').remove();
|
||||
@@ -179,7 +179,8 @@ function loadBranches(product)
|
||||
if($inputgroup.find('.chosen-container').size() >= 2) $inputgroup.find('.chosen-container:last').remove();
|
||||
|
||||
var index = $inputgroup.find('select:first').attr('id').replace('products' , '');
|
||||
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + $(product).val() + "&oldBranch=0¶m=active"), function(data)
|
||||
var oldBranch = $(product).attr('data-branch') !== undefined ? $(product).attr('data-branch') : 0;
|
||||
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + $(product).val() + "&oldBranch=" + oldBranch + "¶m=active"), function(data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
@@ -206,12 +207,13 @@ function loadPlans(product, branchID)
|
||||
|
||||
var productID = $(product).val();
|
||||
var branchID = typeof(branchID) == 'undefined' ? 0 : branchID;
|
||||
var planID = $(product).attr('data-plan') !== undefined ? $(product).attr('data-plan') : 0;
|
||||
var index = $(product).attr('id').replace('products', '');
|
||||
|
||||
$("input[name='products[" + index + "]']").remove();
|
||||
$("input[name='branch[" + index + "]']").remove();
|
||||
|
||||
$.get(createLink('product', 'ajaxGetPlans', "productID=" + productID + '&branch=0,' + branchID + '&planID=0&fieldID&needCreate=&expired=unexpired¶m=skipParent,multiple'), function(data)
|
||||
$.get(createLink('product', 'ajaxGetPlans', "productID=" + productID + '&branch=0,' + branchID + '&planID=' + planID + '&fieldID&needCreate=&expired=unexpired,noclosed¶m=skipParent,multiple'), function(data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
|
||||
+11
-15
@@ -150,27 +150,19 @@ function setParentProgram(parentProgram)
|
||||
{
|
||||
$('#budget').val('');
|
||||
|
||||
var select = data.allProducts;
|
||||
var planSelect = data.plans;
|
||||
var productSelectHtml = data.allProducts;
|
||||
var planSelectHtml = data.plans;
|
||||
|
||||
var index = 0;
|
||||
$('#productsBox .row .col-sm-4 .input-group').each(function()
|
||||
$('#productsBox .row .col-sm-4 .input-group').each(function(index)
|
||||
{
|
||||
var selectedProduct = $(this).find('[name^=products]').val();
|
||||
var selectedBranch = $(this).find('[name^=branch]').val();
|
||||
var selectedPlan = $('#plan' + index ).find('[name^=plans]').val();
|
||||
|
||||
$(this).html(select);
|
||||
$(this).find('[name^=products]').attr('name', 'products[' + index + ']').attr('id', 'products' + index).attr('data-branch', selectedBranch);
|
||||
$(this).html(productSelectHtml);
|
||||
$(this).find('[name^=products]').attr('name', 'products[' + index + ']').attr('id', 'products' + index).attr('data-branch', selectedBranch).attr('data-plan', selectedPlan);
|
||||
$(this).find('[name^=products]').val(selectedProduct).chosen().change();
|
||||
|
||||
index ++;
|
||||
});
|
||||
|
||||
/* Hide product and plan dropdown controls. */
|
||||
$('#plansBox .col-sm-4:not(:last)').remove();
|
||||
$('#plansBox .col-sm-4').children().remove();
|
||||
$('#plansBox .col-sm-4').prepend(planSelect);
|
||||
$('#plansBox .col-sm-4 select').chosen();
|
||||
}
|
||||
|
||||
if(parentProgram != 0)
|
||||
@@ -282,6 +274,9 @@ function setAclList(programID)
|
||||
*/
|
||||
function loadBranches(product)
|
||||
{
|
||||
/* When selecting a product, delete a plan that is empty by default. */
|
||||
$("#planDefault").remove();
|
||||
|
||||
$("#productsBox select[name^='products']").each(function()
|
||||
{
|
||||
var $product = $(product);
|
||||
@@ -348,9 +343,10 @@ function loadPlans(product, branchID)
|
||||
|
||||
var productID = $(product).val();
|
||||
var branchID = typeof(branchID) == 'undefined' ? 0 : branchID;
|
||||
var planID = $(product).attr('data-plan') !== undefined ? $(product).attr('data-plan') : 0;
|
||||
var index = $(product).attr('id').replace('products', '');
|
||||
|
||||
$.get(createLink('product', 'ajaxGetPlans', "productID=" + productID + '&branch=0,' + branchID + '&planID=0&fieldID&needCreate=&expired=unexpired,noclosed¶m=skipParent,multiple'), function(data)
|
||||
$.get(createLink('product', 'ajaxGetPlans', "productID=" + productID + '&branch=0,' + branchID + '&planID=' + planID + '&fieldID&needCreate=&expired=unexpired,noclosed¶m=skipParent,multiple'), function(data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
|
||||
@@ -2,8 +2,34 @@ $(function()
|
||||
{
|
||||
$('#parent').change(function()
|
||||
{
|
||||
var programID = $(this).val();
|
||||
var programID = $(this).val();
|
||||
var lastSelectedID = $('#parent').attr('data-lastSelected');
|
||||
|
||||
setAclList(programID);
|
||||
|
||||
$.get(createLink('project', 'ajaxGetObjectInfo', 'objectType=program&objectID=' + lastSelectedID + "&selectedProgramID=" + programID), function(data)
|
||||
{
|
||||
var data = JSON.parse(data);
|
||||
selectedParent = programID != 0 ? data.selectedProgramPath[1] : 0;
|
||||
lastSelectedParent = lastSelectedID != 0 ? data.objectPath[1] : 0;
|
||||
|
||||
if(selectedParent != lastSelectedParent)
|
||||
{
|
||||
var productSelectHtml = data.allProducts;
|
||||
var planSelectHtml = data.plans;
|
||||
|
||||
$('#productsBox .row .col-sm-4 .input-group').each(function(index)
|
||||
{
|
||||
var selectedProduct = $(this).find('[name^=products]').val();
|
||||
var selectedBranch = $(this).find('[name^=branch]').val();
|
||||
var selectedPlan = $('#plan' + index ).find('[name^=plans]').val();
|
||||
|
||||
$(this).html(productSelectHtml);
|
||||
$(this).find('[name^=products]').attr('name', 'products[' + index + ']').attr('id', 'products' + index).attr('data-branch', selectedBranch).attr('data-plan', selectedPlan);
|
||||
$(this).find('[name^=products]').val(selectedProduct).chosen().change();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
adjustProductBoxMargin();
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
$programList = array($project->parent => $program->name);
|
||||
}
|
||||
?>
|
||||
<td><?php echo html::select('parent', $programList, $project->parent, "class='form-control chosen' $attr");?></td>
|
||||
<td><?php echo html::select('parent', $programList, $project->parent, "class='form-control chosen' data-lastSelected='{$project->parent}' $attr");?></td>
|
||||
<td colspan='2'></td>
|
||||
</tr>
|
||||
<?php endif;?>
|
||||
@@ -164,14 +164,7 @@
|
||||
<?php if($hasBranch) echo html::select("branch[$i]", $branchGroups[$product->id], $branchID, "class='form-control chosen' onchange=\"loadPlans('#products{$i}', this.value)\" data-last='" . $branchID . "'");?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if(in_array($product->id, $unmodifiableProducts) and in_array($branchID, $unmodifiableBranches))
|
||||
{
|
||||
echo html::hidden("products[$i]", $product->id);
|
||||
echo html::hidden("branch[$i]", $branchID);
|
||||
}
|
||||
$i++;
|
||||
?>
|
||||
<?php $i++;?>
|
||||
<?php endforeach;?>
|
||||
<?php endforeach;?>
|
||||
<div class='col-sm-4 <?php if($projectID) echo 'required';?>' style="padding-right: 6px;">
|
||||
|
||||
Reference in New Issue
Block a user