diff --git a/module/project/js/common.js b/module/project/js/common.js index d8c30f6519..9234174496 100644 --- a/module/project/js/common.js +++ b/module/project/js/common.js @@ -150,11 +150,12 @@ function loadBranches(product) /* When selecting a product, delete a plan that is empty by default. */ $("#planDefault").remove(); - var chosenProducts = 0; + var chosenProducts = []; $("#productsBox select[name^='products']").each(function() { var $product = $(product); - if($(this).val() > 0) chosenProducts ++; + var productID = $(this).val(); + if(productID > 0 && chosenProducts.indexOf(productID) == -1) chosenProducts.push(productID); if($product.val() != 0 && $product.val() == $(this).val() && $product.attr('id') != $(this).attr('id') && !multiBranchProducts[$product.val()]) { bootbox.alert(errorSameProducts); @@ -164,7 +165,7 @@ function loadBranches(product) } }); - chosenProducts > 1 ? $('.division').removeClass('hide') : $('.division').addClass('hide'); + chosenProducts.length > 1 ? $('.division').removeClass('hide') : $('.division').addClass('hide'); if($('#productsBox .input-group:last select:first').val() != 0) { diff --git a/module/project/js/create.js b/module/project/js/create.js index 7defd02346..64daca13ba 100644 --- a/module/project/js/create.js +++ b/module/project/js/create.js @@ -294,11 +294,12 @@ function loadBranches(product) /* When selecting a product, delete a plan that is empty by default. */ $("#planDefault").remove(); - var chosenProducts = 0; + var chosenProducts = []; $("#productsBox select[name^='products']").each(function() { - var $product = $(product); - if($(this).val() > 0) chosenProducts ++; + var $product = $(product); + var productID = $(this).val(); + if(productID > 0 && chosenProducts.indexOf(productID) == -1) chosenProducts.push(productID); if($product.val() != 0 && $product.val() == $(this).val() && $product.attr('id') != $(this).attr('id') && !multiBranchProducts[$product.val()]) { bootbox.alert(errorSameProducts); @@ -308,7 +309,7 @@ function loadBranches(product) } }); - (chosenProducts > 1 && model == 'waterfall') ? $('.division').removeClass('hide') : $('.division').addClass('hide'); + (chosenProducts.length > 1 && model == 'waterfall') ? $('.division').removeClass('hide') : $('.division').addClass('hide'); if($('#productsBox .row .input-group:last select:first').val() != 0) {