@@ -1,45 +1,46 | |||||
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 | module QueriesHelper |
|
18 | module QueriesHelper | |
19 |
|
19 | |||
20 | def operators_for_select(filter_type) |
|
20 | def operators_for_select(filter_type) | |
21 | Query.operators_by_filter_type[filter_type].collect {|o| [l(Query.operators[o]), o]} |
|
21 | Query.operators_by_filter_type[filter_type].collect {|o| [l(Query.operators[o]), o]} | |
22 | end |
|
22 | end | |
23 |
|
23 | |||
24 | def column_header(column) |
|
24 | def column_header(column) | |
25 | if column.sortable |
|
25 | column.sortable ? sort_header_tag(column.sortable, :caption => column.caption) : content_tag('th', column.caption) | |
26 | sort_header_tag(column.sortable, :caption => l("field_#{column.name}")) |
|
|||
27 | else |
|
|||
28 | content_tag('th', l("field_#{column.name}")) |
|
|||
29 | end |
|
|||
30 | end |
|
26 | end | |
31 |
|
27 | |||
32 | def column_content(column, issue) |
|
28 | def column_content(column, issue) | |
33 | value = issue.send(column.name) |
|
29 | if column.is_a?(QueryCustomFieldColumn) | |
34 | if value.is_a?(Date) |
|
30 | cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id} | |
35 |
|
|
31 | show_value(cv) | |
36 | elsif value.is_a?(Time) |
|
|||
37 | format_time(value) |
|
|||
38 | elsif column.name == :subject |
|
|||
39 | ((@project.nil? || @project != issue.project) ? "#{issue.project.name} - " : '') + |
|
|||
40 | link_to(h(value), :controller => 'issues', :action => 'show', :id => issue) |
|
|||
41 | else |
|
32 | else | |
42 | h(value) |
|
33 | value = issue.send(column.name) | |
|
34 | if value.is_a?(Date) | |||
|
35 | format_date(value) | |||
|
36 | elsif value.is_a?(Time) | |||
|
37 | format_time(value) | |||
|
38 | elsif column.name == :subject | |||
|
39 | ((@project.nil? || @project != issue.project) ? "#{issue.project.name} - " : '') + | |||
|
40 | link_to(h(value), :controller => 'issues', :action => 'show', :id => issue) | |||
|
41 | else | |||
|
42 | h(value) | |||
|
43 | end | |||
43 | end |
|
44 | end | |
44 | end |
|
45 | end | |
45 | end |
|
46 | end |
@@ -1,320 +1,345 | |||||
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 QueryColumn |
|
18 | class QueryColumn | |
19 | attr_accessor :name, :sortable |
|
19 | attr_accessor :name, :sortable | |
|
20 | include GLoc | |||
20 |
|
21 | |||
21 | def initialize(name, options={}) |
|
22 | def initialize(name, options={}) | |
22 | self.name = name |
|
23 | self.name = name | |
23 | self.sortable = options[:sortable] |
|
24 | self.sortable = options[:sortable] | |
24 | end |
|
25 | end | |
25 |
|
26 | |||
26 | def default?; default end |
|
27 | def caption | |
|
28 | l("field_#{name}") | |||
|
29 | end | |||
|
30 | end | |||
|
31 | ||||
|
32 | class QueryCustomFieldColumn < QueryColumn | |||
|
33 | ||||
|
34 | def initialize(custom_field) | |||
|
35 | self.name = "cf_#{custom_field.id}".to_sym | |||
|
36 | self.sortable = false | |||
|
37 | @cf = custom_field | |||
|
38 | end | |||
|
39 | ||||
|
40 | def caption | |||
|
41 | @cf.name | |||
|
42 | end | |||
|
43 | ||||
|
44 | def custom_field | |||
|
45 | @cf | |||
|
46 | end | |||
27 | end |
|
47 | end | |
28 |
|
48 | |||
29 | class Query < ActiveRecord::Base |
|
49 | class Query < ActiveRecord::Base | |
30 | belongs_to :project |
|
50 | belongs_to :project | |
31 | belongs_to :user |
|
51 | belongs_to :user | |
32 | serialize :filters |
|
52 | serialize :filters | |
33 | serialize :column_names |
|
53 | serialize :column_names | |
34 |
|
54 | |||
35 | attr_protected :project, :user |
|
55 | attr_protected :project, :user | |
36 | attr_accessor :executed_by |
|
56 | attr_accessor :executed_by | |
37 |
|
57 | |||
38 | validates_presence_of :name, :on => :save |
|
58 | validates_presence_of :name, :on => :save | |
39 | validates_length_of :name, :maximum => 255 |
|
59 | validates_length_of :name, :maximum => 255 | |
40 |
|
60 | |||
41 | @@operators = { "=" => :label_equals, |
|
61 | @@operators = { "=" => :label_equals, | |
42 | "!" => :label_not_equals, |
|
62 | "!" => :label_not_equals, | |
43 | "o" => :label_open_issues, |
|
63 | "o" => :label_open_issues, | |
44 | "c" => :label_closed_issues, |
|
64 | "c" => :label_closed_issues, | |
45 | "!*" => :label_none, |
|
65 | "!*" => :label_none, | |
46 | "*" => :label_all, |
|
66 | "*" => :label_all, | |
47 | ">=" => '>=', |
|
67 | ">=" => '>=', | |
48 | "<=" => '<=', |
|
68 | "<=" => '<=', | |
49 | "<t+" => :label_in_less_than, |
|
69 | "<t+" => :label_in_less_than, | |
50 | ">t+" => :label_in_more_than, |
|
70 | ">t+" => :label_in_more_than, | |
51 | "t+" => :label_in, |
|
71 | "t+" => :label_in, | |
52 | "t" => :label_today, |
|
72 | "t" => :label_today, | |
53 | "w" => :label_this_week, |
|
73 | "w" => :label_this_week, | |
54 | ">t-" => :label_less_than_ago, |
|
74 | ">t-" => :label_less_than_ago, | |
55 | "<t-" => :label_more_than_ago, |
|
75 | "<t-" => :label_more_than_ago, | |
56 | "t-" => :label_ago, |
|
76 | "t-" => :label_ago, | |
57 | "~" => :label_contains, |
|
77 | "~" => :label_contains, | |
58 | "!~" => :label_not_contains } |
|
78 | "!~" => :label_not_contains } | |
59 |
|
79 | |||
60 | cattr_reader :operators |
|
80 | cattr_reader :operators | |
61 |
|
81 | |||
62 | @@operators_by_filter_type = { :list => [ "=", "!" ], |
|
82 | @@operators_by_filter_type = { :list => [ "=", "!" ], | |
63 | :list_status => [ "o", "=", "!", "c", "*" ], |
|
83 | :list_status => [ "o", "=", "!", "c", "*" ], | |
64 | :list_optional => [ "=", "!", "!*", "*" ], |
|
84 | :list_optional => [ "=", "!", "!*", "*" ], | |
65 | :list_one_or_more => [ "*", "=" ], |
|
85 | :list_one_or_more => [ "*", "=" ], | |
66 | :date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-" ], |
|
86 | :date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-" ], | |
67 | :date_past => [ ">t-", "<t-", "t-", "t", "w" ], |
|
87 | :date_past => [ ">t-", "<t-", "t-", "t", "w" ], | |
68 | :string => [ "=", "~", "!", "!~" ], |
|
88 | :string => [ "=", "~", "!", "!~" ], | |
69 | :text => [ "~", "!~" ], |
|
89 | :text => [ "~", "!~" ], | |
70 | :integer => [ "=", ">=", "<=" ] } |
|
90 | :integer => [ "=", ">=", "<=" ] } | |
71 |
|
91 | |||
72 | cattr_reader :operators_by_filter_type |
|
92 | cattr_reader :operators_by_filter_type | |
73 |
|
93 | |||
74 | @@available_columns = [ |
|
94 | @@available_columns = [ | |
75 | QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position"), |
|
95 | QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position"), | |
76 | QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position"), |
|
96 | QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position"), | |
77 | QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position"), |
|
97 | QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position"), | |
78 | QueryColumn.new(:subject), |
|
98 | QueryColumn.new(:subject), | |
79 | QueryColumn.new(:assigned_to, :sortable => "#{User.table_name}.lastname"), |
|
99 | QueryColumn.new(:assigned_to, :sortable => "#{User.table_name}.lastname"), | |
80 | QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on"), |
|
100 | QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on"), | |
81 | QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name"), |
|
101 | QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name"), | |
82 | QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"), |
|
102 | QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"), | |
83 | QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"), |
|
103 | QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"), | |
84 | QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"), |
|
104 | QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"), | |
85 | QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio"), |
|
105 | QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio"), | |
86 | QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on"), |
|
106 | QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on"), | |
87 | ] |
|
107 | ] | |
88 | cattr_reader :available_columns |
|
108 | cattr_reader :available_columns | |
89 |
|
109 | |||
90 | def initialize(attributes = nil) |
|
110 | def initialize(attributes = nil) | |
91 | super attributes |
|
111 | super attributes | |
92 | self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} } |
|
112 | self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} } | |
93 | end |
|
113 | end | |
94 |
|
114 | |||
95 | def executed_by=(user) |
|
115 | def executed_by=(user) | |
96 | @executed_by = user |
|
116 | @executed_by = user | |
97 | set_language_if_valid(user.language) if user |
|
117 | set_language_if_valid(user.language) if user | |
98 | end |
|
118 | end | |
99 |
|
119 | |||
100 | def validate |
|
120 | def validate | |
101 | filters.each_key do |field| |
|
121 | filters.each_key do |field| | |
102 | errors.add label_for(field), :activerecord_error_blank unless |
|
122 | errors.add label_for(field), :activerecord_error_blank unless | |
103 | # filter requires one or more values |
|
123 | # filter requires one or more values | |
104 | (values_for(field) and !values_for(field).first.empty?) or |
|
124 | (values_for(field) and !values_for(field).first.empty?) or | |
105 | # filter doesn't require any value |
|
125 | # filter doesn't require any value | |
106 | ["o", "c", "!*", "*", "t", "w"].include? operator_for(field) |
|
126 | ["o", "c", "!*", "*", "t", "w"].include? operator_for(field) | |
107 | end if filters |
|
127 | end if filters | |
108 | end |
|
128 | end | |
109 |
|
129 | |||
110 | def editable_by?(user) |
|
130 | def editable_by?(user) | |
111 | return false unless user |
|
131 | return false unless user | |
112 | return true if !is_public && self.user_id == user.id |
|
132 | return true if !is_public && self.user_id == user.id | |
113 | is_public && user.allowed_to?(:manage_public_queries, project) |
|
133 | is_public && user.allowed_to?(:manage_public_queries, project) | |
114 | end |
|
134 | end | |
115 |
|
135 | |||
116 | def available_filters |
|
136 | def available_filters | |
117 | return @available_filters if @available_filters |
|
137 | return @available_filters if @available_filters | |
118 | @available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } }, |
|
138 | @available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } }, | |
119 | "tracker_id" => { :type => :list, :order => 2, :values => Tracker.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } }, |
|
139 | "tracker_id" => { :type => :list, :order => 2, :values => Tracker.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } }, | |
120 | "priority_id" => { :type => :list, :order => 3, :values => Enumeration.find(:all, :conditions => ['opt=?','IPRI']).collect{|s| [s.name, s.id.to_s] } }, |
|
140 | "priority_id" => { :type => :list, :order => 3, :values => Enumeration.find(:all, :conditions => ['opt=?','IPRI']).collect{|s| [s.name, s.id.to_s] } }, | |
121 | "subject" => { :type => :text, :order => 8 }, |
|
141 | "subject" => { :type => :text, :order => 8 }, | |
122 | "created_on" => { :type => :date_past, :order => 9 }, |
|
142 | "created_on" => { :type => :date_past, :order => 9 }, | |
123 | "updated_on" => { :type => :date_past, :order => 10 }, |
|
143 | "updated_on" => { :type => :date_past, :order => 10 }, | |
124 | "start_date" => { :type => :date, :order => 11 }, |
|
144 | "start_date" => { :type => :date, :order => 11 }, | |
125 | "due_date" => { :type => :date, :order => 12 }, |
|
145 | "due_date" => { :type => :date, :order => 12 }, | |
126 | "done_ratio" => { :type => :integer, :order => 13 }} |
|
146 | "done_ratio" => { :type => :integer, :order => 13 }} | |
127 |
|
147 | |||
128 | user_values = [] |
|
148 | user_values = [] | |
129 | user_values << ["<< #{l(:label_me)} >>", "me"] if executed_by |
|
149 | user_values << ["<< #{l(:label_me)} >>", "me"] if executed_by | |
130 | if project |
|
150 | if project | |
131 | user_values += project.users.collect{|s| [s.name, s.id.to_s] } |
|
151 | user_values += project.users.collect{|s| [s.name, s.id.to_s] } | |
132 | elsif executed_by |
|
152 | elsif executed_by | |
133 | # members of the user's projects |
|
153 | # members of the user's projects | |
134 | user_values += executed_by.projects.collect(&:users).flatten.uniq.sort.collect{|s| [s.name, s.id.to_s] } |
|
154 | user_values += executed_by.projects.collect(&:users).flatten.uniq.sort.collect{|s| [s.name, s.id.to_s] } | |
135 | end |
|
155 | end | |
136 | @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty? |
|
156 | @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty? | |
137 | @available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty? |
|
157 | @available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty? | |
138 |
|
158 | |||
139 | if project |
|
159 | if project | |
140 | # project specific filters |
|
160 | # project specific filters | |
141 | @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } } |
|
161 | @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } } | |
142 | @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } } |
|
162 | @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } } | |
143 | unless @project.active_children.empty? |
|
163 | unless @project.active_children.empty? | |
144 | @available_filters["subproject_id"] = { :type => :list_one_or_more, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } } |
|
164 | @available_filters["subproject_id"] = { :type => :list_one_or_more, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } } | |
145 | end |
|
165 | end | |
146 | @project.all_custom_fields.select(&:is_filter?).each do |field| |
|
166 | @project.all_custom_fields.select(&:is_filter?).each do |field| | |
147 | case field.field_format |
|
167 | case field.field_format | |
148 | when "string", "int" |
|
168 | when "string", "int" | |
149 | options = { :type => :string, :order => 20 } |
|
169 | options = { :type => :string, :order => 20 } | |
150 | when "text" |
|
170 | when "text" | |
151 | options = { :type => :text, :order => 20 } |
|
171 | options = { :type => :text, :order => 20 } | |
152 | when "list" |
|
172 | when "list" | |
153 | options = { :type => :list_optional, :values => field.possible_values, :order => 20} |
|
173 | options = { :type => :list_optional, :values => field.possible_values, :order => 20} | |
154 | when "date" |
|
174 | when "date" | |
155 | options = { :type => :date, :order => 20 } |
|
175 | options = { :type => :date, :order => 20 } | |
156 | when "bool" |
|
176 | when "bool" | |
157 | options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 } |
|
177 | options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 } | |
158 | end |
|
178 | end | |
159 | @available_filters["cf_#{field.id}"] = options.merge({ :name => field.name }) |
|
179 | @available_filters["cf_#{field.id}"] = options.merge({ :name => field.name }) | |
160 | end |
|
180 | end | |
161 | # remove category filter if no category defined |
|
181 | # remove category filter if no category defined | |
162 | @available_filters.delete "category_id" if @available_filters["category_id"][:values].empty? |
|
182 | @available_filters.delete "category_id" if @available_filters["category_id"][:values].empty? | |
163 | end |
|
183 | end | |
164 | @available_filters |
|
184 | @available_filters | |
165 | end |
|
185 | end | |
166 |
|
186 | |||
167 | def add_filter(field, operator, values) |
|
187 | def add_filter(field, operator, values) | |
168 | # values must be an array |
|
188 | # values must be an array | |
169 | return unless values and values.is_a? Array # and !values.first.empty? |
|
189 | return unless values and values.is_a? Array # and !values.first.empty? | |
170 | # check if field is defined as an available filter |
|
190 | # check if field is defined as an available filter | |
171 | if available_filters.has_key? field |
|
191 | if available_filters.has_key? field | |
172 | filter_options = available_filters[field] |
|
192 | filter_options = available_filters[field] | |
173 | # check if operator is allowed for that filter |
|
193 | # check if operator is allowed for that filter | |
174 | #if @@operators_by_filter_type[filter_options[:type]].include? operator |
|
194 | #if @@operators_by_filter_type[filter_options[:type]].include? operator | |
175 | # allowed_values = values & ([""] + (filter_options[:values] || []).collect {|val| val[1]}) |
|
195 | # allowed_values = values & ([""] + (filter_options[:values] || []).collect {|val| val[1]}) | |
176 | # filters[field] = {:operator => operator, :values => allowed_values } if (allowed_values.first and !allowed_values.first.empty?) or ["o", "c", "!*", "*", "t"].include? operator |
|
196 | # filters[field] = {:operator => operator, :values => allowed_values } if (allowed_values.first and !allowed_values.first.empty?) or ["o", "c", "!*", "*", "t"].include? operator | |
177 | #end |
|
197 | #end | |
178 | filters[field] = {:operator => operator, :values => values } |
|
198 | filters[field] = {:operator => operator, :values => values } | |
179 | end |
|
199 | end | |
180 | end |
|
200 | end | |
181 |
|
201 | |||
182 | def add_short_filter(field, expression) |
|
202 | def add_short_filter(field, expression) | |
183 | return unless expression |
|
203 | return unless expression | |
184 | parms = expression.scan(/^(o|c|\!|\*)?(.*)$/).first |
|
204 | parms = expression.scan(/^(o|c|\!|\*)?(.*)$/).first | |
185 | add_filter field, (parms[0] || "="), [parms[1] || ""] |
|
205 | add_filter field, (parms[0] || "="), [parms[1] || ""] | |
186 | end |
|
206 | end | |
187 |
|
207 | |||
188 | def has_filter?(field) |
|
208 | def has_filter?(field) | |
189 | filters and filters[field] |
|
209 | filters and filters[field] | |
190 | end |
|
210 | end | |
191 |
|
211 | |||
192 | def operator_for(field) |
|
212 | def operator_for(field) | |
193 | has_filter?(field) ? filters[field][:operator] : nil |
|
213 | has_filter?(field) ? filters[field][:operator] : nil | |
194 | end |
|
214 | end | |
195 |
|
215 | |||
196 | def values_for(field) |
|
216 | def values_for(field) | |
197 | has_filter?(field) ? filters[field][:values] : nil |
|
217 | has_filter?(field) ? filters[field][:values] : nil | |
198 | end |
|
218 | end | |
199 |
|
219 | |||
200 | def label_for(field) |
|
220 | def label_for(field) | |
201 | label = @available_filters[field][:name] if @available_filters.has_key?(field) |
|
221 | label = @available_filters[field][:name] if @available_filters.has_key?(field) | |
202 | label ||= field.gsub(/\_id$/, "") |
|
222 | label ||= field.gsub(/\_id$/, "") | |
203 | end |
|
223 | end | |
204 |
|
224 | |||
205 | def available_columns |
|
225 | def available_columns | |
206 | cols = Query.available_columns |
|
226 | return @available_columns if @available_columns | |
|
227 | @available_columns = Query.available_columns | |||
|
228 | @available_columns += (project ? | |||
|
229 | project.custom_fields : | |||
|
230 | IssueCustomField.find(:all, :conditions => {:is_for_all => true}) | |||
|
231 | ).collect {|cf| QueryCustomFieldColumn.new(cf) } | |||
207 | end |
|
232 | end | |
208 |
|
233 | |||
209 | def columns |
|
234 | def columns | |
210 | if has_default_columns? |
|
235 | if has_default_columns? | |
211 | available_columns.select {|c| Setting.issue_list_default_columns.include?(c.name.to_s) } |
|
236 | available_columns.select {|c| Setting.issue_list_default_columns.include?(c.name.to_s) } | |
212 | else |
|
237 | else | |
213 | # preserve the column_names order |
|
238 | # preserve the column_names order | |
214 | column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact |
|
239 | column_names.collect {|name| available_columns.find {|col| col.name == name}}.compact | |
215 | end |
|
240 | end | |
216 | end |
|
241 | end | |
217 |
|
242 | |||
218 | def column_names=(names) |
|
243 | def column_names=(names) | |
219 | names = names.select {|n| n.is_a?(Symbol) || !n.blank? } if names |
|
244 | names = names.select {|n| n.is_a?(Symbol) || !n.blank? } if names | |
220 | names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym } if names |
|
245 | names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym } if names | |
221 | write_attribute(:column_names, names) |
|
246 | write_attribute(:column_names, names) | |
222 | end |
|
247 | end | |
223 |
|
248 | |||
224 | def has_column?(column) |
|
249 | def has_column?(column) | |
225 | column_names && column_names.include?(column.name) |
|
250 | column_names && column_names.include?(column.name) | |
226 | end |
|
251 | end | |
227 |
|
252 | |||
228 | def has_default_columns? |
|
253 | def has_default_columns? | |
229 | column_names.nil? || column_names.empty? |
|
254 | column_names.nil? || column_names.empty? | |
230 | end |
|
255 | end | |
231 |
|
256 | |||
232 | def statement |
|
257 | def statement | |
233 | # project/subprojects clause |
|
258 | # project/subprojects clause | |
234 | clause = '' |
|
259 | clause = '' | |
235 | if project && has_filter?("subproject_id") |
|
260 | if project && has_filter?("subproject_id") | |
236 | subproject_ids = [] |
|
261 | subproject_ids = [] | |
237 | if operator_for("subproject_id") == "=" |
|
262 | if operator_for("subproject_id") == "=" | |
238 | subproject_ids = values_for("subproject_id").each(&:to_i) |
|
263 | subproject_ids = values_for("subproject_id").each(&:to_i) | |
239 | else |
|
264 | else | |
240 | subproject_ids = project.active_children.collect{|p| p.id} |
|
265 | subproject_ids = project.active_children.collect{|p| p.id} | |
241 | end |
|
266 | end | |
242 | clause << "#{Issue.table_name}.project_id IN (%d,%s)" % [project.id, subproject_ids.join(",")] if project |
|
267 | clause << "#{Issue.table_name}.project_id IN (%d,%s)" % [project.id, subproject_ids.join(",")] if project | |
243 | elsif project |
|
268 | elsif project | |
244 | clause << "#{Issue.table_name}.project_id=%d" % project.id |
|
269 | clause << "#{Issue.table_name}.project_id=%d" % project.id | |
245 | else |
|
270 | else | |
246 | clause << Project.visible_by(executed_by) |
|
271 | clause << Project.visible_by(executed_by) | |
247 | end |
|
272 | end | |
248 |
|
273 | |||
249 | # filters clauses |
|
274 | # filters clauses | |
250 | filters_clauses = [] |
|
275 | filters_clauses = [] | |
251 | filters.each_key do |field| |
|
276 | filters.each_key do |field| | |
252 | next if field == "subproject_id" |
|
277 | next if field == "subproject_id" | |
253 | v = values_for(field).clone |
|
278 | v = values_for(field).clone | |
254 | next unless v and !v.empty? |
|
279 | next unless v and !v.empty? | |
255 |
|
280 | |||
256 | sql = '' |
|
281 | sql = '' | |
257 | if field =~ /^cf_(\d+)$/ |
|
282 | if field =~ /^cf_(\d+)$/ | |
258 | # custom field |
|
283 | # custom field | |
259 | db_table = CustomValue.table_name |
|
284 | db_table = CustomValue.table_name | |
260 | db_field = 'value' |
|
285 | db_field = 'value' | |
261 | sql << "#{Issue.table_name}.id IN (SELECT #{db_table}.customized_id FROM #{db_table} where #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{$1} AND " |
|
286 | sql << "#{Issue.table_name}.id IN (SELECT #{db_table}.customized_id FROM #{db_table} where #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{$1} AND " | |
262 | else |
|
287 | else | |
263 | # regular field |
|
288 | # regular field | |
264 | db_table = Issue.table_name |
|
289 | db_table = Issue.table_name | |
265 | db_field = field |
|
290 | db_field = field | |
266 | sql << '(' |
|
291 | sql << '(' | |
267 | end |
|
292 | end | |
268 |
|
293 | |||
269 | # "me" value subsitution |
|
294 | # "me" value subsitution | |
270 | if %w(assigned_to_id author_id).include?(field) |
|
295 | if %w(assigned_to_id author_id).include?(field) | |
271 | v.push(executed_by ? executed_by.id.to_s : "0") if v.delete("me") |
|
296 | v.push(executed_by ? executed_by.id.to_s : "0") if v.delete("me") | |
272 | end |
|
297 | end | |
273 |
|
298 | |||
274 | case operator_for field |
|
299 | case operator_for field | |
275 | when "=" |
|
300 | when "=" | |
276 | sql = sql + "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" |
|
301 | sql = sql + "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" | |
277 | when "!" |
|
302 | when "!" | |
278 | sql = sql + "#{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" |
|
303 | sql = sql + "#{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" | |
279 | when "!*" |
|
304 | when "!*" | |
280 | sql = sql + "#{db_table}.#{db_field} IS NULL" |
|
305 | sql = sql + "#{db_table}.#{db_field} IS NULL" | |
281 | when "*" |
|
306 | when "*" | |
282 | sql = sql + "#{db_table}.#{db_field} IS NOT NULL" |
|
307 | sql = sql + "#{db_table}.#{db_field} IS NOT NULL" | |
283 | when ">=" |
|
308 | when ">=" | |
284 | sql = sql + "#{db_table}.#{db_field} >= #{v.first.to_i}" |
|
309 | sql = sql + "#{db_table}.#{db_field} >= #{v.first.to_i}" | |
285 | when "<=" |
|
310 | when "<=" | |
286 | sql = sql + "#{db_table}.#{db_field} <= #{v.first.to_i}" |
|
311 | sql = sql + "#{db_table}.#{db_field} <= #{v.first.to_i}" | |
287 | when "o" |
|
312 | when "o" | |
288 | sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id" |
|
313 | sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id" | |
289 | when "c" |
|
314 | when "c" | |
290 | sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id" |
|
315 | sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id" | |
291 | when ">t-" |
|
316 | when ">t-" | |
292 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today + 1).to_time)] |
|
317 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today + 1).to_time)] | |
293 | when "<t-" |
|
318 | when "<t-" | |
294 | sql = sql + "#{db_table}.#{db_field} <= '%s'" % connection.quoted_date((Date.today - v.first.to_i).to_time) |
|
319 | sql = sql + "#{db_table}.#{db_field} <= '%s'" % connection.quoted_date((Date.today - v.first.to_i).to_time) | |
295 | when "t-" |
|
320 | when "t-" | |
296 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today - v.first.to_i + 1).to_time)] |
|
321 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today - v.first.to_i + 1).to_time)] | |
297 | when ">t+" |
|
322 | when ">t+" | |
298 | sql = sql + "#{db_table}.#{db_field} >= '%s'" % connection.quoted_date((Date.today + v.first.to_i).to_time) |
|
323 | sql = sql + "#{db_table}.#{db_field} >= '%s'" % connection.quoted_date((Date.today + v.first.to_i).to_time) | |
299 | when "<t+" |
|
324 | when "<t+" | |
300 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)] |
|
325 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)] | |
301 | when "t+" |
|
326 | when "t+" | |
302 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today + v.first.to_i).to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)] |
|
327 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today + v.first.to_i).to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)] | |
303 | when "t" |
|
328 | when "t" | |
304 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today+1).to_time)] |
|
329 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today+1).to_time)] | |
305 | when "w" |
|
330 | when "w" | |
306 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Time.now.at_beginning_of_week), connection.quoted_date(Time.now.next_week.yesterday)] |
|
331 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Time.now.at_beginning_of_week), connection.quoted_date(Time.now.next_week.yesterday)] | |
307 | when "~" |
|
332 | when "~" | |
308 | sql = sql + "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'" |
|
333 | sql = sql + "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'" | |
309 | when "!~" |
|
334 | when "!~" | |
310 | sql = sql + "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(v.first)}%'" |
|
335 | sql = sql + "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(v.first)}%'" | |
311 | end |
|
336 | end | |
312 | sql << ')' |
|
337 | sql << ')' | |
313 | filters_clauses << sql |
|
338 | filters_clauses << sql | |
314 | end if filters and valid? |
|
339 | end if filters and valid? | |
315 |
|
340 | |||
316 | clause << ' AND ' unless clause.empty? |
|
341 | clause << ' AND ' unless clause.empty? | |
317 | clause << filters_clauses.join(' AND ') unless filters_clauses.empty? |
|
342 | clause << filters_clauses.join(' AND ') unless filters_clauses.empty? | |
318 | clause |
|
343 | clause | |
319 | end |
|
344 | end | |
320 | end |
|
345 | end |
@@ -1,27 +1,27 | |||||
1 | <% content_tag 'fieldset', :id => 'columns', :style => (query.has_default_columns? ? 'display:none;' : nil) do %> |
|
1 | <% content_tag 'fieldset', :id => 'columns', :style => (query.has_default_columns? ? 'display:none;' : nil) do %> | |
2 | <legend><%= l(:field_column_names) %></legend> |
|
2 | <legend><%= l(:field_column_names) %></legend> | |
3 |
|
3 | |||
4 | <%= hidden_field_tag 'query[column_names][]', '' %> |
|
4 | <%= hidden_field_tag 'query[column_names][]', '' %> | |
5 | <table margin=0> |
|
5 | <table margin=0> | |
6 | <tr> |
|
6 | <tr> | |
7 | <td><%= select_tag 'available_columns', |
|
7 | <td><%= select_tag 'available_columns', | |
8 |
options_for_select((query.available_columns - query.columns).collect {|column| [ |
|
8 | options_for_select((query.available_columns - query.columns).collect {|column| [column.caption, column.name]}), | |
9 | :multiple => true, :size => 10, :style => "width:150px" %> |
|
9 | :multiple => true, :size => 10, :style => "width:150px" %> | |
10 | </td> |
|
10 | </td> | |
11 | <td align="center" valign="middle"> |
|
11 | <td align="center" valign="middle"> | |
12 | <input type="button" value="-->" |
|
12 | <input type="button" value="-->" | |
13 | onclick="moveOptions(this.form.available_columns, this.form.selected_columns);" /><br /> |
|
13 | onclick="moveOptions(this.form.available_columns, this.form.selected_columns);" /><br /> | |
14 | <input type="button" value="<--" |
|
14 | <input type="button" value="<--" | |
15 | onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" /> |
|
15 | onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" /> | |
16 | </td> |
|
16 | </td> | |
17 | <td><%= select_tag 'query[column_names][]', |
|
17 | <td><%= select_tag 'query[column_names][]', | |
18 |
options_for_select(@query.columns.collect {|column| [ |
|
18 | options_for_select(@query.columns.collect {|column| [column.caption, column.name]}), | |
19 | :id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %> |
|
19 | :id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %> | |
20 | </td> |
|
20 | </td> | |
21 | </tr> |
|
21 | </tr> | |
22 | </table> |
|
22 | </table> | |
23 | <% end %> |
|
23 | <% end %> | |
24 |
|
24 | |||
25 | <% content_for :header_tags do %> |
|
25 | <% content_for :header_tags do %> | |
26 | <%= javascript_include_tag 'select_list_move' %> |
|
26 | <%= javascript_include_tag 'select_list_move' %> | |
27 | <% end %> |
|
27 | <% end %> |
@@ -1,97 +1,97 | |||||
1 | <h2><%= l(:label_settings) %></h2> |
|
1 | <h2><%= l(:label_settings) %></h2> | |
2 |
|
2 | |||
3 | <div id="settings"> |
|
3 | <div id="settings"> | |
4 | <% form_tag({:action => 'edit'}) do %> |
|
4 | <% form_tag({:action => 'edit'}) do %> | |
5 | <div class="box tabular"> |
|
5 | <div class="box tabular"> | |
6 | <p><label><%= l(:setting_app_title) %></label> |
|
6 | <p><label><%= l(:setting_app_title) %></label> | |
7 | <%= text_field_tag 'settings[app_title]', Setting.app_title, :size => 30 %></p> |
|
7 | <%= text_field_tag 'settings[app_title]', Setting.app_title, :size => 30 %></p> | |
8 |
|
8 | |||
9 | <p><label><%= l(:setting_app_subtitle) %></label> |
|
9 | <p><label><%= l(:setting_app_subtitle) %></label> | |
10 | <%= text_field_tag 'settings[app_subtitle]', Setting.app_subtitle, :size => 60 %></p> |
|
10 | <%= text_field_tag 'settings[app_subtitle]', Setting.app_subtitle, :size => 60 %></p> | |
11 |
|
11 | |||
12 | <p><label><%= l(:setting_welcome_text) %></label> |
|
12 | <p><label><%= l(:setting_welcome_text) %></label> | |
13 | <%= text_area_tag 'settings[welcome_text]', Setting.welcome_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %></p> |
|
13 | <%= text_area_tag 'settings[welcome_text]', Setting.welcome_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %></p> | |
14 | <%= wikitoolbar_for 'settings[welcome_text]' %> |
|
14 | <%= wikitoolbar_for 'settings[welcome_text]' %> | |
15 |
|
15 | |||
16 | <p><label><%= l(:label_theme) %></label> |
|
16 | <p><label><%= l(:label_theme) %></label> | |
17 | <%= select_tag 'settings[ui_theme]', options_for_select( ([[l(:label_default), '']] + Redmine::Themes.themes.collect {|t| [t.name, t.id]}), Setting.ui_theme) %></p> |
|
17 | <%= select_tag 'settings[ui_theme]', options_for_select( ([[l(:label_default), '']] + Redmine::Themes.themes.collect {|t| [t.name, t.id]}), Setting.ui_theme) %></p> | |
18 |
|
18 | |||
19 | <p><label><%= l(:setting_default_language) %></label> |
|
19 | <p><label><%= l(:setting_default_language) %></label> | |
20 | <%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p> |
|
20 | <%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p> | |
21 |
|
21 | |||
22 | <p><label><%= l(:setting_date_format) %></label> |
|
22 | <p><label><%= l(:setting_date_format) %></label> | |
23 | <%= select_tag 'settings[date_format]', options_for_select( [[l(:label_language_based), '0'], ['ISO 8601 (YYYY-MM-DD)', '1']], Setting.date_format) %></p> |
|
23 | <%= select_tag 'settings[date_format]', options_for_select( [[l(:label_language_based), '0'], ['ISO 8601 (YYYY-MM-DD)', '1']], Setting.date_format) %></p> | |
24 |
|
24 | |||
25 | <p><label><%= l(:setting_attachment_max_size) %></label> |
|
25 | <p><label><%= l(:setting_attachment_max_size) %></label> | |
26 | <%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %> KB</p> |
|
26 | <%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %> KB</p> | |
27 |
|
27 | |||
28 | <p><label><%= l(:setting_issues_export_limit) %></label> |
|
28 | <p><label><%= l(:setting_issues_export_limit) %></label> | |
29 | <%= text_field_tag 'settings[issues_export_limit]', Setting.issues_export_limit, :size => 6 %></p> |
|
29 | <%= text_field_tag 'settings[issues_export_limit]', Setting.issues_export_limit, :size => 6 %></p> | |
30 |
|
30 | |||
31 | <p><label><%= l(:setting_cross_project_issue_relations) %></label> |
|
31 | <p><label><%= l(:setting_cross_project_issue_relations) %></label> | |
32 | <%= check_box_tag 'settings[cross_project_issue_relations]', 1, Setting.cross_project_issue_relations? %><%= hidden_field_tag 'settings[cross_project_issue_relations]', 0 %></p> |
|
32 | <%= check_box_tag 'settings[cross_project_issue_relations]', 1, Setting.cross_project_issue_relations? %><%= hidden_field_tag 'settings[cross_project_issue_relations]', 0 %></p> | |
33 |
|
33 | |||
34 | <p><label><%= l(:setting_mail_from) %></label> |
|
34 | <p><label><%= l(:setting_mail_from) %></label> | |
35 | <%= text_field_tag 'settings[mail_from]', Setting.mail_from, :size => 60 %></p> |
|
35 | <%= text_field_tag 'settings[mail_from]', Setting.mail_from, :size => 60 %></p> | |
36 |
|
36 | |||
37 | <p><label><%= l(:setting_host_name) %></label> |
|
37 | <p><label><%= l(:setting_host_name) %></label> | |
38 | <%= text_field_tag 'settings[host_name]', Setting.host_name, :size => 60 %></p> |
|
38 | <%= text_field_tag 'settings[host_name]', Setting.host_name, :size => 60 %></p> | |
39 |
|
39 | |||
40 | <p><label><%= l(:setting_protocol) %></label> |
|
40 | <p><label><%= l(:setting_protocol) %></label> | |
41 | <%= select_tag 'settings[protocol]', options_for_select(['http', 'https'], Setting.protocol) %></p> |
|
41 | <%= select_tag 'settings[protocol]', options_for_select(['http', 'https'], Setting.protocol) %></p> | |
42 |
|
42 | |||
43 | <p><label><%= l(:setting_text_formatting) %></label> |
|
43 | <p><label><%= l(:setting_text_formatting) %></label> | |
44 | <%= select_tag 'settings[text_formatting]', options_for_select([[l(:label_none), "0"], ["textile", "textile"]], Setting.text_formatting) %></p> |
|
44 | <%= select_tag 'settings[text_formatting]', options_for_select([[l(:label_none), "0"], ["textile", "textile"]], Setting.text_formatting) %></p> | |
45 |
|
45 | |||
46 | <p><label><%= l(:setting_wiki_compression) %></label> |
|
46 | <p><label><%= l(:setting_wiki_compression) %></label> | |
47 | <%= select_tag 'settings[wiki_compression]', options_for_select( [[l(:label_none), 0], ["gzip", "gzip"]], Setting.wiki_compression) %></p> |
|
47 | <%= select_tag 'settings[wiki_compression]', options_for_select( [[l(:label_none), 0], ["gzip", "gzip"]], Setting.wiki_compression) %></p> | |
48 |
|
48 | |||
49 | <p><label><%= l(:setting_feeds_limit) %></label> |
|
49 | <p><label><%= l(:setting_feeds_limit) %></label> | |
50 | <%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></p> |
|
50 | <%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></p> | |
51 |
|
51 | |||
52 | <p><label><%= l(:setting_autofetch_changesets) %></label> |
|
52 | <p><label><%= l(:setting_autofetch_changesets) %></label> | |
53 | <%= check_box_tag 'settings[autofetch_changesets]', 1, Setting.autofetch_changesets? %><%= hidden_field_tag 'settings[autofetch_changesets]', 0 %></p> |
|
53 | <%= check_box_tag 'settings[autofetch_changesets]', 1, Setting.autofetch_changesets? %><%= hidden_field_tag 'settings[autofetch_changesets]', 0 %></p> | |
54 |
|
54 | |||
55 | <p><label><%= l(:setting_sys_api_enabled) %></label> |
|
55 | <p><label><%= l(:setting_sys_api_enabled) %></label> | |
56 | <%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %><%= hidden_field_tag 'settings[sys_api_enabled]', 0 %></p> |
|
56 | <%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %><%= hidden_field_tag 'settings[sys_api_enabled]', 0 %></p> | |
57 |
|
57 | |||
58 | <p><label><%= l(:setting_repositories_encodings) %></label> |
|
58 | <p><label><%= l(:setting_repositories_encodings) %></label> | |
59 | <%= text_field_tag 'settings[repositories_encodings]', Setting.repositories_encodings, :size => 60 %><br /><em><%= l(:text_comma_separated) %></em></p> |
|
59 | <%= text_field_tag 'settings[repositories_encodings]', Setting.repositories_encodings, :size => 60 %><br /><em><%= l(:text_comma_separated) %></em></p> | |
60 | </div> |
|
60 | </div> | |
61 |
|
61 | |||
62 | <fieldset class="box"><legend><%= l(:setting_issue_list_default_columns) %></legend> |
|
62 | <fieldset class="box"><legend><%= l(:setting_issue_list_default_columns) %></legend> | |
63 | <%= hidden_field_tag 'settings[issue_list_default_columns][]', '' %> |
|
63 | <%= hidden_field_tag 'settings[issue_list_default_columns][]', '' %> | |
64 | <p><% Query.available_columns.each do |column| %> |
|
64 | <p><% Query.new.available_columns.each do |column| %> | |
65 | <label><%= check_box_tag 'settings[issue_list_default_columns][]', column.name, Setting.issue_list_default_columns.include?(column.name.to_s) %> |
|
65 | <label><%= check_box_tag 'settings[issue_list_default_columns][]', column.name, Setting.issue_list_default_columns.include?(column.name.to_s) %> | |
66 |
<%= |
|
66 | <%= column.caption %></label> | |
67 | <% end %></p> |
|
67 | <% end %></p> | |
68 | </fieldset> |
|
68 | </fieldset> | |
69 |
|
69 | |||
70 | <fieldset class="box tabular"><legend><%= l(:label_authentication) %></legend> |
|
70 | <fieldset class="box tabular"><legend><%= l(:label_authentication) %></legend> | |
71 | <p><label><%= l(:setting_login_required) %></label> |
|
71 | <p><label><%= l(:setting_login_required) %></label> | |
72 | <%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p> |
|
72 | <%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p> | |
73 |
|
73 | |||
74 | <p><label><%= l(:setting_autologin) %></label> |
|
74 | <p><label><%= l(:setting_autologin) %></label> | |
75 | <%= select_tag 'settings[autologin]', options_for_select( [[l(:label_disabled), "0"]] + [1, 7, 30, 365].collect{|days| [lwr(:actionview_datehelper_time_in_words_day, days), days.to_s]}, Setting.autologin) %></p> |
|
75 | <%= select_tag 'settings[autologin]', options_for_select( [[l(:label_disabled), "0"]] + [1, 7, 30, 365].collect{|days| [lwr(:actionview_datehelper_time_in_words_day, days), days.to_s]}, Setting.autologin) %></p> | |
76 |
|
76 | |||
77 | <p><label><%= l(:setting_self_registration) %></label> |
|
77 | <p><label><%= l(:setting_self_registration) %></label> | |
78 | <%= check_box_tag 'settings[self_registration]', 1, Setting.self_registration? %><%= hidden_field_tag 'settings[self_registration]', 0 %></p> |
|
78 | <%= check_box_tag 'settings[self_registration]', 1, Setting.self_registration? %><%= hidden_field_tag 'settings[self_registration]', 0 %></p> | |
79 |
|
79 | |||
80 | <p><label><%= l(:label_password_lost) %></label> |
|
80 | <p><label><%= l(:label_password_lost) %></label> | |
81 | <%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p> |
|
81 | <%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p> | |
82 | </fieldset> |
|
82 | </fieldset> | |
83 |
|
83 | |||
84 | <fieldset class="box tabular"><legend><%= l(:text_issues_ref_in_commit_messages) %></legend> |
|
84 | <fieldset class="box tabular"><legend><%= l(:text_issues_ref_in_commit_messages) %></legend> | |
85 | <p><label><%= l(:setting_commit_ref_keywords) %></label> |
|
85 | <p><label><%= l(:setting_commit_ref_keywords) %></label> | |
86 | <%= text_field_tag 'settings[commit_ref_keywords]', Setting.commit_ref_keywords, :size => 30 %><br /><em><%= l(:text_comma_separated) %></em></p> |
|
86 | <%= text_field_tag 'settings[commit_ref_keywords]', Setting.commit_ref_keywords, :size => 30 %><br /><em><%= l(:text_comma_separated) %></em></p> | |
87 |
|
87 | |||
88 | <p><label><%= l(:setting_commit_fix_keywords) %></label> |
|
88 | <p><label><%= l(:setting_commit_fix_keywords) %></label> | |
89 | <%= text_field_tag 'settings[commit_fix_keywords]', Setting.commit_fix_keywords, :size => 30 %> |
|
89 | <%= text_field_tag 'settings[commit_fix_keywords]', Setting.commit_fix_keywords, :size => 30 %> | |
90 | <%= l(:label_applied_status) %>: <%= select_tag 'settings[commit_fix_status_id]', options_for_select( [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, Setting.commit_fix_status_id) %> |
|
90 | <%= l(:label_applied_status) %>: <%= select_tag 'settings[commit_fix_status_id]', options_for_select( [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, Setting.commit_fix_status_id) %> | |
91 | <%= l(:field_done_ratio) %>: <%= select_tag 'settings[commit_fix_done_ratio]', options_for_select( [[l(:label_no_change_option), '']] + ((0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }), Setting.commit_fix_done_ratio) %> |
|
91 | <%= l(:field_done_ratio) %>: <%= select_tag 'settings[commit_fix_done_ratio]', options_for_select( [[l(:label_no_change_option), '']] + ((0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }), Setting.commit_fix_done_ratio) %> | |
92 | <br /><em><%= l(:text_comma_separated) %></em></p> |
|
92 | <br /><em><%= l(:text_comma_separated) %></em></p> | |
93 | </fieldset> |
|
93 | </fieldset> | |
94 |
|
94 | |||
95 | <%= submit_tag l(:button_save) %> |
|
95 | <%= submit_tag l(:button_save) %> | |
96 | </div> |
|
96 | </div> | |
97 | <% end %> |
|
97 | <% end %> |
General Comments 0
You need to be logged in to leave comments.
Login now