[refs #478] Change js handler logic

This commit is contained in:
konstantin.grabar 2012-05-24 16:51:39 +04:00
parent 3d2bcdd019
commit 0958299f51
2 changed files with 9 additions and 11 deletions

View File

@ -46,21 +46,19 @@ $(document).ready(function() {
return false; return false;
}); });
$("select#build_list_update_type").change(function() { $("select#build_list_save_to_platform_id").change(function() {
if ( $(this).val() == "bugfix" || $(this).val() == "security" ) { if ( $.inArray(parseInt($("select#build_list_save_to_platform_id").val()), FROZEN_PLS) == 0 ) {
$("select#build_list_save_to_platform_id option").each(function(i,el) { $("select#build_list_update_type option").each(function(i,el) {
$(el).removeAttr("disabled"); if ( $.inArray($(el).attr("value"), ["security", "bugfix"]) == -1 ) {
$(el).attr("disabled", "disabled");
// If disabled option is selected - select 'bugfix':
if ( $(el).attr("selected") ) {
$( $('select#build_list_update_type option[value="bugfix"]') ).attr("selected", "selected");
}
}
}); });
} else { } else {
$("select#build_list_save_to_platform_id option").each(function(i,el) { $("select#build_list_update_type option").removeAttr("disabled");
if ( $.inArray(parseInt($(el).attr("value")), FROZEN_PLS) == 0 ) {
$(el).attr("disabled", "disabled");
// If disabled option is selected - select blank repository (it is always first):
if ( $(el).attr("selected") ) {
$( $("select#build_list_save_to_platform_id option")[0] ).attr("selected", "selected");
}
}
});
} }
}); });
$("select#build_list_update_type").trigger('change'); $("select#build_list_update_type").trigger('change');

View File

@ -11,7 +11,7 @@
.offset25{:style => 'padding-left: 25px'}= render 'include_repos', :platform => pl .offset25{:style => 'padding-left: 25px'}= render 'include_repos', :platform => pl
%section.right %section.right
%h3= t("activerecord.attributes.build_list.save_to_platform") %h3= t("activerecord.attributes.build_list.save_to_platform")
.lineForm= f.select :save_to_platform_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]}, :include_blank => true .lineForm= f.select :save_to_platform_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]}
%h3= t("activerecord.attributes.build_list.project_version") %h3= t("activerecord.attributes.build_list.project_version")
- if controller.action_name == 'new' - if controller.action_name == 'new'
.lineForm= f.select :project_version, @project.versions_for_group_select, :selected => "latest_" + @project.default_branch .lineForm= f.select :project_version, @project.versions_for_group_select, :selected => "latest_" + @project.default_branch