From d24422f757b9eac5122b2f03a7ad783e69e707d3 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 16 Apr 2012 20:06:34 +0400 Subject: [PATCH] [refs #223] Add branch auto select --- app/assets/javascripts/extra/build_list.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index 682cd9c4a..14778eaff 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -23,6 +23,8 @@ $(document).ready(function() { $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled').removeAttr('checked'); } }); + + setBranchSelected(); }); $('#build_list_pl_id').trigger('change'); @@ -47,3 +49,17 @@ function setPlChecked(pointer, checked) { pl_cbx.removeAttr('checked'); } } + +function setBranchSelected() { + var pl_id = $('#build_list_pl_id').val(); + // Checks if selected platform is main or not: + if ( $('.all_platforms').find('input[type="checkbox"][value=' + pl_id + '].build_bpl_ids').size() > 0 ) { + var pl_name = $('#build_list_pl_id option[value="' + pl_id + '"]').text().match(/([\w-]+)\/[\w-]+/)[1]; + var branch_pl_opt = $('#build_list_project_version option[value="latest_' + pl_name + '"]'); + // If there is branch we need - set it selected: + if ( branch_pl_opt.size() > 0 ) { + $('#build_list_project_version option[selected]').removeAttr('selected'); + branch_pl_opt.attr('selected', 'selected'); + } + } +}