<commit_before><% if @defence_request.new_record? %>
  <%= render 'solicitor_search', object: @defence_request %>
<% end %>

<%= bootstrap_form_for(@defence_request) do |f| %>
  <%= render 'shared/form_errors', object: @defence_request %>

  <% if @defence_request.new_record? %>
    <%= f.form_group :solicitor_type, label: {text: t('solicitor_type')} do %>
      <%= f.radio_button :solicitor_type, :duty, label: t('duty'), name: 'defence_request[solicitor_type]', inline: true, class: 'solicitor_type_radio', checked: true %>
      <%= f.radio_button :solicitor_type, :own, label: t('own'), name: 'defence_request[solicitor_type]', inline: true, class: 'solicitor_type_radio' %>
    <% end %>
  <% end %>

  <!-- details -->
  <div class="panel panel-default details">
    <div class="panel-heading">
      <h3 class="panel-title"><%= t('details') %></h3>
    </div>
    <div class="panel-body">
      <%= f.text_field :solicitor_name, label: t('solicitor_name'), autofocus: true %>
      <%= f.text_field :solicitor_firm, label: t('solicitor_firm') %>
      <%= f.select :scheme, solicitor_schemes, {label: t('scheme')} %>
      <%= f.text_field :phone_number, label: t('phone_number') %>
      <%= f.text_field :custody_number, label: t('custody_number') %>
      <%= f.text_field :allegations, label: t('allegations') %>
      <%= f.time_select :time_of_arrival, {label: t('time_of_arrival')}, {class: 'time-select'} %>
    </div>
  </div>
  <!-- detainee -->
  <div class="panel panel-default detainee">
    <div class="panel-heading">
      <h3 class="panel-title"><%= t('detainee') %></h3>
    </div>
    <div class="panel-body">
      <%= f.text_field :detainee_surname, label: t('detainee_surname') %>
      <%= f.text_field :detainee_first_name, label: t('detainee_first_name') %>

      <%= f.form_group :gender, label: {text: t('gender')} do %>
        <%= f.radio_button :gender, :male, label: t('male'), name: 'defence_request[gender]', inline: true %>
        <%= f.radio_button :gender, :female, label: t('female'), name: 'defence_request[gender]', inline: true %>
      <% end %>

      <%= f.check_box :adult, label: t('adult') %>

      <%= f.date_select :date_of_birth, {
          start_year: Date.today.year,
          end_year: 120.years.ago.year,
          label: t('date_of_birth')
      }, {
                            class: 'time-select'
                        } %>
      <%= f.check_box :appropriate_adult, label: t('appropriate_adult') %>
    </div>
  </div>
  <!-- comments -->
  <div class="panel panel-default comments">
    <div class="panel-heading">
      <h3 class="panel-title"><%= t('comments') %></h3>
    </div>
    <div class="panel-body">
      <%= f.text_area :comments, label: t('comments'), rows: '5' %>
    </div>
  </div>

  <%= f.submit class: 'btn btn-primary' %>

  <% if @defence_request.new_record? %>
    <%= link_to t('cancel'), defence_requests_path, class: 'btn btn-default cancel' %>
  <% else %>
    <%= link_to t('cancel'), defence_requests_path, class: 'btn btn-default cancel' %>
  <% end %>

<% end %>

<% if @defence_request.new_record? %>
  <script>
    $(document).ready(function () {

      // Clear solicitor search results on ESC keypress
      $(document).on('keyup', function(event) {
        if($('.solicitor_results_list *').length > 0 && event.keyCode === 27){
          $('.solicitor_results_list').empty();
        }
      });<commit_msg>use keydown to trigger clearing of solicitor results rather than keyup<commit_after><% if @defence_request.new_record? %>
  <%= render 'solicitor_search', object: @defence_request %>
<% end %>

<%= bootstrap_form_for(@defence_request) do |f| %>
  <%= render 'shared/form_errors', object: @defence_request %>

  <% if @defence_request.new_record? %>
    <%= f.form_group :solicitor_type, label: {text: t('solicitor_type')} do %>
      <%= f.radio_button :solicitor_type, :duty, label: t('duty'), name: 'defence_request[solicitor_type]', inline: true, class: 'solicitor_type_radio', checked: true %>
      <%= f.radio_button :solicitor_type, :own, label: t('own'), name: 'defence_request[solicitor_type]', inline: true, class: 'solicitor_type_radio' %>
    <% end %>
  <% end %>

  <!-- details -->
  <div class="panel panel-default details">
    <div class="panel-heading">
      <h3 class="panel-title"><%= t('details') %></h3>
    </div>
    <div class="panel-body">
      <%= f.text_field :solicitor_name, label: t('solicitor_name'), autofocus: true %>
      <%= f.text_field :solicitor_firm, label: t('solicitor_firm') %>
      <%= f.select :scheme, solicitor_schemes, {label: t('scheme')} %>
      <%= f.text_field :phone_number, label: t('phone_number') %>
      <%= f.text_field :custody_number, label: t('custody_number') %>
      <%= f.text_field :allegations, label: t('allegations') %>
      <%= f.time_select :time_of_arrival, {label: t('time_of_arrival')}, {class: 'time-select'} %>
    </div>
  </div>
  <!-- detainee -->
  <div class="panel panel-default detainee">
    <div class="panel-heading">
      <h3 class="panel-title"><%= t('detainee') %></h3>
    </div>
    <div class="panel-body">
      <%= f.text_field :detainee_surname, label: t('detainee_surname') %>
      <%= f.text_field :detainee_first_name, label: t('detainee_first_name') %>

      <%= f.form_group :gender, label: {text: t('gender')} do %>
        <%= f.radio_button :gender, :male, label: t('male'), name: 'defence_request[gender]', inline: true %>
        <%= f.radio_button :gender, :female, label: t('female'), name: 'defence_request[gender]', inline: true %>
      <% end %>

      <%= f.check_box :adult, label: t('adult') %>

      <%= f.date_select :date_of_birth, {
          start_year: Date.today.year,
          end_year: 120.years.ago.year,
          label: t('date_of_birth')
      }, {
                            class: 'time-select'
                        } %>
      <%= f.check_box :appropriate_adult, label: t('appropriate_adult') %>
    </div>
  </div>
  <!-- comments -->
  <div class="panel panel-default comments">
    <div class="panel-heading">
      <h3 class="panel-title"><%= t('comments') %></h3>
    </div>
    <div class="panel-body">
      <%= f.text_area :comments, label: t('comments'), rows: '5' %>
    </div>
  </div>

  <%= f.submit class: 'btn btn-primary' %>

  <% if @defence_request.new_record? %>
    <%= link_to t('cancel'), defence_requests_path, class: 'btn btn-default cancel' %>
  <% else %>
    <%= link_to t('cancel'), defence_requests_path, class: 'btn btn-default cancel' %>
  <% end %>

<% end %>

<% if @defence_request.new_record? %>
  <script>
    $(document).ready(function () {

      // Clear solicitor search results on ESC keypress
      $(document).on('keydown', function(event) {
        if($('.solicitor_results_list *').length > 0 && event.keyCode === 27){
          $('.solicitor_results_list').empty();
        }
      });
{'fraction_non_alphanumeric': 0.19724437998549674, 'fraction_numerical': 0.0037708484408992024, 'mean_word_length': 3.3839796567069294, 'pattern_counts': {'":': 0, '<': 137, '<?xml version=': 0, '>': 139, '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': '7236788', 'n_tokens_mistral': 2605, 'n_tokens_neox': 2365, 'n_words': 468}