%= form_for @composer.job_invocation, :html => {'data-refresh-url' => refresh_job_invocations_path, :id => 'job_invocation_form'} do |f| %>
<%= selectable_f f, :job_category, @composer.available_job_categories, {}, :label => _('Job category') %>
<% selected_templates_per_provider = {} %>
<% @composer.displayed_provider_types.each do |provider_type| %>
<%= f.fields_for 'providers' do |providers_fields| %>
<%= providers_fields.fields_for provider_type do |provider_type_fields| %>
<% templates_for_provider = @composer.templates_for_provider(provider_type) %>
<% selected_templates_per_provider[provider_type] = @composer.preselected_template_for_provider(provider_type) || templates_for_provider.first %>
<%= selectable_f provider_type_fields, 'job_template_id', templates_for_provider.map { |t| [t.name, t.id] },
{ :selected => selected_templates_per_provider[provider_type].try(:id) },
{ :class => 'job_template_selector', :label => _('Job template'),
:data => { :provider_type => provider_type }, :required => true, :onchange => "template_change(this);" }%>
<% end %>
<% end %>
<% end %>
<%= fields_for @composer.targeting do |targeting_fields| %>
<% @composer.available_bookmarks.each do |bookmark| %>
<% end %>
<%= selectable_f targeting_fields, :bookmark_id, @composer.available_bookmarks.map { |b| [b.name, b.id] }, :selected => @composer.targeting.bookmark_id, :include_blank => true %>
<%= textarea_f targeting_fields, :search_query, :value => @composer.displayed_search_query, :rows => 5 %>
<% @composer.displayed_provider_types.each do |provider_type| %>
<% end %>
<%= number_f f, :concurrency_level, :label => _('Concurrency level'), :placeholder => 'N', :min => 1, :help_inline => N_("Run at most N tasks at a time") %>
<%= number_f f, :time_span, :label => _('Time span'), :placeholder => 'N', :min => 1, :help_inline => N_("Distribute execution over N seconds") %>
<% end %>
<%= trigger_selector f, @composer.triggering %>
<%= render :partial => 'preview_hosts_modal' %>
<%= submit_or_cancel f, false, :cancel_path => job_invocations_path %>
<% end %>