<commit_before><% current_user_authorized_to_manage = @sample.new_record?|| @sample.can_manage? -%>

<div class="asset_form">


  <%= f.error_messages -%>

  <% if @sample.new_record? %>
      <div class="form-group">
      <%= f.select :sample_type_id,
                   options_for_select(SampleType.all.collect { |st| [st.title, st.id] }, @sample.sample_type_id),
                   {:include_blank => 'Please select the appropriate Sample type' },:class => 'form-control' %>
      </div>
  <% end %>

  <div id="sample_attributes">
    <%= render :partial=>"sample_attributes_form",:locals=>{sample:@sample} %>
  </div>

  <div id="sample_extra_details" style="display:none">
    <%= render :partial => "projects/project_selector", :locals => { :resource => @sample,:allow_nil=> false} -%>
    <% if current_user_authorized_to_manage -%>
        <%= render :partial => "assets/asset_form_bottom", :locals=>{:f=>f,attribution_enable:false,show_publications:false,sharing_link:false} %>
    <% end %>
  </div>
  <%= preview_permission_popup_link(@sample)-%>

  <%= f.submit (@sample.new_record? ? "Create" : "Update"), :class => 'btn btn-primary',:id=>'sample_submit_btn',disabled:@sample.sample_type.nil? %>
    or
  <%= cancel_button(@sample.new_record? ? samples_path : sample_path(@sample)) %>
</div>

<script>
    <% unless @sample.sample_type.nil? %>
        $j('#sample_extra_details').show();
    <% end %>

    $j('#sample_sample_type_id').on('change', function () {
        if (this.value) {
            $j.ajax({
                url:"<%= attribute_form_samples_path %>",
                type: "get",
                data: {sample_type_id: this.value},
                dataType: "json",
                success: function(data) {
                    var replacement = "<div id='sample_attributes'>"+data["form"]+"</div>"
                    $j('#sample_attributes').replaceWith(replacement);
                    $j('#sample_submit_btn').prop('disabled',false);
                    $j('#sample_extra_details').show();
                },
                error: function(data) {
                    $j('#sample_attributes').replaceWith("<div id='sample_attributes'/>");
                    $j('#sample_submit_btn').prop('disabled',true);
                }
            });
        }
        else {
            $j('#sample_attributes').replaceWith("<div id='sample_attributes'/>");
            $j('#sample_submit_btn').prop('disabled',true);
            $j('#sample_extra_details').hide();
        }
    });

    $j('#sample_submit_btn').on('click', function() {
        previewPermissions();
        return(false);
    });


</script><commit_msg>added a temporary link for new sample type<commit_after><% current_user_authorized_to_manage = @sample.new_record?|| @sample.can_manage? -%>

<div class="asset_form">


  <%= f.error_messages -%>

  <% if @sample.new_record? %>
      <div class="form-group">
      <%= f.select :sample_type_id,
                   options_for_select(SampleType.all.collect { |st| [st.title, st.id] }, @sample.sample_type_id),
                   {:include_blank => 'Please select the appropriate Sample type' },:class => 'form-control' %>
        <span id="new_sample_type_link">or <%= link_to 'Define new sample type',new_sample_type_path %></span>
      </div>
  <% end %>

  <div id="sample_attributes">
    <%= render :partial=>"sample_attributes_form",:locals=>{sample:@sample} %>
  </div>

  <div id="sample_extra_details" style="display:none">
    <%= render :partial => "projects/project_selector", :locals => { :resource => @sample,:allow_nil=> false} -%>
    <% if current_user_authorized_to_manage -%>
        <%= render :partial => "assets/asset_form_bottom", :locals=>{:f=>f,attribution_enable:false,show_publications:false,sharing_link:false} %>
    <% end %>
  </div>
  <%= preview_permission_popup_link(@sample)-%>

  <%= f.submit (@sample.new_record? ? "Create" : "Update"), :class => 'btn btn-primary',:id=>'sample_submit_btn',disabled:@sample.sample_type.nil? %>
    or
  <%= cancel_button(@sample.new_record? ? samples_path : sample_path(@sample)) %>
</div>

<script>
    <% unless @sample.sample_type.nil? %>
        $j('#sample_extra_details').show();
    <% end %>

    $j('#sample_sample_type_id').on('change', function () {
        if (this.value) {
            $j.ajax({
                url:"<%= attribute_form_samples_path %>",
                type: "get",
                data: {sample_type_id: this.value},
                dataType: "json",
                success: function(data) {
                    var replacement = "<div id='sample_attributes'>"+data["form"]+"</div>"
                    $j('#sample_attributes').replaceWith(replacement);
                    $j('#sample_submit_btn').prop('disabled',false);
                    $j('#sample_extra_details').show();
                    $j('#new_sample_type_link').hide();
                },
                error: function(data) {
                    $j('#sample_attributes').replaceWith("<div id='sample_attributes'/>");
                    $j('#sample_submit_btn').prop('disabled',true);
                }
            });
        }
        else {
            $j('#sample_attributes').replaceWith("<div id='sample_attributes'/>");
            $j('#sample_submit_btn').prop('disabled',true);
            $j('#sample_extra_details').hide();
            $j('#new_sample_type_link').show();
        }
    });

    $j('#sample_submit_btn').on('click', function() {
        previewPermissions();
        return(false);
    });


</script>
{'fraction_non_alphanumeric': 0.18263688760806918, 'fraction_numerical': 0.0, 'mean_word_length': 2.702, 'pattern_counts': {'":': 0, '<': 66, '<?xml version=': 0, '>': 92, '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': '6937441', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1654, 'n_words': 232}