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