Merge pull request #255 from abf/rosa-build:253-extra_repositories_to_mass_builds

#253 Add extra build for platform repositories to mass builds
This commit is contained in:
avokhmin 2013-08-02 17:10:46 +04:00
commit 348b76024c
3 changed files with 17 additions and 7 deletions

View File

@ -26,4 +26,12 @@ $(document).ready(function() {
.attr('checked', false);
}
});
var autocomplete_repos = $('.autocomplete-form.extra_repositories #extra_repositories');
var default_autocomplete_path = $('#autocomplete_extra_repos_path').val();
$('#mass_build_build_for_platform_id').on('change', function() {
var path = default_autocomplete_path + '&build_for_platform_id=' + $(this).val();
autocomplete_repos.attr('data-autocomplete', path);
});
$('#mass_build_build_for_platform_id').trigger('change');
});

View File

@ -16,11 +16,11 @@ class AutocompletesController < ApplicationController
end
def autocomplete_extra_repositories
# Only personal repositories can be attached to the build
Platform.includes(:repositories).personal.search(params[:term])
.accessible_by(current_ability, :read)
.search_order.limit(5).each do |platform|
# Only personal and build for platform repositories can be attached to the build
Platform.includes(:repositories).search(params[:term]).search_order
.accessible_by(current_ability, :read).limit(5)
.where("platforms.platform_type = 'personal' OR platforms.id = ?",
params[:build_for_platform_id].to_i).each do |platform|
platform.repositories.each do |repository|
label = "#{platform.name}/#{repository.name}"
results << { :id => repository.id,

View File

@ -25,6 +25,8 @@
%h3= t('activerecord.attributes.build_list.build_for_platform')
= f.collection_select :build_for_platform_id, Platform.main, :id, :name
.both
= hidden_field_tag :autocomplete_extra_repos_path,
"#{autocomplete_extra_repositories_autocompletes_path}?#{{:platform_id => @mass_build.save_to_platform.try(:id)}.to_param}"
= render 'shared/autocomplete_form',
:field => :extra_repositories,
:field_class => Repository,
@ -32,7 +34,7 @@
:subject => @mass_build,
:autocomplete_path => autocomplete_extra_repositories_autocompletes_path
= render 'shared/autocomplete_form',
:field => :extra_build_lists,
:field => :extra_build_lists,
:field_class => BuildList,
:placeholder => '1000000',
:subject => @mass_build,
@ -41,4 +43,4 @@
.both
= f.check_box :auto_publish
= f.label :auto_publish
.both
.both