<% title "#{@audit.action.camelize} #{audited_type @audit}: #{audit_title @audit}" %>

<%= title_actions link_to_if_authorized(_("Host details"),
                                        hash_for_host_path(:id => @audit.auditable.to_param),
                                        :title => _("Host details"),
                                        :class => 'btn btn-info') if @audit.auditable_type == 'Host' && @audit.auditable %>
<%= title_actions link_to 'Back', :back, :class=>'btn btn-default' %>
<% tmplt =  audit_template?(@audit) %>

<div class="tabbable">
  <ul class="nav nav-tabs">
    <% if tmplt %>
      <li class="active"><a href="#tab0" data-toggle="tab"><%= _('Template Diff') %></a></li>
    <% end %>
    <li class='<%= "active" unless tmplt %>' ><a href="#tab1" data-toggle="tab"><%= _('Details') %></a></li>
    <li><a href="#tab2" data-toggle="tab"><%= _('History') %></a></li>
  </ul>
  <div class="tab-content">
    <% if tmplt %>
    <div class="tab-pane active" id="tab0">
       <%= render 'config_templates/diff', :templates => @audit.audited_changes["template"], :file_name => audit_title(@audit) %>
    </div>
    <% end %>
    <div class='tab-pane <%= "active" unless tmplt%>' id="tab1">
      <table class="table table-bordered table-striped">
        <tr>
          <th><%= _('Item') %></th>
          <% if @audit.action == 'update' %>
            <th><%= _('Old') %></th>
            <th><%= _('New') %></th>
          <% else %>
            <th><%= _('Value') %></th>
          <% end  %>
        </tr>
        <% @audit.audited_changes.each do |name,change| %>
            <% next if change.nil? or change.to_s.empty? %>
            <% next if name == "template" %>
            <tr>
              <td><%= name.humanize %></td>
              <% if change.is_a?(Array) %>
                  <% change.each do |v| %>
                      <td><%= id_to_label(name,v) %></td>
                  <% end %>
              <% else %>
                  <td><%= id_to_label(name,change) %></td>
              <% end %>
            </tr>
        <% end %>
      </table>
    </div>
    <div class="tab-pane" id="tab2">
      <%= render :partial => 'list', :locals =>{:audits => @history} %>
    </div>
  </div>
</div>

