##// END OF EJS Templates
Fixed: can't select columns when creating a new query....
Jean-Philippe Lang -
r784:cb8bee3a4e5a
parent child
Show More
@@ -1,83 +1,83
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class QueriesController < ApplicationController
19 19 layout 'base'
20 20 before_filter :find_project, :authorize
21 21
22 22 def index
23 23 @queries = @project.queries.find(:all,
24 24 :order => "name ASC",
25 25 :conditions => ["is_public = ? or user_id = ?", true, (logged_in_user ? logged_in_user.id : 0)])
26 26 end
27 27
28 28 def new
29 29 @query = Query.new(params[:query])
30 30 @query.project = @project
31 31 @query.user = logged_in_user
32 32 @query.executed_by = logged_in_user
33 33 @query.is_public = false unless current_role.allowed_to?(:manage_public_queries)
34 34 @query.column_names = nil if params[:default_columns]
35 35
36 36 params[:fields].each do |field|
37 37 @query.add_filter(field, params[:operators][field], params[:values][field])
38 38 end if params[:fields]
39 39
40 if request.post? and @query.save
40 if request.post? && params[:confirm] && @query.save
41 41 flash[:notice] = l(:notice_successful_create)
42 42 redirect_to :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => @query
43 43 return
44 44 end
45 45 render :layout => false if request.xhr?
46 46 end
47 47
48 48 def edit
49 49 if request.post?
50 50 @query.filters = {}
51 51 params[:fields].each do |field|
52 52 @query.add_filter(field, params[:operators][field], params[:values][field])
53 53 end if params[:fields]
54 54 @query.attributes = params[:query]
55 55 @query.is_public = false unless current_role.allowed_to?(:manage_public_queries)
56 56 @query.column_names = nil if params[:default_columns]
57 57
58 58 if @query.save
59 59 flash[:notice] = l(:notice_successful_update)
60 60 redirect_to :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => @query
61 61 end
62 62 end
63 63 end
64 64
65 65 def destroy
66 66 @query.destroy if request.post?
67 67 redirect_to :controller => 'queries', :project_id => @project
68 68 end
69 69
70 70 private
71 71 def find_project
72 72 if params[:id]
73 73 @query = Query.find(params[:id])
74 74 @query.executed_by = logged_in_user
75 75 @project = @query.project
76 76 render_403 unless @query.editable_by?(logged_in_user)
77 77 else
78 78 @project = Project.find(params[:project_id])
79 79 end
80 80 rescue ActiveRecord::RecordNotFound
81 81 render_404
82 82 end
83 83 end
@@ -1,64 +1,59
1 1 <% if @query.new_record? %>
2 2 <h2><%=l(:label_issue_plural)%></h2>
3 3 <% set_html_title l(:label_issue_plural) %>
4 4
5 <% form_tag({:action => 'list_issues'}, :id => 'query_form') do %>
5 <% form_tag({ :controller => 'queries', :action => 'new', :project_id => @project }, :id => 'query_form') do %>
6 6 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
7 7 <% end %>
8 8 <div class="contextual">
9 9 <%= link_to_remote l(:button_apply),
10 10 { :url => { :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 },
11 11 :update => "content",
12 12 :with => "Form.serialize('query_form')"
13 13 }, :class => 'icon icon-edit' %>
14 14
15 15 <%= link_to_remote l(:button_clear),
16 16 { :url => {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1},
17 17 :update => "content",
18 18 }, :class => 'icon icon-reload' %>
19 19
20 20 <% if current_role.allowed_to?(:save_queries) %>
21 <%= link_to_remote l(:button_save),
22 { :url => { :controller => 'queries', :action => 'new', :project_id => @project },
23 :method => 'get',
24 :update => "content",
25 :with => "Form.serialize('query_form')"
26 }, :class => 'icon icon-save' %>
21 <%= link_to l(:button_save), {}, :onclick => "$('query_form').submit(); return false;", :class => 'icon icon-save' %>
27 22 <% end %>
28 23 </div>
29 24 <br />
30 25 <% else %>
31 26 <div class="contextual">
32 27 <% if @query.editable_by?(User.current) %>
33 28 <%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => @query}, :class => 'icon icon-edit' %>
34 29 <%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => @query}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
35 30 <% end %>
36 31 </div>
37 32
38 33 <h2><%= @query.name %></h2>
39 34 <% set_html_title @query.name %>
40 35 <% end %>
41 36 <%= error_messages_for 'query' %>
42 37 <% if @query.valid? %>
43 38 <% if @issues.empty? %>
44 39 <p class="nodata"><%= l(:label_no_data) %></p>
45 40 <% else %>
46 41 &nbsp;
47 42 <% form_tag({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) do %>
48 43 <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query} %>
49 44 <div class="contextual">
50 45 <%= l(:label_export_to) %>
51 46 <%= link_to 'CSV', {:action => 'export_issues_csv', :id => @project}, :class => 'icon icon-csv' %>,
52 47 <%= link_to 'PDF', {:action => 'export_issues_pdf', :id => @project}, :class => 'icon icon-pdf' %>
53 48 </div>
54 49 <p><%= submit_tag(l(:button_move), :class => "button-small") if authorize_for('projects', 'move_issues') %>
55 50 <%= pagination_links_full @issue_pages %>
56 51 [ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ]
57 52 </p>
58 53 <% end %>
59 54 <% end %>
60 55 <% end %>
61 56
62 57 <% content_for :sidebar do %>
63 58 <%= render :partial => 'issues/sidebar' %>
64 59 <% end %>
@@ -1,20 +1,21
1 1 <%= error_messages_for 'query' %>
2 <%= hidden_field_tag 'confirm', 1 %>
2 3
3 4 <div class="box">
4 5 <div class="tabular">
5 6 <p><label for="query_name"><%=l(:field_name)%></label>
6 7 <%= text_field 'query', 'name', :size => 80 %></p>
7 8
8 9 <% if current_role.allowed_to?(:manage_public_queries) %>
9 10 <p><label for="query_is_public"><%=l(:field_is_public)%></label>
10 11 <%= check_box 'query', 'is_public' %></p>
11 12 <% end %>
12 13
13 14 <p><label for="query_default_columns"><%=l(:label_default_columns)%></label>
14 15 <%= check_box_tag 'default_columns', 1, @query.has_default_columns?, :id => 'query_default_columns',
15 16 :onclick => 'if (this.checked) {Element.hide("columns")} else {Element.show("columns")}' %></p>
16 17 </div>
17 18
18 19 <%= render :partial => 'queries/filters', :locals => {:query => query}%>
19 20 <%= render :partial => 'queries/columns', :locals => {:query => query}%>
20 21 </div>
General Comments 0
You need to be logged in to leave comments. Login now