<commit_before><%= flash_and_form_errors %>
<%# if this is an empty batch (not one with errors) show the normal form %>
<% if @user_batch.lines.nil? %>
  <%= nice_form_for(@user_batch) do |f| %>
    <%= form_field(f, :batch, :type => :textarea, :required => true) %>
    <%= form_submit_button(f, :label => :create) %>
  <% end %>

<%# otherwise show a special form with info about each line %>
<% else %>

  <%= form_for(@user_batch, :html => {:class => 'user_batch_form'}) do |f| %>
    <% @user_batch.lines.each_with_index do |line, idx| %>
      <% ok = line[:user] && line[:user].valid? %>
      <div class="batch_line_with_info <%= ok ? 'line_ok' : 'line_error' %>">
        <input type="text" name="user_batch[lines][][text]" value="<%= line[:text] %>"/>
        <div class="info">
          <% if ok %>
            <i class="icon-ok"></i>
            <%= t('common.ok') %>
          <% else %>
            <i class="icon-exclamation"></i>
            <%= get_line_errors(line) %>
          <% end %>
        </div>
      </div>
    <% end %>
    <%= form_submit_button(f, :label => :try_again) %>
  <% end %>
<% end %><commit_msg>refactored user batch form<commit_after><%= flash_and_form_errors %>
<%# if this is an empty batch (not one with errors) show the normal form %>
<% if @user_batch.lines.nil? %>
  <%= elmo_form_for(@user_batch) do |f| %>
    <%= f.field(:batch, :type => :textarea, :required => true) %>
    <%= f.submit(:create) %>
  <% end %>

<%# otherwise show a special form with info about each line %>
<% else %>

  <%= form_for(@user_batch, :html => {:class => 'user_batch_form'}) do |f| %>
    <% @user_batch.lines.each_with_index do |line, idx| %>
      <% ok = line[:user] && line[:user].valid? %>
      <div class="batch_line_with_info <%= ok ? 'line_ok' : 'line_error' %>">
        <input type="text" name="user_batch[lines][][text]" value="<%= line[:text] %>"/>
        <div class="info">
          <% if ok %>
            <i class="icon-ok"></i>
            <%= t('common.ok') %>
          <% else %>
            <i class="icon-exclamation"></i>
            <%= get_line_errors(line) %>
          <% end %>
        </div>
      </div>
    <% end %>
    <%= form_submit_button(f, :label => :try_again) %>
  <% end %>
<% end %>
{'fraction_non_alphanumeric': 0.2163716814159292, 'fraction_numerical': 0.0, 'mean_word_length': 2.743377483443709, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6869313', 'n_tokens_mistral': 867, 'n_tokens_neox': 763, 'n_words': 170}