#1137修复项目文档排序时hash中若有空key排序报错的BUG

This commit is contained in:
sw 2014-10-27 16:26:31 +08:00
parent cf9f33fce7
commit da11b88a9b
3 changed files with 42 additions and 24 deletions

View File

@ -44,7 +44,7 @@ class DocumentsController < ApplicationController
@grouped = documents.group_by {|d| d.title.first.upcase}
when 'author'
# @grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
@grouped = documents.group_by {|d| d.user.name }
@grouped = documents.group_by(&:user)
else
@grouped = documents.group_by(&:category)
end

View File

@ -1,18 +1,25 @@
<!-- <h4><%= link_to h(document.title), document_path(document) %></h4>
<p><em><%= format_time(document.updated_on) %></em></p>
<div class="wiki">
<%= textilizable(truncate_lines(document.description), :object => document) %>
</div> -->
<!--add by huang-->
<table width="660px" align="center">
<tr><td class="font_title_document"><%= link_to h(document.title), document_path(document) %></td></tr>
<tr><td colspan="2">
<tr>
<td class="font_title_document">
<%= link_to h(document.title), document_path(document) %>
</td>
</tr>
<tr>
<td colspan="2">
<div class="font_description">
<%= textilizable(truncate_lines(document.description), :object => document) %>
</div>
</td></tr>
<tr><td align="right"><p class="font_lighter"><%= format_time(document.updated_on) %></p></td></tr>
<tr><td class="line_under"></td></tr>
</td>
</tr>
<tr>
<td align="right">
<p class="font_lighter">
<%= format_time(document.updated_on) %>
</p>
</td>
</tr>
<tr>
<td class="line_under"></td>
</tr>
</table>

View File

@ -12,23 +12,34 @@
</div>
<div id="add-document" style="display:none;">
<h3><%=l(:label_document_new)%></h3>
<%= labelled_form_for @document, :url => project_documents_path(@project), :html => {:multipart => true} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<p>
<%= submit_tag l(:button_create) %>
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-document").hide(); return false;' %>
</p>
<% end %>
<h3>
<%=l(:label_document_new)%>
</h3>
<%= labelled_form_for @document, :url => project_documents_path(@project), :html => {:multipart => true} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<p>
<%= submit_tag l(:button_create) %>
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-document").hide(); return false;' %>
</p>
<% end %>
</div>
<h3><%=l(:label_document_plural)%></h3>
<% if @grouped.empty? %><p class="nodata"><%= l(:label_no_data) %></p><% end %>
<% if @grouped.empty? %>
<p class="nodata">
<%= l(:label_no_data) %>
</p>
<% end %>
<% @grouped.keys.sort.each do |group| %>
<!-- <h3><%= group %></h3> -->
<% if @grouped.has_key? nil %>
<% @grouped.keys.each do |group| %>
<%= render :partial => 'documents/document', :collection => @grouped[group] %>
<% end %>
<% else %>
<% @grouped.keys.sort.each do |group| %>
<%= render :partial => 'documents/document', :collection => @grouped[group] %>
<% end %>
<% end %>
<% html_title(l(:label_document_plural)) -%>