<commit_before><% @parent_collection = (@order.class.name.split('::').last.humanize if @order) || (@user.class.name.split('::').last.humanize if @user) %>
<% if @order %>
  <%= render :partial => 'spree/admin/shared/order_tabs', :locals => { :current => 'Addresses' } %>
<% end %>

<% content_for :page_title do %>
  <% if @user && !@order %>
    <%= link_to "#{Spree.t(:editing_user)} #{@user.try(:email)}", edit_admin_user_url(@user) %>
  <% end %>
<% end %>

<% content_for :page_actions do %>
  <li><%= button_link_to I18n.t(:new_address, scope: :address_book), new_admin_address_path(user_id: @user.try(:id), order_id: @order.try(:id)), :icon => 'plus' %></li>
  <li><%= button_link_to "Back to #{@parent_collection}", redirect_back_admin_addresses_url(user_id: @user.try(:id), order_id: @order.try(:id)), :icon => 'arrow-left' %></li>
<% end %>

<fieldset data-hook="admin_addresses" id="admin_user_edit_addresses" class="alpha twelve columns">
  <legend><%= Spree.t('addresses', :scope => 'admin.user') %></legend>

  <% if @addresses.blank? %>
    <div class="alpha twelve columns no-objects-found">
      No Addresses found,
      <%= link_to "Add one", new_admin_address_path(user_id: @user.try(:id), order_id: @order.try(:id)) %>!
    </div>
  <% else %>
    <table id="addresses">
      <thead>
        <tr class="<%= cycle('even', 'odd') %>">
          <th><%= I18n.t(:address, scope: :address_book) %></th>
          <% if @user %>
            <th class="align-center"><%= I18n.t(:def_bill, scope: :address_book) %></th>
            <th class="align-center"><%= I18n.t(:def_ship, scope: :address_book) %></th>
          <% end %>
          <% if @order %>
            <th class="align-center"><%= I18n.t(:order_bill, scope: :address_book) %></th>
            <th class="align-center"><%= I18n.t(:order_ship, scope: :address_book) %></th>
          <% end %>
          <th class="actions"></th>
        </tr>
      </thead>

      <tbody>
      <%= form_for @user || @order, url: update_addresses_admin_addresses_path(user_id: @user.try(:id), order_id: @order.try(:id)), method: :put do |f| %>
        <% @addresses.each do |address| %>
          <tr class="<%= cycle('even', 'odd') %>" id="address-<%= address.id %>">
            <td><%= address %></td>
            <% if @user %>
              <td class="align-center">
                <%= radio_button_tag 'user[bill_address_id]',
                  address.user_bill.try(:id) || address.id,
                  address.user_bill.present? %>
                <%= label_tag "user_bill_address_id_#{address.id}", '' %>
              </td>
              <td class="align-center">
                <%= radio_button_tag 'user[ship_address_id]',
                  address.user_ship.try(:id) || address.id,
                  address.user_ship.present? %>
                <%= label_tag "user_ship_address_id_#{address.id}", '' %>
              </td>
            <% end %>
            <% if @order %>
              <% disable = !@order.can_update_addresses? %>

              <td class="align-center">
                <%=
                  radio_button_tag 'order[bill_address_id]',
                    address.order_bill.try(:id) || address.id,
                    address.order_bill.present?,
                    disabled: disable,
                    readonly: disable
                %>
                <%= label_tag "order_bill_address_id_#{address.id}", '' %>
              </td>
              <td class="align-center">
                <%=
                  radio_button_tag 'order[ship_address_id]',
                    address.order_ship.try(:id) || address.id,
                    address.order_ship.present?,
                    disabled: disable,
                    readonly: disable
                %>
                <%= label_tag "order_ship_address_id_#{address.id}", '' %>
              </td>
            <% end %>
            <td class="actions">
              <% if address.primary_address.editable? %>
                <%= link_to_edit_url edit_admin_address_url(address.primary_address, user_id: @user.try(:id), order_id: @order.try(:id)), no_text: true, id: "edit-address-#{address.id}" %>
              <% end %>
            </td>
          </tr>
        <% end %>
        <div class="row">
          <div class="alpha twelve columns">
            <%= f.submit I18n.t(:update_default_addresses, scope: :address_book) %>
          </div>
        </div>
      <% end %>
      </tbody>
    </table>
  <% end %>
</fieldset><commit_msg>Move update button out of table, disable user radios if we can't update.<commit_after><% @parent_collection = (@order.class.name.split('::').last.humanize if @order) || (@user.class.name.split('::').last.humanize if @user) %>
<% if @order %>
  <%= render :partial => 'spree/admin/shared/order_tabs', :locals => { :current => 'Addresses' } %>
<% end %>

<% content_for :page_title do %>
  <% if @user && !@order %>
    <%= link_to "#{Spree.t(:editing_user)} #{@user.try(:email)}", edit_admin_user_url(@user) %>
  <% end %>
<% end %>

<% content_for :page_actions do %>
  <li><%= button_link_to I18n.t(:new_address, scope: :address_book), new_admin_address_path(user_id: @user.try(:id), order_id: @order.try(:id)), :icon => 'plus' %></li>
  <li><%= button_link_to "Back to #{@parent_collection}", redirect_back_admin_addresses_url(user_id: @user.try(:id), order_id: @order.try(:id)), :icon => 'arrow-left' %></li>
<% end %>

<fieldset data-hook="admin_addresses" id="admin_user_edit_addresses" class="alpha twelve columns">
  <legend><%= Spree.t('addresses', :scope => 'admin.user') %></legend>

  <% if @addresses.blank? %>
    <div class="alpha twelve columns no-objects-found">
      No Addresses found,
      <%= link_to "Add one", new_admin_address_path(user_id: @user.try(:id), order_id: @order.try(:id)) %>!
    </div>
  <% else %>
    <%= form_for @user || @order, url: update_addresses_admin_addresses_path(user_id: @user.try(:id), order_id: @order.try(:id)), method: :put do |f| %>
      <div class="row">
        <div class="alpha twelve columns">
          <%= f.submit I18n.t(:update_default_addresses, scope: :address_book) %>
        </div>
      </div>
      <table id="addresses">
        <thead>
          <tr class="<%= cycle('even', 'odd') %>">
            <th><%= I18n.t(:address, scope: :address_book) %></th>
            <% if @user %>
              <th class="align-center"><%= I18n.t(:def_bill, scope: :address_book) %></th>
              <th class="align-center"><%= I18n.t(:def_ship, scope: :address_book) %></th>
            <% end %>
            <% if @order %>
              <th class="align-center"><%= I18n.t(:order_bill, scope: :address_book) %></th>
              <th class="align-center"><%= I18n.t(:order_ship, scope: :address_book) %></th>
            <% end %>
            <th class="actions"></th>
          </tr>
        </thead>

        <tbody>
          <% @addresses.each do |address| %>
            <tr class="<%= cycle('even', 'odd') %>" id="address-<%= address.id %>">
              <td><%= address %></td>
              <% if @user %>
                <% disable_user = !@user.can_update_addresses? %>

                <td class="align-center">
                  <%=
                    radio_button_tag 'user[bill_address_id]',
                      address.user_bill.try(:id) || address.id,
                      address.user_bill.present?,
                      disabled: disable_user
                    %>
                  <%= label_tag "user_bill_address_id_#{address.id}", '' %>
                </td>
                <td class="align-center">
                  <%=
                    radio_button_tag 'user[ship_address_id]',
                      address.user_ship.try(:id) || address.id,
                      address.user_ship.present?,
                      disabled: disable_user
                    %>
                  <%= label_tag "user_ship_address_id_#{address.id}", '' %>
                </td>
              <% end %>
              <% if @order %>
                <% disable_order = !@order.can_update_addresses? %>

                <td class="align-center">
                  <%=
                    radio_button_tag 'order[bill_address_id]',
                      address.order_bill.try(:id) || address.id,
                      address.order_bill.present?,
                      disabled: disable_order
                    %>
                  <%= label_tag "order_bill_address_id_#{address.id}", '' %>
                </td>
                <td class="align-center">
                  <%=
                    radio_button_tag 'order[ship_address_id]',
                      address.order_ship.try(:id) || address.id,
                      address.order_ship.present?,
                      disabled: disable_order
                    %>
                  <%= label_tag "order_ship_address_id_#{address.id}", '' %>
                </td>
              <% end %>
              <td class="actions">
                <% if address.primary_address.editable? %>
                  <%= link_to_edit_url edit_admin_address_url(address.primary_address, user_id: @user.try(:id), order_id: @order.try(:id)), no_text: true, id: "edit-address-#{address.id}" %>
                <% end %>
              </td>
            </tr>
          <% end %>
        </tbody>
      </table>
    <% end %>
  <% end %>
</fieldset>
{'fraction_non_alphanumeric': 0.1816047801963295, 'fraction_numerical': 0.002987622705932565, 'mean_word_length': 2.0012808197246237, 'pattern_counts': {'":': 0, '<': 204, '<?xml version=': 0, '>': 216, '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': '2971064', 'n_tokens_mistral': 3162, 'n_tokens_neox': 2872, 'n_words': 511}