<% n_inputs = 0 %>

<% content_for :pi_input_form do %>
<form role="form" style="width:60%">
  <div class="form-group">
    <% @object.components.each do |cname, component| %>
      <% next if !component %>
      <% component[:script_parameters].andand.each do |pname, pvalue_spec| %>
        <% if pvalue_spec.is_a? Hash %>
          <% if (pvalue_spec[:description] or
                 ((pvalue_spec[:required] or pvalue_spec[:optional] == false) and
                  not pvalue_spec[:value])) %>
            <% n_inputs += 1 %>
            <label for="<% "#{cname}-#{pname}" %>">
              <%= @object.component_input_title(cname, pname) %>
            </label>
            <div>
              <p class="form-control-static">
                <%= render_pipeline_component_attribute @object, :components, [cname, :script_parameters, pname.to_sym], pvalue_spec %>
              </p>
            </div>
            <p class="help-block">
              <%= pvalue_spec[:description] %>
            </p>
          <% end %>
        <% end %>
      <% end %>
    <% end %>
  </div>
</form>
<% end %>

<% if n_inputs == 0 %>
  <p>This pipeline does not need any further inputs specified. You can start it by clicking the "Run" button whenever you're ready. (It's not too late to change existing settings, though.)</p>
<% else %>
  <p><i>Provide <%= n_inputs > 1 ? 'values' : 'a value' %> for the following <%= n_inputs > 1 ? 'parameters' : 'parameter' %>, then click the "Run" button to start the pipeline.</i></p>
  <%= content_for :pi_input_form %>

  <%= link_to(url_for('pipeline_instance[state]' => 'RunningOnServer'),
      class: 'btn btn-primary run-pipeline-button',
      method: :patch
      ) do %>
    Run <i class="fa fa-fw fa-play"></i>
  <% end %>

<% end %>

<div style="margin-top: 1em;">
  <p>Click the "Components" tab above to see a full list of pipeline settings.</p>
</div>