<% html_title l(:label_ux_toolkit_ticket_templates) %>

<div class="contextual">
  <%= link_to l(:label_ux_toolkit_new_ticket_template),
              new_ux_toolkit_ticket_template_path,
              class: 'icon icon-add' %>
</div>

<h2><%= l(:label_ux_toolkit_ticket_templates) %></h2>

<p class="info"><%= l(:text_ux_toolkit_ticket_templates_help) %></p>

<% if @templates.any? %>
  <table class="list ux-toolkit-template-list">
    <thead>
      <tr>
        <%= sort_header_tag('name', caption: l(:label_ux_toolkit_template_name)) %>
        <%= sort_header_tag('enabled',
                            caption: l(:label_ux_toolkit_template_enabled),
                            default_order: 'desc') %>
        <%= sort_header_tag('subject_template',
                            caption: l(:label_ux_toolkit_ticket_template_subject_template)) %>
        <%= sort_header_tag('updated_at',
                            caption: l(:field_updated_on),
                            default_order: 'desc') %>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <% @templates.each do |template| %>
        <tr class="<%= cycle('odd', 'even') %>">
          <td class="name"><%= link_to h(template.name), edit_ux_toolkit_ticket_template_path(template) %></td>
          <td><%= checked_image template.enabled? %></td>
          <td><%= h(template.subject_template.presence || '-') %></td>
          <td><%= format_time(template.updated_at) %></td>
          <td class="buttons">
            <%= link_to l(:button_edit),
                        edit_ux_toolkit_ticket_template_path(template),
                        class: 'icon icon-edit' %>
            <% if template.enabled? %>
              <%= link_to l(:button_ux_toolkit_disable),
                          disable_ux_toolkit_ticket_template_path(template),
                          method: :post,
                          class: 'icon icon-lock' %>
            <% else %>
              <%= link_to l(:button_ux_toolkit_enable),
                          enable_ux_toolkit_ticket_template_path(template),
                          method: :post,
                          class: 'icon icon-unlock' %>
            <% end %>
            <%= link_to l(:button_delete),
                        ux_toolkit_ticket_template_path(template),
                        method: :delete,
                        data: {confirm: l(:text_ux_toolkit_confirm_delete_ticket_template)},
                        class: 'icon icon-del' %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <p class="nodata"><%= l(:text_ux_toolkit_no_ticket_templates) %></p>
<% end %>
