end
end
- Review.find(:all, :include => [ 'review_comments', 'project', 'user', 'assignee', 'resource' ], :order => 'created_at DESC', :conditions => [conditions.join(' AND '), values], :limit => 200)
+ sort=options['sort']
+ asc=options['asc']
+ if sort
+ if asc
+ sort += ' ASC, reviews.updated_at DESC'
+ else
+ sort += ' DESC, reviews.updated_at DESC'
+ end
+ else
+ sort = 'reviews.updated_at DESC'
+ end
+
+ # We define 'assignee' before 'user' in the ':include' so that it is possible to sort on the assignee.name
+ Review.find(:all, :include => [ 'review_comments', 'project', 'assignee', 'resource', 'user' ], :conditions => [conditions.join(' AND '), values], :order => sort, :limit => 200)
end
def self.reviews_to_xml(reviews, convert_markdown=false)
$('assignees').value = ''
}
}
+function launchSearch(columnName, link) {
+ $('sort').value = columnName
+ if ($('asc').value == "true") {
+ $('asc').value = "false";
+ } else {
+ $('asc').value = "true";
+ }
+ document.forms[0].submit()
+}
</script>
<div id="reviews-search">
<h1>Reviews</h1>
<br/>
<br/>
<div style="width:100%; text-align: right">
+ <input type="hidden" name="sort" id="sort" value="<%= @sort -%>"/>
+ <input type="hidden" name="asc" id="asc" value="<%= @asc -%>"/>
<%= submit_tag "Search", :id => 'submit_search' %>
</div>
</td>
<table id="reviews-list" class="data width100">
<thead>
<tr>
- <th width="1%" nowrap></th>
- <th width="1%" nowrap>Id</th>
- <th width="1%" nowrap></th>
- <th>Title</th>
- <th width="1%">Project</th>
- <th>Assignee</th>
- <th>Age</th>
+ <th width="1%" nowrap>
+ <a href="#" onClick="launchSearch('status', this)">St.</a>
+ <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'status' -%>
+ </th>
+ <th width="1%" nowrap>
+ <a href="#" onClick="launchSearch('id', this)">Id</a>
+ <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'id' -%>
+ </th>
+ <th width="1%" nowrap>
+ <a href="#" onClick="launchSearch('severity', this)">Se.</a>
+ <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'severity' -%>
+ </th>
+ <th>
+ <a href="#" onClick="launchSearch('title', this)">Title</a>
+ <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'title' -%>
+ </th>
+ <th width="1%">
+ <a href="#" onClick="launchSearch('projects.name', this)">Project</a>
+ <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'projects.name' -%>
+ </th>
+ <th>
+ <a href="#" onClick="launchSearch('users.name', this)">Assignee</a>
+ <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'users.name' -%>
+ </th>
+ <th>
+ <a href="#" onClick="launchSearch('updated_at', this)">Age</a>
+ <%= image_tag(@asc ? "asc12.png" : "desc12.png") if @sort == 'updated_at' -%>
+ </th>
</tr>
</thead>
<tbody>
<%
@reviews.each do |review|
- comment = review.comments.first
+ comment = review.comments.last
%>
<tr class="<%= cycle('even', 'odd') -%>">
<td><img src="<%= ApplicationController.root_context -%>/images/status/<%= review.status -%>.png" title="<%= review.status.capitalize -%>"/></td>
<td><%= review.project.name -%>
<br/><span class="note"><%= review.resource.long_name -%></span></td>
<td><%= review.assignee ? h(review.assignee.name) : '-' -%></td>
- <td><%= distance_of_time_in_words_to_now(review.created_at) -%></td>
+ <td><%= distance_of_time_in_words_to_now(review.updated_at) -%></td>
</tr>
<%
end