<commit_before><% @variable = @design.project.variables.find_by_id(params[:variable_id]) %>
<% @domain = @variable.domain || @project.domains.new %>

<div class="page-header">
  <h1>Edit Variable Domain <span style="font-size:0.4em"><%= @variable.name %></span></h1>
</div>

<form id="domain_form" class="form-horizontal">
  <div class="control-group">
    <label class="control-label">Name</label>
    <div class="controls">
      <%= text_field_tag "domain[name]", @domain.name, maxlength: 30, style: 'width:225px', autocomplete: 'off' %>
      <div class="help-block">Letter followed by letters, numbers, or underscores. Max length 30 characters.</div>
      <i>domain1_population</i>
    </div>
  </div>

  <div id="options" data-object="sortable">
    <%= render partial: 'domains/options' %>
  </div>
  <div class="btn-toolbar">
    <%= link_to 'Add Additional Options', '#', id: 'add_more_domain_options', class: 'btn btn-mini' %>
  </div>
</form>

<hr class="soften" style="margin-top:20px;" />

<div class="button-group pull-right">
  <% if @domain.new_record? %>
    <%= button_tag 'Create', data: { object: 'push-partial-change', target: '#domain_form', create: 'domain', position: params[:position], variable_id: @variable.id }, class: 'btn btn-primary' %>
  <% else %>
    <% other_variables = @domain.variables.count - 1 %>
    <%= button_tag "Update Existing Domain" + (other_variables > 0 ? " (linked to #{pluralize(other_variables, 'other variable')})" : ""), data: { object: 'push-partial-change', target: '#domain_form', update: 'domain', position: params[:position], variable_id: @variable.id }, class: 'btn btn-primary' %>
    or
    <%= button_tag 'Create New Domain', data: { object: 'push-partial-change', target: '#domain_form', create: 'domain', position: params[:position], variable_id: @variable.id }, class: 'btn btn-primary' %>
  <% end %>
  <% domains = @project.domains %>
  <% if domains.count > 0 %>
    or
    <span class="white-space:nowrap"><%= select_tag 'domain[id]', options_for_select( [['', nil]] + domains.collect{|d| [d.name, d.id]} ), class: "chzn-select" %>
    <%= button_tag 'Use Selected Domain', data: { object: 'push-partial-change', target: '#domain_id', create: 'domain', position: params[:position], variable_id: @variable.id }, class: 'btn btn-primary' %></span>
  <% end %>
  <%= button_tag 'Cancel', data: { object: 'hide-contour-modal', position: params[:position] }, class: 'btn' %>
</div>
<commit_msg>Changed button title for clarification<commit_after><% @variable = @design.project.variables.find_by_id(params[:variable_id]) %>
<% @domain = @variable.domain || @project.domains.new %>

<div class="page-header">
  <h1>Edit Variable Domain <span style="font-size:0.4em"><%= @variable.name %></span></h1>
</div>

<form id="domain_form" class="form-horizontal">
  <div class="control-group">
    <label class="control-label">Name</label>
    <div class="controls">
      <%= text_field_tag "domain[name]", @domain.name, maxlength: 30, style: 'width:225px', autocomplete: 'off' %>
      <div class="help-block">Letter followed by letters, numbers, or underscores. Max length 30 characters.</div>
      <i>domain1_population</i>
    </div>
  </div>

  <div id="options" data-object="sortable">
    <%= render partial: 'domains/options' %>
  </div>
  <div class="btn-toolbar">
    <%= link_to 'Add Additional Options', '#', id: 'add_more_domain_options', class: 'btn btn-mini' %>
  </div>
</form>

<hr class="soften" style="margin-top:20px;" />

<div class="button-group pull-right">
  <% if @domain.new_record? %>
    <%= button_tag 'Create', data: { object: 'push-partial-change', target: '#domain_form', create: 'domain', position: params[:position], variable_id: @variable.id }, class: 'btn btn-primary' %>
  <% else %>
    <% other_variables = @domain.variables.count - 1 %>
    <%= button_tag "Update Existing Domain" + (other_variables > 0 ? " (linked to #{pluralize(other_variables, 'other variable')})" : ""), data: { object: 'push-partial-change', target: '#domain_form', update: 'domain', position: params[:position], variable_id: @variable.id }, class: 'btn btn-primary' %>
    or
    <%= button_tag 'Copy Choices to New Domain', data: { object: 'push-partial-change', target: '#domain_form', create: 'domain', position: params[:position], variable_id: @variable.id }, class: 'btn btn-primary' %>
  <% end %>
  <% domains = @project.domains %>
  <% if domains.count > 0 %>
    or
    <span class="white-space:nowrap"><%= select_tag 'domain[id]', options_for_select( [['', nil]] + domains.collect{|d| [d.name, d.id]} ), class: "chzn-select" %>
    <%= button_tag 'Use Selected Domain', data: { object: 'push-partial-change', target: '#domain_id', create: 'domain', position: params[:position], variable_id: @variable.id }, class: 'btn btn-primary' %></span>
  <% end %>
  <%= button_tag 'Cancel', data: { object: 'hide-contour-modal', position: params[:position] }, class: 'btn' %>
</div>

{'fraction_non_alphanumeric': 0.20217917675544794, 'fraction_numerical': 0.006860371267150928, 'mean_word_length': 4.852420306965762, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 99, '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': '7319082', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1595, 'n_words': 384}