<div class="project_r_h">
  <h2 class="project_h2"><%= l(:label_title_code_review)%></h2>
</div>
<%
# Code Review plugin for Redmine
# Copyright (C) 2009-2012  Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-%>

<script>
function change_option(flag) {
 // var url = "<%= raw url_for(:controller => 'code_review', :action=>'index', :id => @project) %>";
 // $('#content').load(url, {'show_closed': flag});
}
</script>
<div id="code_review_list">

  <% if @all_review_count > 0 %>
    <p>
      <%= form_tag({:controller => 'code_review', :action=>'index', :id => @project}, :id => 'optionform') do %>
        <%= check_box_tag 'show_closed', 'true', @show_closed, :onchange => "change_option($('#show_closed').is(':checked'));"%> <%=h l(:label_show_closed_reviews) %>
      <script type="text/javascript">
           $(document).ready(function (){

               $("#optionform").change(function(){
                   $("#optionform").submit();
               });
           });

      </script>
      <% end %>
      <%# observe_field 'show_closed', :with => 'show_closed', :update => 'content' %>
    </p>
  <% end %>

  <% if @reviews == nil or @reviews.length == 0 %>
    <p class="nodata"><%= l(:label_no_data) %></p>
  <% else %>


    <table class="list" style="width:100%;table-layout: fixed;">
      <thead>
        <tr>
          <%= sort_header_tag "#{Issue.table_name}.id", :caption => '#'  %>
          <%= sort_header_tag "#{Issue.table_name}.status_id", :caption => l(:field_status)%>
          <%= sort_header_tag "#{Issue.table_name}.subject", :caption => l(:field_subject)%>
          <%= sort_header_tag 'path', :caption => l(:label_code_path)%>
          <th>
            <%=h l(:label_code_line)%>
          </th>
          <%= sort_header_tag "#{Changeset.table_name}.revision", :caption => l(:label_revision)%>
          <%= sort_header_tag "#{Changeset.table_name}.committer", :caption => l(:label_code_author)%>
          <%= sort_header_tag 'user_id', :caption => l(:label_code_reviewer)%>
          <%= sort_header_tag 'updated_at', :caption => l(:label_date) %>
        </tr>
      </thead>
      <tbody>
        <% for review in @reviews %>
          <tr class="<%= cycle 'odd', 'even' %>">
            <td style="text-overflow:ellipsis;white-space:nowrap;overflow:hidden;">
              <%= link_to review.issue.id.to_s, {:controller => 'issues', :action => 'show',
                :id => review.issue.id}, :title => review.issue.subject %>
            </td>

            <td class="status" style="text-overflow:ellipsis;white-space:nowrap;overflow:hidden;" title="<%=h  review.issue.status %>">
              <%=h  review.issue.status %>
            </td>
            <td class="subject" style="text-overflow:ellipsis;white-space:nowrap;overflow:hidden;" title="<%=h  review.issue.subject %>">
              <%=h  review.issue.subject %>
            </td>
            <td class="path" style="text-overflow:ellipsis;white-space:nowrap;overflow:hidden;">
              <%
              review_path = URI.decode(review.path)
              codepath = review_path
              if (review_path.length > 55)
                codepath = review_path[0, 15] + '...' + review_path[review_path.length - 35, 35]
              end
              -%>
              <%= link_to(raw(codepath), {:controller => 'code_review', :action => 'show', :id => @project, :review_id => review.id}, :title => review_path) -%>
           </td>
            <td style="text-overflow:ellipsis;white-space:nowrap;overflow:hidden;" title="<%=h review.line %>"><%=h review.line %></td>
            <td style="text-overflow:ellipsis;white-space:nowrap;overflow:hidden;" title="<%=h review.revision %>"><%=h review.revision %></td>
            <td style="text-overflow:ellipsis;white-space:nowrap;overflow:hidden;" title="<%=h review.committer %>"><%=h review.committer %></td>
            <td style="text-overflow:ellipsis;white-space:nowrap;overflow:hidden;" title="<%=h review.user.name %>"><%=h review.user.name %></td>
            <td style="text-overflow:ellipsis;white-space:nowrap;overflow:hidden;" title="<%=h format_time(review.created_at) %>"><%=h format_time(review.created_at) %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
    <p class="pagination"><%= pagination_links_full @review_pages, @review_count %></p>

  <% end %>

  <% content_for :header_tags do %>
    <%= stylesheet_link_tag "code_review.css", :plugin => "redmine_code_review", :media => "screen" %>
  <% end %>
</div>
<% html_title(l(:code_reviews)) -%>