group_by_patch.patch

Andrew Chaika, 2009-03-02 21:22

Download (5.93 KB)

View differences:

app/controllers/issues_controller.rb (revision 2)
64 64
                           :conditions => @query.statement,
65 65
                           :limit  =>  limit,
66 66
                           :offset =>  @issue_pages.current.offset
67
      if !params[:group_by].nil? 
68
        @query.group_by = params[:group_by].to_s
69
      end
67 70
      respond_to do |format|
68 71
        format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
69 72
        format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
app/controllers/queries_controller.rb (revision 2)
26 26
    @query.user = User.current
27 27
    @query.is_public = false unless (@query.project && current_role.allowed_to?(:manage_public_queries)) || User.current.admin?
28 28
    @query.column_names = nil if params[:default_columns]
29
    @query.group_by = params[:group_by]
29 30
    
30 31
    params[:fields].each do |field|
31 32
      @query.add_filter(field, params[:operators][field], params[:values][field])
......
49 50
      @query.project = nil if params[:query_is_for_all]
50 51
      @query.is_public = false unless (@query.project && current_role.allowed_to?(:manage_public_queries)) || User.current.admin?
51 52
      @query.column_names = nil if params[:default_columns]
53
      @query.group_by = params[:group_by].to_s
52 54
      
53 55
      if @query.save
54 56
        flash[:notice] = l(:notice_successful_update)
app/views/issues/_list.rhtml (revision 2)
1
<script type="text/javascript">
2
//<![CDATA[
3
function toggle_group(group_id) {
4
  $$('tr.group-' + group_id).invoke('toggle');//.hide();
5
  el = $('gh-' + group_id); 
6
  el.className = (el.className == "entry")?'entry   open':'entry';
7
}
8
//]]>
9
</script>
1 10
<% form_tag({}) do -%>	
2 11
<table class="list issues">
3 12
    <thead><tr>
......
10 19
        <% end %>
11 20
	</tr></thead>
12 21
	<tbody>
13
	<% issues.each do |issue| -%>
14
	<tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= css_issue_classes(issue) %>">
22

  
23
  <% is_group_defined = query.group_by.nil? %>
24
  <% if !is_group_defined %>
25
  <% is_group_defined = query.group_by.empty? %>
26
  <% end %>
27
  <% if is_group_defined %> 
28
  <% @issues_by_group = { "" => @issues } %>
29
  <% else %>
30
  <% column = query.columns.find{|c| c.name.to_s == query.group_by} %>
31
  <% @issues_by_group = @issues.group_by {|i| column_content(column, i) } %>
32
  <% end %>
33

  
34
  <% col_nums = query.columns.size %>
35
  <% group_num = 0 %>
36
  <% @issues_by_group.each do |key, issue_list| -%>
37
  <% group_num = group_num+1 %>
38
  
39
  <% if !is_group_defined %> 
40
  <tr class="entry open" id="gh-<%= group_num.to_s %>">
41
    <td colspan="<%= col_nums+2 %>" class="header" style="padding-top: 10px; padding-bottom: 10px; font-weight: bold;">
42
    <span class="expander" onclick='toggle_group(<%= group_num.to_s %>);'>&nbsp</span></a> [<%= key %>] (<%= issue_list.size %>)</td>
43
  </tr>
44
  <% end %>
45

  
46
	<% issue_list.each do |issue| -%>
47
	<tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= css_issue_classes(issue) %> group-<%= group_num %>">
15 48
	    <td class="checkbox"><%= check_box_tag("ids[]", issue.id, false, :id => nil) %></td>
16 49
		<td><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %></td>
17 50
        <% query.columns.each do |column| %><%= content_tag 'td', column_content(column, issue), :class => column.name %><% end %>
18 51
	</tr>
52

  
19 53
	<% end -%>
54

  
55
  <% end -%>  
56
 
20 57
	</tbody>
21 58
</table>
22 59
<% end -%>
app/views/queries/_filters.rhtml (revision 2)
58 58

  
59 59
<table width="100%">
60 60
<tr>
61
<td>
61
<td rowspan="2">
62 62
<table>
63 63
<% query.available_filters.sort{|a,b| a[1][:order]<=>b[1][:order]}.each do |filter| %>
64 64
    <% field = filter[0]
......
95 95
</td>
96 96
<td class="add-filter">
97 97
<%= l(:label_filter_add) %>:
98
<%= select_tag 'add_filter_select', options_for_select([["",""]] + query.available_filters.sort{|a,b| a[1][:order]<=>b[1][:order]}.collect{|field| [ field[1][:name] || l(("field_"+field[0].to_s.gsub(/\_id$/, "")).to_sym), field[0]] unless query.has_filter?(field[0])}.compact), :onchange => "add_filter();", :class => "select-small" %>
98
<%= select_tag 'add_filter_select', options_for_select([["",""]] + query.available_filters.sort{|a,b| a[1][:order]<=>b[1][:order]}.collect{|field| [ field[1][:name] || l(("field_"+field[0].to_s.gsub(/\_id$/, "")).to_sym), field[0]] unless query.has_filter?(field[0])}.compact), :onchange => "add_filter();", :class => "select-small", :style => "width: 150px" %>
99 99
</td>
100 100
</tr>
101
<tr>
102
<td class="add-filter">
103
<%= l(:label_group_by) %>:
104
<%= select_tag 'group_by', options_for_select([["",""]] + query.columns.collect {|column| [column.caption, column.name.to_s]}, query.group_by), :class => "select-small", :style => "width: 150px" %>
105
</td>
106
</tr>
101 107
</table>
lang/ru.yml (revision 2)
730 730
text_wiki_destroy_confirmation: Вы уверены, что хотите удалить данную Wiki и все ее содержимое?
731 731
text_workflow_edit: Выберите роль и трекер для редактирования последовательности состояний
732 732

  
733
label_group_by: Группировать по