<commit_before><%
   asset ||= nil
   object ||= nil
   entity=controller_name.singularize
   display_asset = nil
   path_to_object = nil
   if asset == "data_file"
      display_asset = @display_data_file
      path_to_object = data_file_path(@data_file).concat("/#{controller_name}/#{object.id}")
   elsif asset == "sop"
     display_asset = @sop
     path_to_object = sop_path(@sop).concat("/#{controller_name}/#{object.id}")
   end
%>
<%= form_for_with_callbacks object,
  :url=> path_to_object,
  :before=>"$('update_#{object.id}').disabled=true;",
  :loaded=>"$('update_#{object.id}').disabled=false;",
  :html=>{:method=>:put, :id => "edit_condition_or_factor_#{object.id}_form", :style => "display:none", :remote => true} do |f| -%>


  <div class="conditions_or_factors" >
  <h4 style="border-bottom: 1px solid #DDD; width: 20em;"> Edit this entry </h4>
  <table class='conditions_or_factor_table'>
    <tr>
      <th>Item</th>
      <th>Unit</th>
      <% if entity == "studied_factor" %>
         <th>Start value</th>
         <th>End value</th>
         <th>SD</th>
      <% elsif entity == 'experimental_condition' %>
        <th>Value</th>
      <% end %>
    </tr>
    <tr>

      <% if entity == "studied_factor" %>
        <td><%=  f.collection_select :measured_item_id, MeasuredItem.factors_studied_items.sort{|a,b| a.title <=> b.title},:id,:title, {}, {:onchange => "additionalFieldForItem('edit_condition_or_factor_#{object.id}_form', '#{object.id}')"} %></td>
        <td><%=  f.collection_select :unit_id, Unit.factors_studied_units.sort{|a,b| a.order <=> b.order},:id,:symbol %></td>
      <% elsif entity == "experimental_condition" %>
        <td><%=  f.collection_select :measured_item_id, MeasuredItem.all.sort{|a,b| a.title <=> b.title},:id,:title, {}, {:onchange => "additionalFieldForItem('edit_condition_or_factor_#{object.id}_form', '#{object.id}')"} %></td>
        <td><%=  f.collection_select :unit_id, Unit.all.sort{|a,b| a.order <=> b.order},:id,:symbol %></td>
      <% end %>

      <td><%= f.text_field :start_value,:size=>4 %></td>

      <% if entity == "studied_factor" %>
          <td><%= f.text_field :end_value,:size=>4 %></td>
          <td><%= f.text_field :standard_deviation,:size=>4 %></td>
      <% end %>

      <%= hidden_field_tag "version", display_asset.version -%>
    </tr>
  </table>

  <div id="<%= object.id -%>growth_medium_or_buffer_description" class="growth_medium_or_buffer_description" style="display: none">
      <%= hidden_field_tag "annotation[attribute_name]", "description" -%>
      Please enter the description:<br/>
      <%= text_area_tag "annotation[value]", try_block{Annotation.for_annotatable(object.class.name, object.id).with_attribute_name('description').first.value.text}, :cols => 45 -%>
  </div>

  <div id="<%= object.id -%>substance_condition_factor" class="substance_condition_factor" style="display: none">
    <%= render :partial=>"layouts/substances_autocomplete", :locals => {:name => "#{object.id}_substance", :resource => object}%>
  </div>

  <div class='border_top'>
    <%= f.submit "Update", :id => "update_#{object.id}" %> or <%= link_to_function "Cancel" do |page|
          page.visual_effect :fade, "edit_condition_or_factor_#{object.id}_form"
          page["edit_on_#{object.id}"].toggle
          page["edit_off_#{object.id}"].toggle
     end
    -%>
  </div>

  </div>
  <%= javascript_tag "additionalFieldForItem('edit_condition_or_factor_#{object.id}_form', #{object.id} )"-%>

<% end -%>

<commit_msg>OPSK-1374 bootstrap editing factors studied<commit_after><%
  asset ||= nil
  object ||= nil
  entity=controller_name.singularize
  display_asset = nil
  path_to_object = nil
  if asset == "data_file"
    display_asset = @display_data_file
    path_to_object = data_file_path(@data_file).concat("/#{controller_name}/#{object.id}")
  elsif asset == "sop"
    display_asset = @sop
    path_to_object = sop_path(@sop).concat("/#{controller_name}/#{object.id}")
  end
%>
<%= form_for_with_callbacks object,
                            :url => path_to_object,
                            :before => "$('update_#{object.id}').disabled=true;",
                            :loaded => "$('update_#{object.id}').disabled=false;",
                            :html => {:method => :put, :id => "edit_condition_or_factor_#{object.id}_form", :style => "display:none", :remote => true} do |f| -%>


    <div class="conditions_or_factors">
      <h4 style="border-bottom: 1px solid #DDD; width: 20em;"> Edit this entry </h4>
      <table class='conditions_or_factor_table'>
        <tr>
          <th>Item</th>
          <th>Unit</th>
          <% if entity == "studied_factor" %>
              <th>Start value</th>
              <th>End value</th>
              <th>SD</th>
          <% elsif entity == 'experimental_condition' %>
              <th>Value</th>
          <% end %>
        </tr>
        <div class="form-group">
          <tr>

            <% if entity == "studied_factor" %>
                <td><%= f.collection_select :measured_item_id, MeasuredItem.factors_studied_items.sort { |a, b| a.title <=> b.title }, :id, :title, {}, {:onchange => "additionalFieldForItem('edit_condition_or_factor_#{object.id}_form', '#{object.id}')", :class => "form-control"} %></td>
                <td><%= f.collection_select :unit_id, Unit.factors_studied_units.sort { |a, b| a.order <=> b.order }, :id, :symbol, {}, :class => "form-control" %></td>
            <% elsif entity == "experimental_condition" %>
                <td><%= f.collection_select :measured_item_id, MeasuredItem.all.sort { |a, b| a.title <=> b.title }, :id, :title, {}, {:onchange => "additionalFieldForItem('edit_condition_or_factor_#{object.id}_form', '#{object.id}')", :class => "form-control"} %></td>
                <td><%= f.collection_select :unit_id, Unit.all.sort { |a, b| a.order <=> b.order }, :id, :symbol, {}, :class => "form-control" %></td>
            <% end %>

            <td><%= f.text_field :start_value, :size => 4, :class => "form-control" %></td>

            <% if entity == "studied_factor" %>
                <td><%= f.text_field :end_value, :size => 4, :class => "form-control" %></td>
                <td><%= f.text_field :standard_deviation, :size => 4, :class => "form-control" %></td>
            <% end %>

            <%= hidden_field_tag "version", display_asset.version -%>
          </tr>
          </tr>
      </table>

      <div id="<%= object.id -%>growth_medium_or_buffer_description" class="growth_medium_or_buffer_description" style="display: none">
        <%= hidden_field_tag "annotation[attribute_name]", "description" -%>
        Please enter the description:<br/>
        <%= text_area_tag "annotation[value]", try_block { Annotation.for_annotatable(object.class.name, object.id).with_attribute_name('description').first.value.text }, :cols => 45, :class => "form-control" -%>
      </div>

      <div id="<%= object.id -%>substance_condition_factor" class="substance_condition_factor" style="display: none">
        <%= render :partial => "layouts/substances_autocomplete", :locals => {:name => "#{object.id}_substance", :resource => object} %>
      </div>

      <div class='border_top'>
        <%= f.submit "Update", :id => "update_#{object.id}", :class => 'btn btn-primary' %>
        or <%= link_to_function "Cancel" do |page|
        page.visual_effect :fade, "edit_condition_or_factor_#{object.id}_form"
        page["edit_on_#{object.id}"].toggle
        page["edit_off_#{object.id}"].toggle
      end
      -%>
      </div>

    </div>
    <%= javascript_tag "additionalFieldForItem('edit_condition_or_factor_#{object.id}_form', #{object.id} )" -%>

<% end -%>


{'fraction_non_alphanumeric': 0.19326748115414608, 'fraction_numerical': 0.0031193137509747857, 'mean_word_length': 3.298882681564246, 'pattern_counts': {'":': 0, '<': 153, '<?xml version=': 0, '>': 200, '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': '7485646', 'n_tokens_mistral': 2740, 'n_tokens_neox': 2598, 'n_words': 442}