<table width="100%" class="striped">
  <thead>
    <tr>
      <th width="25%">From</th>
      <th width="25%">To</th>
      <th width="10%">Reference</th>
      <th width="15%">Approver</th>
      <th width="5%">Status</th>
      <th width="15%"></th>
    </tr>
  </thead>
  <tbody>
    <% tag_aliases.each do |tag_alias| %>
      <tr id="tag-alias-<%= tag_alias.id %>">
        <td class="category-<%= tag_alias.antecedent_tag.try(: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><%= link_to_user(tag_alias.approver) if tag_alias.approver %></td>
        <td id="tag-alias-status-for-<%= tag_alias.id %>">
          <%= tag_alias.status %>
        </td>
        <td>
          <%= link_to "Show", tag_alias_path(tag_alias) %>

          <% if tag_alias.editable_by?(CurrentUser.user) %>
            | <%= link_to "Edit", edit_tag_alias_path(tag_alias) %>
          <% end %>

          <% if tag_alias.deletable_by?(CurrentUser.user) %>
            | <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this alias?"} %>
          <% end %>

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

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