diff --git a/module/execution/css/create.css b/module/execution/css/create.css index 1d8a16b1f2..bc275a4497 100644 --- a/module/execution/css/create.css +++ b/module/execution/css/create.css @@ -19,6 +19,8 @@ #lifeTimeTips {display: none;} #teams_chosen .chosen-drop ul li .label {margin-top: 3px; background: #fff; color: #838a9d; border: 1px solid #d8d8d8;} +.chosen-container.chosen-highlight-selected .disabled-result.result-selected {background: none;} + #productsBox .row .col-sm-4 {padding-right: 13px;} #plansBox .row {display: inline-table; width: 102%;} #plansBox .row .col-sm-4 {display: inline-block; float: none; padding-right: 13px;} diff --git a/module/execution/css/edit.css b/module/execution/css/edit.css index 13a5a35dc3..7d3767b7d3 100644 --- a/module/execution/css/edit.css +++ b/module/execution/css/edit.css @@ -2,3 +2,5 @@ #plansBox .row {display: inline-table; width: 102%;} #plansBox .row .col-sm-4 {display: inline-block; float: none;} + +.chosen-container.chosen-highlight-selected .disabled-result.result-selected {background: none;} diff --git a/module/execution/js/common.js b/module/execution/js/common.js index 9a831597b7..23d5c21ed1 100644 --- a/module/execution/js/common.js +++ b/module/execution/js/common.js @@ -124,18 +124,6 @@ function computeEndDate(delta) */ function loadBranches(product) { - $("#productsBox select[name^='products']").each(function() - { - var $product = $(product); - if($product.val() != 0 && $product.val() == $(this).val() && $product.attr('id') != $(this).attr('id') && !multiBranchProducts[$product.val()]) - { - alert(errorSameProducts); - $product.val(0); - $product.trigger("chosen:updated"); - return false; - } - }); - if($('#productsBox .input-group:last select:first').val() != 0) { var length = $('#productsBox .input-group').size(); @@ -232,6 +220,30 @@ function adjustPlanBoxMargin() } } +/** + * Make the selected product non clickable. + * + * @return void + */ +function nonClickableSelectedProduct() +{ + $("select[id^='products'] option[disabled='disabled']").removeAttr('disabled'); + + var selectedVal = []; + $("select[id^='products']").each(function() + { + var selectedProduct = $(this).val(); + if(selectedProduct != 0 && $.inArray(selectedProduct, selectedVal) < 0 && !multiBranchProducts[selectedProduct]) selectedVal.push(selectedProduct); + }) + + $.each(selectedVal, function(index, value) + { + $("select[id^='products'] option[value='" + value +"']").attr('disabled', 'disabled'); + }) + + $("select[id^=products]").trigger('chosen:updated'); +} + /* Auto compute the work days. */ $(function() { diff --git a/module/execution/js/create.js b/module/execution/js/create.js index 440e45a60d..ae1df4888e 100644 --- a/module/execution/js/create.js +++ b/module/execution/js/create.js @@ -109,6 +109,9 @@ $(function() return false; } }); + + nonClickableSelectedProduct(); + $(document).on('change', "select[id^='products']", nonClickableSelectedProduct); }); function showLifeTimeTips() diff --git a/module/execution/js/edit.js b/module/execution/js/edit.js index 7f0807e178..4d83a62253 100644 --- a/module/execution/js/edit.js +++ b/module/execution/js/edit.js @@ -67,6 +67,9 @@ $(function() } } }); + + nonClickableSelectedProduct(); + $(document).on('change', "select[id^='products']", nonClickableSelectedProduct); }) var lastProjectID = $("#project").val();