Revision 784
Added by Jean-Philippe Lang over 17 years ago
trunk/app/controllers/issues_controller.rb | ||
---|---|---|
46 | 46 |
@issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) |
47 | 47 |
@issue_pages = Paginator.new self, @issue_count, 25, params['page'] |
48 | 48 |
@issues = Issue.find :all, :order => sort_clause, |
49 |
:include => [ :assigned_to, :status, :tracker, :project, :priority ], |
|
49 |
:include => [ :assigned_to, :status, :tracker, :project, :priority, :category ],
|
|
50 | 50 |
:conditions => @query.statement, |
51 | 51 |
:limit => @issue_pages.items_per_page, |
52 | 52 |
:offset => @issue_pages.current.offset |
trunk/app/controllers/projects_controller.rb | ||
---|---|---|
250 | 250 |
@issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) |
251 | 251 |
@issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page'] |
252 | 252 |
@issues = Issue.find :all, :order => sort_clause, |
253 |
:include => [ :assigned_to, :status, :tracker, :project, :priority ], |
|
253 |
:include => [ :assigned_to, :status, :tracker, :project, :priority, :category ],
|
|
254 | 254 |
:conditions => @query.statement, |
255 | 255 |
:limit => @issue_pages.items_per_page, |
256 | 256 |
:offset => @issue_pages.current.offset |
trunk/app/models/query.rb | ||
---|---|---|
211 | 211 |
if has_default_columns? |
212 | 212 |
available_columns.select {|c| c.default? } |
213 | 213 |
else |
214 |
available_columns.select {|c| column_names.include?(c.name) } |
|
214 |
# preserve the column_names order |
|
215 |
column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact |
|
215 | 216 |
end |
216 | 217 |
end |
217 | 218 |
|
trunk/app/views/queries/_columns.rhtml | ||
---|---|---|
1 | 1 |
<% content_tag 'fieldset', :id => 'columns', :style => (query.has_default_columns? ? 'display:none;' : nil) do %> |
2 | 2 |
<legend><%= l(:field_column_names) %></legend> |
3 |
<% query.available_columns.each do |column| %> |
|
4 |
<label><%= check_box_tag 'query[column_names][]', column.name, query.has_column?(column) %> <%= l("field_#{column.name}") %></label><br /> |
|
5 |
<% end %> |
|
3 |
|
|
6 | 4 |
<%= hidden_field_tag 'query[column_names][]', '' %> |
5 |
<table margin=0> |
|
6 |
<tr> |
|
7 |
<td><%= select_tag 'available_columns', |
|
8 |
options_for_select((query.available_columns - query.columns).collect {|column| [l("field_#{column.name}"), column.name]}), |
|
9 |
:multiple => true, :size => 10, :style => "width:150px" %> |
|
10 |
</td> |
|
11 |
<td align="center" valign="middle"> |
|
12 |
<input type="button" value="-->" |
|
13 |
onclick="moveOptions(this.form.available_columns, this.form.selected_columns);" /><br /> |
|
14 |
<input type="button" value="<--" |
|
15 |
onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" /> |
|
16 |
</td> |
|
17 |
<td><%= select_tag 'query[column_names][]', |
|
18 |
options_for_select(@query.columns.collect {|column| [l("field_#{column.name}"), column.name]}), |
|
19 |
:id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %> |
|
20 |
</td> |
|
21 |
</tr> |
|
22 |
</table> |
|
7 | 23 |
<% end %> |
24 |
|
|
25 |
<% content_for :header_tags do %> |
|
26 |
<%= javascript_include_tag 'select_list_move' %> |
|
27 |
<% end %> |
trunk/app/views/queries/_form.rhtml | ||
---|---|---|
12 | 12 |
|
13 | 13 |
<p><label for="query_default_columns"><%=l(:label_default_columns)%></label> |
14 | 14 |
<%= check_box_tag 'default_columns', 1, @query.has_default_columns?, :id => 'query_default_columns', |
15 |
:onchange => 'if (this.checked) {Element.hide("columns")} else {Element.show("columns")}' %></p>
|
|
15 |
:onclick => 'if (this.checked) {Element.hide("columns")} else {Element.show("columns")}' %></p>
|
|
16 | 16 |
</div> |
17 | 17 |
|
18 |
<%= render :partial => 'queries/filters', :locals => {:query => query}%> |
|
18 | 19 |
<%= render :partial => 'queries/columns', :locals => {:query => query}%> |
19 |
<%= render :partial => 'queries/filters', :locals => {:query => query}%> |
|
20 | 20 |
</div> |
trunk/app/views/queries/edit.rhtml | ||
---|---|---|
1 | 1 |
<h2><%= l(:label_query) %></h2> |
2 | 2 |
|
3 |
<% form_tag({:action => 'edit', :id => @query}) do %> |
|
3 |
<% form_tag({:action => 'edit', :id => @query}, :onsubmit => 'selectAllOptions("selected_columns");') do %>
|
|
4 | 4 |
<%= render :partial => 'form', :locals => {:query => @query} %> |
5 | 5 |
<%= submit_tag l(:button_save) %> |
6 | 6 |
<% end %> |
trunk/app/views/queries/new.rhtml | ||
---|---|---|
1 | 1 |
<h2><%= l(:label_query_new) %></h2> |
2 | 2 |
|
3 |
<% form_tag({:action => 'new', :project_id => @query.project}) do %> |
|
3 |
<% form_tag({:action => 'new', :project_id => @query.project}, :onsubmit => 'selectAllOptions("selected_columns");') do %>
|
|
4 | 4 |
<%= render :partial => 'form', :locals => {:query => @query} %> |
5 | 5 |
<%= submit_tag l(:button_save) %> |
6 | 6 |
<% end %> |
trunk/public/javascripts/select_list_move.js | ||
---|---|---|
1 |
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5); |
|
2 |
|
|
3 |
function addOption(theSel, theText, theValue) |
|
4 |
{ |
|
5 |
var newOpt = new Option(theText, theValue); |
|
6 |
var selLength = theSel.length; |
|
7 |
theSel.options[selLength] = newOpt; |
|
8 |
} |
|
9 |
|
|
10 |
function deleteOption(theSel, theIndex) |
|
11 |
{ |
|
12 |
var selLength = theSel.length; |
|
13 |
if(selLength>0) |
|
14 |
{ |
|
15 |
theSel.options[theIndex] = null; |
|
16 |
} |
|
17 |
} |
|
18 |
|
|
19 |
function moveOptions(theSelFrom, theSelTo) |
|
20 |
{ |
|
21 |
|
|
22 |
var selLength = theSelFrom.length; |
|
23 |
var selectedText = new Array(); |
|
24 |
var selectedValues = new Array(); |
|
25 |
var selectedCount = 0; |
|
26 |
|
|
27 |
var i; |
|
28 |
|
|
29 |
for(i=selLength-1; i>=0; i--) |
|
30 |
{ |
|
31 |
if(theSelFrom.options[i].selected) |
|
32 |
{ |
|
33 |
selectedText[selectedCount] = theSelFrom.options[i].text; |
|
34 |
selectedValues[selectedCount] = theSelFrom.options[i].value; |
|
35 |
deleteOption(theSelFrom, i); |
|
36 |
selectedCount++; |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
for(i=selectedCount-1; i>=0; i--) |
|
41 |
{ |
|
42 |
addOption(theSelTo, selectedText[i], selectedValues[i]); |
|
43 |
} |
|
44 |
|
|
45 |
if(NS4) history.go(0); |
|
46 |
} |
|
47 |
|
|
48 |
function selectAllOptions(id) |
|
49 |
{ |
|
50 |
var select = $(id); |
|
51 |
for (var i=0; i<select.options.length; i++) { |
|
52 |
select.options[i].selected = true; |
|
53 |
} |
|
54 |
} |
|
55 |
|
Also available in: Unified diff
Custom query columns: checkboxes replaced by two selects that let the user specify columns order.