haru/redmine_code_review

View on GitHub
app/views/code_review/index.html.erb

Summary

Maintainability
Test Coverage
<%
# 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">
  <h2>
    <%=h l(:code_reviews) %>
  </h2>

  <% 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) %>
      <% 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">
      <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>
              <%= link_to review.issue.id.to_s, {:controller => 'issues', :action => 'show',
                :id => review.issue.id}, :title => review.issue.subject %>
            </td>

            <td class="status">
              <%=h  review.issue.status %>
            </td>
            <td class="subject">
              <%=h  review.issue.subject %>
            </td>
            <td class="path">
              <%
              review_path = URI.decode_www_form_component(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><%=h review.line %></td>
            <td><%=h review.revision %></td>
            <td><%=h review.committer %></td>
            <td><%=h review.user.name %></td>
            <td><%=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>