<div id="c-tag-aliases">
  <div id="a-index">
    <div class="search">
      <%= form_tag(general_search_tag_aliases_path, :method => :get) do %>
        <%= text_field_tag "query", params[:query], :value => params[:search][:name_matches] %>
        <%= submit_tag "Search Aliases" %>
        <%= submit_tag "Search Implications" %>
      <% end %>
    </div>

    <table width="100%" class="striped">
      <thead>
        <tr>
          <th width="30%">From</th>
          <th width="30%">To</th>
          <th width="10%">Reference</th>
          <th width="10%">Status</th>
          <th width="20%"></th>
        </tr>
      </thead>
      <tbody>
        <% @tag_aliases.each do |tag_alias| %>
          <tr id="tag-alias-<%= tag_alias.id %>">
            <td class="category-<%= tag_alias.antecedent_tag.category %>"><%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> <span class="count"><%= tag_alias.antecedent_tag.post_count rescue 0 %></span></td>
            <td class="category-<%= tag_alias.consequent_tag.try(:category) %>"><%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> <span class="count"><%= tag_alias.consequent_tag.post_count rescue 0 %></span></td>
            <td>
              <% if tag_alias.forum_topic_id %>
                <%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %>
              <% end %>
            </td>
            <td id="tag-alias-status-for-<%= tag_alias.id %>">
              <%= tag_alias.status %>
            </td>
            <td>
              <% if CurrentUser.is_admin? %>
                <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this alias?" %>

                <% if tag_alias.is_pending? %>
                  | <%= link_to "Approve", approve_tag_alias_path(tag_alias), :remote => true, :method => :post %>
                <% end %>

                <% if CurrentUser.is_moderator? %>
                  | <%= link_to "Fix", tag_alias_correction_path(:tag_alias_id => tag_alias.id) %>
                <% end %>
              <% end %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>

    <%= numbered_paginator(@tag_aliases) %>
  </div>
</div>

<%= render "secondary_links" %>

<% content_for(:page_title) do %>
  Tag Aliases - <%= Danbooru.config.app_name %>
<% end %>

