<section class="viewblock">
  <header class="viewblock-header">
    <div class="viewblock-header_right">
      <div class="button-padding">
        <% if can? :create, FieldConfig %>
          <form action="<%= new_screen_field_field_config_path %>" method="GET">
            <% keys = get_available_keys(@screen, @field) %>
            <% if !keys.empty? %>
              <%= select_tag "key", options_for_select(keys), include_blank: true %>
            <% end %>
            <%= submit_tag t(:new_model, model: FieldConfig.model_name.human), class: "btn", name:nil %>
          </form>
        <% end %>
      </div>
    </div>
    <h1 class="default-padding">
      <%= link_to t(:all_model, model: Screen.model_name.human(count: 42)), screens_path %> &gt;
      <%= link_to @screen.name, @screen %> &gt;
      <%= t('.manage_model_for_field', { model: FieldConfig.model_name.human(count: 42), name: @field.name }) %>
    </h1>
  </header>
  <div class="viewblock-cont">
    <table>
      <thead>
        <tr>
          <th><%= FieldConfig.human_attribute_name(:key) %></th>
          <th><%= FieldConfig.human_attribute_name(:value) %></th>
          <th><%= FieldConfig.human_attribute_name(:actions) %></th>
        </tr>
      </thead>

      <tbody>
      <% @field_configs.each do |field_config| %>
        <tr>
          <td><%= field_config.key %></td>
          <td><%= field_config.value %></td>
          <td>
            <% if can? :edit, @field_config %>
              <%= link_to t(:edit, model: FieldConfig.model_name.human), edit_screen_field_field_config_path(@screen, @field, field_config), class: "btn" %>
            <% end %>
            <% if can? :delete, @field_config %>
              <%= link_to t(:destroy, model: FieldConfig.model_name.human), [@screen, @field, field_config], method: :delete, data: { confirm: t(:are_you_sure_delete_model_key, model: FieldConfig.model_name.human, key: field_config.key) }, class: "btn" %>
            <% end %>
          </td>
        </tr>
      <% end %>
      </tbody>
    </table>
  </div>
</section>
