@@ -1,450 +1,450 | |||||
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 ApplicationHelper |
|
18 | module ApplicationHelper | |
19 | include Redmine::WikiFormatting::Macros::Definitions |
|
19 | include Redmine::WikiFormatting::Macros::Definitions | |
20 |
|
20 | |||
21 | def current_role |
|
21 | def current_role | |
22 | @current_role ||= User.current.role_for_project(@project) |
|
22 | @current_role ||= User.current.role_for_project(@project) | |
23 | end |
|
23 | end | |
24 |
|
24 | |||
25 | # Return true if user is authorized for controller/action, otherwise false |
|
25 | # Return true if user is authorized for controller/action, otherwise false | |
26 | def authorize_for(controller, action) |
|
26 | def authorize_for(controller, action) | |
27 | User.current.allowed_to?({:controller => controller, :action => action}, @project) |
|
27 | User.current.allowed_to?({:controller => controller, :action => action}, @project) | |
28 | end |
|
28 | end | |
29 |
|
29 | |||
30 | # Display a link if user is authorized |
|
30 | # Display a link if user is authorized | |
31 | def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference) |
|
31 | def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference) | |
32 | link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action]) |
|
32 | link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action]) | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def link_to_signin |
|
35 | def link_to_signin | |
36 | link_to l(:label_login), { :controller => 'account', :action => 'login' }, :class => 'signin' |
|
36 | link_to l(:label_login), { :controller => 'account', :action => 'login' }, :class => 'signin' | |
37 | end |
|
37 | end | |
38 |
|
38 | |||
39 | def link_to_signout |
|
39 | def link_to_signout | |
40 | link_to l(:label_logout), { :controller => 'account', :action => 'logout' }, :class => 'logout' |
|
40 | link_to l(:label_logout), { :controller => 'account', :action => 'logout' }, :class => 'logout' | |
41 | end |
|
41 | end | |
42 |
|
42 | |||
43 | # Display a link to user's account page |
|
43 | # Display a link to user's account page | |
44 | def link_to_user(user) |
|
44 | def link_to_user(user) | |
45 | user ? link_to(user, :controller => 'account', :action => 'show', :id => user) : 'Anonymous' |
|
45 | user ? link_to(user, :controller => 'account', :action => 'show', :id => user) : 'Anonymous' | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | def link_to_issue(issue) |
|
48 | def link_to_issue(issue) | |
49 | link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue |
|
49 | link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue | |
50 | end |
|
50 | end | |
51 |
|
51 | |||
52 | def toggle_link(name, id, options={}) |
|
52 | def toggle_link(name, id, options={}) | |
53 | onclick = "Element.toggle('#{id}'); " |
|
53 | onclick = "Element.toggle('#{id}'); " | |
54 | onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ") |
|
54 | onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ") | |
55 | onclick << "return false;" |
|
55 | onclick << "return false;" | |
56 | link_to(name, "#", :onclick => onclick) |
|
56 | link_to(name, "#", :onclick => onclick) | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
59 | def show_and_goto_link(name, id, options={}) |
|
59 | def show_and_goto_link(name, id, options={}) | |
60 | onclick = "Element.show('#{id}'); " |
|
60 | onclick = "Element.show('#{id}'); " | |
61 | onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ") |
|
61 | onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ") | |
62 |
onclick << " |
|
62 | onclick << "Element.scrollTo('#{id}'); " | |
63 | onclick << "return false;" |
|
63 | onclick << "return false;" | |
64 | link_to(name, "#", options.merge(:onclick => onclick)) |
|
64 | link_to(name, "#", options.merge(:onclick => onclick)) | |
65 | end |
|
65 | end | |
66 |
|
66 | |||
67 | def image_to_function(name, function, html_options = {}) |
|
67 | def image_to_function(name, function, html_options = {}) | |
68 | html_options.symbolize_keys! |
|
68 | html_options.symbolize_keys! | |
69 | tag(:input, html_options.merge({ |
|
69 | tag(:input, html_options.merge({ | |
70 | :type => "image", :src => image_path(name), |
|
70 | :type => "image", :src => image_path(name), | |
71 | :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};" |
|
71 | :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};" | |
72 | })) |
|
72 | })) | |
73 | end |
|
73 | end | |
74 |
|
74 | |||
75 | def prompt_to_remote(name, text, param, url, html_options = {}) |
|
75 | def prompt_to_remote(name, text, param, url, html_options = {}) | |
76 | html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;" |
|
76 | html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;" | |
77 | link_to name, {}, html_options |
|
77 | link_to name, {}, html_options | |
78 | end |
|
78 | end | |
79 |
|
79 | |||
80 | def format_date(date) |
|
80 | def format_date(date) | |
81 | return nil unless date |
|
81 | return nil unless date | |
82 | # "Setting.date_format.size < 2" is a temporary fix (content of date_format setting changed) |
|
82 | # "Setting.date_format.size < 2" is a temporary fix (content of date_format setting changed) | |
83 | @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format) |
|
83 | @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format) | |
84 | date.strftime(@date_format) |
|
84 | date.strftime(@date_format) | |
85 | end |
|
85 | end | |
86 |
|
86 | |||
87 | def format_time(time, include_date = true) |
|
87 | def format_time(time, include_date = true) | |
88 | return nil unless time |
|
88 | return nil unless time | |
89 | time = time.to_time if time.is_a?(String) |
|
89 | time = time.to_time if time.is_a?(String) | |
90 | zone = User.current.time_zone |
|
90 | zone = User.current.time_zone | |
91 | if time.utc? |
|
91 | if time.utc? | |
92 | local = zone ? zone.adjust(time) : time.getlocal |
|
92 | local = zone ? zone.adjust(time) : time.getlocal | |
93 | else |
|
93 | else | |
94 | local = zone ? zone.adjust(time.getutc) : time |
|
94 | local = zone ? zone.adjust(time.getutc) : time | |
95 | end |
|
95 | end | |
96 | @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format) |
|
96 | @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format) | |
97 | @time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format) |
|
97 | @time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format) | |
98 | include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format) |
|
98 | include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format) | |
99 | end |
|
99 | end | |
100 |
|
100 | |||
101 | def authoring(created, author) |
|
101 | def authoring(created, author) | |
102 | time_tag = content_tag('acronym', distance_of_time_in_words(Time.now, created), :title => format_time(created)) |
|
102 | time_tag = content_tag('acronym', distance_of_time_in_words(Time.now, created), :title => format_time(created)) | |
103 | l(:label_added_time_by, author || 'Anonymous', time_tag) |
|
103 | l(:label_added_time_by, author || 'Anonymous', time_tag) | |
104 | end |
|
104 | end | |
105 |
|
105 | |||
106 | def day_name(day) |
|
106 | def day_name(day) | |
107 | l(:general_day_names).split(',')[day-1] |
|
107 | l(:general_day_names).split(',')[day-1] | |
108 | end |
|
108 | end | |
109 |
|
109 | |||
110 | def month_name(month) |
|
110 | def month_name(month) | |
111 | l(:actionview_datehelper_select_month_names).split(',')[month-1] |
|
111 | l(:actionview_datehelper_select_month_names).split(',')[month-1] | |
112 | end |
|
112 | end | |
113 |
|
113 | |||
114 | def pagination_links_full(paginator, count=nil, options={}) |
|
114 | def pagination_links_full(paginator, count=nil, options={}) | |
115 | page_param = options.delete(:page_param) || :page |
|
115 | page_param = options.delete(:page_param) || :page | |
116 | url_param = params.dup |
|
116 | url_param = params.dup | |
117 | # don't reuse params if filters are present |
|
117 | # don't reuse params if filters are present | |
118 | url_param.clear if url_param.has_key?(:set_filter) |
|
118 | url_param.clear if url_param.has_key?(:set_filter) | |
119 |
|
119 | |||
120 | html = '' |
|
120 | html = '' | |
121 | html << link_to_remote(('« ' + l(:label_previous)), |
|
121 | html << link_to_remote(('« ' + l(:label_previous)), | |
122 | {:update => 'content', |
|
122 | {:update => 'content', | |
123 | :url => url_param.merge(page_param => paginator.current.previous), |
|
123 | :url => url_param.merge(page_param => paginator.current.previous), | |
124 | :complete => 'window.scrollTo(0,0)'}, |
|
124 | :complete => 'window.scrollTo(0,0)'}, | |
125 | {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous |
|
125 | {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous | |
126 |
|
126 | |||
127 | html << (pagination_links_each(paginator, options) do |n| |
|
127 | html << (pagination_links_each(paginator, options) do |n| | |
128 | link_to_remote(n.to_s, |
|
128 | link_to_remote(n.to_s, | |
129 | {:url => {:params => url_param.merge(page_param => n)}, |
|
129 | {:url => {:params => url_param.merge(page_param => n)}, | |
130 | :update => 'content', |
|
130 | :update => 'content', | |
131 | :complete => 'window.scrollTo(0,0)'}, |
|
131 | :complete => 'window.scrollTo(0,0)'}, | |
132 | {:href => url_for(:params => url_param.merge(page_param => n))}) |
|
132 | {:href => url_for(:params => url_param.merge(page_param => n))}) | |
133 | end || '') |
|
133 | end || '') | |
134 |
|
134 | |||
135 | html << ' ' + link_to_remote((l(:label_next) + ' »'), |
|
135 | html << ' ' + link_to_remote((l(:label_next) + ' »'), | |
136 | {:update => 'content', |
|
136 | {:update => 'content', | |
137 | :url => url_param.merge(page_param => paginator.current.next), |
|
137 | :url => url_param.merge(page_param => paginator.current.next), | |
138 | :complete => 'window.scrollTo(0,0)'}, |
|
138 | :complete => 'window.scrollTo(0,0)'}, | |
139 | {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next |
|
139 | {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next | |
140 |
|
140 | |||
141 | unless count.nil? |
|
141 | unless count.nil? | |
142 | html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ') |
|
142 | html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ') | |
143 | end |
|
143 | end | |
144 |
|
144 | |||
145 | html |
|
145 | html | |
146 | end |
|
146 | end | |
147 |
|
147 | |||
148 | def per_page_links(selected=nil) |
|
148 | def per_page_links(selected=nil) | |
149 | url_param = params.dup |
|
149 | url_param = params.dup | |
150 | url_param.clear if url_param.has_key?(:set_filter) |
|
150 | url_param.clear if url_param.has_key?(:set_filter) | |
151 |
|
151 | |||
152 | links = Setting.per_page_options_array.collect do |n| |
|
152 | links = Setting.per_page_options_array.collect do |n| | |
153 | n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)}, |
|
153 | n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)}, | |
154 | {:href => url_for(url_param.merge(:per_page => n))}) |
|
154 | {:href => url_for(url_param.merge(:per_page => n))}) | |
155 | end |
|
155 | end | |
156 | links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil |
|
156 | links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil | |
157 | end |
|
157 | end | |
158 |
|
158 | |||
159 | def html_title(*args) |
|
159 | def html_title(*args) | |
160 | if args.empty? |
|
160 | if args.empty? | |
161 | title = [] |
|
161 | title = [] | |
162 | title << @project.name if @project |
|
162 | title << @project.name if @project | |
163 | title += @html_title if @html_title |
|
163 | title += @html_title if @html_title | |
164 | title << Setting.app_title |
|
164 | title << Setting.app_title | |
165 | title.compact.join(' - ') |
|
165 | title.compact.join(' - ') | |
166 | else |
|
166 | else | |
167 | @html_title ||= [] |
|
167 | @html_title ||= [] | |
168 | @html_title += args |
|
168 | @html_title += args | |
169 | end |
|
169 | end | |
170 | end |
|
170 | end | |
171 |
|
171 | |||
172 | def accesskey(s) |
|
172 | def accesskey(s) | |
173 | Redmine::AccessKeys.key_for s |
|
173 | Redmine::AccessKeys.key_for s | |
174 | end |
|
174 | end | |
175 |
|
175 | |||
176 | # Formats text according to system settings. |
|
176 | # Formats text according to system settings. | |
177 | # 2 ways to call this method: |
|
177 | # 2 ways to call this method: | |
178 | # * with a String: textilizable(text, options) |
|
178 | # * with a String: textilizable(text, options) | |
179 | # * with an object and one of its attribute: textilizable(issue, :description, options) |
|
179 | # * with an object and one of its attribute: textilizable(issue, :description, options) | |
180 | def textilizable(*args) |
|
180 | def textilizable(*args) | |
181 | options = args.last.is_a?(Hash) ? args.pop : {} |
|
181 | options = args.last.is_a?(Hash) ? args.pop : {} | |
182 | case args.size |
|
182 | case args.size | |
183 | when 1 |
|
183 | when 1 | |
184 | obj = nil |
|
184 | obj = nil | |
185 | text = args.shift || '' |
|
185 | text = args.shift || '' | |
186 | when 2 |
|
186 | when 2 | |
187 | obj = args.shift |
|
187 | obj = args.shift | |
188 | text = obj.send(args.shift) |
|
188 | text = obj.send(args.shift) | |
189 | else |
|
189 | else | |
190 | raise ArgumentError, 'invalid arguments to textilizable' |
|
190 | raise ArgumentError, 'invalid arguments to textilizable' | |
191 | end |
|
191 | end | |
192 |
|
192 | |||
193 | # when using an image link, try to use an attachment, if possible |
|
193 | # when using an image link, try to use an attachment, if possible | |
194 | attachments = options[:attachments] |
|
194 | attachments = options[:attachments] | |
195 | if attachments |
|
195 | if attachments | |
196 | text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(gif|jpg|jpeg|png))!/) do |m| |
|
196 | text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(gif|jpg|jpeg|png))!/) do |m| | |
197 | style = $1 |
|
197 | style = $1 | |
198 | filename = $6 |
|
198 | filename = $6 | |
199 | rf = Regexp.new(filename, Regexp::IGNORECASE) |
|
199 | rf = Regexp.new(filename, Regexp::IGNORECASE) | |
200 | # search for the picture in attachments |
|
200 | # search for the picture in attachments | |
201 | if found = attachments.detect { |att| att.filename =~ rf } |
|
201 | if found = attachments.detect { |att| att.filename =~ rf } | |
202 | image_url = url_for :controller => 'attachments', :action => 'download', :id => found.id |
|
202 | image_url = url_for :controller => 'attachments', :action => 'download', :id => found.id | |
203 | "!#{style}#{image_url}!" |
|
203 | "!#{style}#{image_url}!" | |
204 | else |
|
204 | else | |
205 | "!#{style}#{filename}!" |
|
205 | "!#{style}#{filename}!" | |
206 | end |
|
206 | end | |
207 | end |
|
207 | end | |
208 | end |
|
208 | end | |
209 |
|
209 | |||
210 | text = (Setting.text_formatting == 'textile') ? |
|
210 | text = (Setting.text_formatting == 'textile') ? | |
211 | Redmine::WikiFormatting.to_html(text) { |macro, args| exec_macro(macro, obj, args) } : |
|
211 | Redmine::WikiFormatting.to_html(text) { |macro, args| exec_macro(macro, obj, args) } : | |
212 | simple_format(auto_link(h(text))) |
|
212 | simple_format(auto_link(h(text))) | |
213 |
|
213 | |||
214 | # different methods for formatting wiki links |
|
214 | # different methods for formatting wiki links | |
215 | case options[:wiki_links] |
|
215 | case options[:wiki_links] | |
216 | when :local |
|
216 | when :local | |
217 | # used for local links to html files |
|
217 | # used for local links to html files | |
218 | format_wiki_link = Proc.new {|project, title| "#{title}.html" } |
|
218 | format_wiki_link = Proc.new {|project, title| "#{title}.html" } | |
219 | when :anchor |
|
219 | when :anchor | |
220 | # used for single-file wiki export |
|
220 | # used for single-file wiki export | |
221 | format_wiki_link = Proc.new {|project, title| "##{title}" } |
|
221 | format_wiki_link = Proc.new {|project, title| "##{title}" } | |
222 | else |
|
222 | else | |
223 | format_wiki_link = Proc.new {|project, title| url_for :controller => 'wiki', :action => 'index', :id => project, :page => title } |
|
223 | format_wiki_link = Proc.new {|project, title| url_for :controller => 'wiki', :action => 'index', :id => project, :page => title } | |
224 | end |
|
224 | end | |
225 |
|
225 | |||
226 | project = options[:project] || @project |
|
226 | project = options[:project] || @project | |
227 |
|
227 | |||
228 | # Wiki links |
|
228 | # Wiki links | |
229 | # |
|
229 | # | |
230 | # Examples: |
|
230 | # Examples: | |
231 | # [[mypage]] |
|
231 | # [[mypage]] | |
232 | # [[mypage|mytext]] |
|
232 | # [[mypage|mytext]] | |
233 | # wiki links can refer other project wikis, using project name or identifier: |
|
233 | # wiki links can refer other project wikis, using project name or identifier: | |
234 | # [[project:]] -> wiki starting page |
|
234 | # [[project:]] -> wiki starting page | |
235 | # [[project:|mytext]] |
|
235 | # [[project:|mytext]] | |
236 | # [[project:mypage]] |
|
236 | # [[project:mypage]] | |
237 | # [[project:mypage|mytext]] |
|
237 | # [[project:mypage|mytext]] | |
238 | text = text.gsub(/(!)?(\[\[([^\]\|]+)(\|([^\]\|]+))?\]\])/) do |m| |
|
238 | text = text.gsub(/(!)?(\[\[([^\]\|]+)(\|([^\]\|]+))?\]\])/) do |m| | |
239 | link_project = project |
|
239 | link_project = project | |
240 | esc, all, page, title = $1, $2, $3, $5 |
|
240 | esc, all, page, title = $1, $2, $3, $5 | |
241 | if esc.nil? |
|
241 | if esc.nil? | |
242 | if page =~ /^([^\:]+)\:(.*)$/ |
|
242 | if page =~ /^([^\:]+)\:(.*)$/ | |
243 | link_project = Project.find_by_name($1) || Project.find_by_identifier($1) |
|
243 | link_project = Project.find_by_name($1) || Project.find_by_identifier($1) | |
244 | page = $2 |
|
244 | page = $2 | |
245 | title ||= $1 if page.blank? |
|
245 | title ||= $1 if page.blank? | |
246 | end |
|
246 | end | |
247 |
|
247 | |||
248 | if link_project && link_project.wiki |
|
248 | if link_project && link_project.wiki | |
249 | # check if page exists |
|
249 | # check if page exists | |
250 | wiki_page = link_project.wiki.find_page(page) |
|
250 | wiki_page = link_project.wiki.find_page(page) | |
251 | link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)), |
|
251 | link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)), | |
252 | :class => ('wiki-page' + (wiki_page ? '' : ' new'))) |
|
252 | :class => ('wiki-page' + (wiki_page ? '' : ' new'))) | |
253 | else |
|
253 | else | |
254 | # project or wiki doesn't exist |
|
254 | # project or wiki doesn't exist | |
255 | title || page |
|
255 | title || page | |
256 | end |
|
256 | end | |
257 | else |
|
257 | else | |
258 | all |
|
258 | all | |
259 | end |
|
259 | end | |
260 | end |
|
260 | end | |
261 |
|
261 | |||
262 | # Redmine links |
|
262 | # Redmine links | |
263 | # |
|
263 | # | |
264 | # Examples: |
|
264 | # Examples: | |
265 | # Issues: |
|
265 | # Issues: | |
266 | # #52 -> Link to issue #52 |
|
266 | # #52 -> Link to issue #52 | |
267 | # Changesets: |
|
267 | # Changesets: | |
268 | # r52 -> Link to revision 52 |
|
268 | # r52 -> Link to revision 52 | |
269 | # Documents: |
|
269 | # Documents: | |
270 | # document#17 -> Link to document with id 17 |
|
270 | # document#17 -> Link to document with id 17 | |
271 | # document:Greetings -> Link to the document with title "Greetings" |
|
271 | # document:Greetings -> Link to the document with title "Greetings" | |
272 | # document:"Some document" -> Link to the document with title "Some document" |
|
272 | # document:"Some document" -> Link to the document with title "Some document" | |
273 | # Versions: |
|
273 | # Versions: | |
274 | # version#3 -> Link to version with id 3 |
|
274 | # version#3 -> Link to version with id 3 | |
275 | # version:1.0.0 -> Link to version named "1.0.0" |
|
275 | # version:1.0.0 -> Link to version named "1.0.0" | |
276 | # version:"1.0 beta 2" -> Link to version named "1.0 beta 2" |
|
276 | # version:"1.0 beta 2" -> Link to version named "1.0 beta 2" | |
277 | # Attachments: |
|
277 | # Attachments: | |
278 | # attachment:file.zip -> Link to the attachment of the current object named file.zip |
|
278 | # attachment:file.zip -> Link to the attachment of the current object named file.zip | |
279 | text = text.gsub(%r{([\s\(,-^])(!)?(attachment|document|version)?((#|r)(\d+)|(:)([^"][^\s<>]+|"[^"]+"))(?=[[:punct:]]|\s|<|$)}) do |m| |
|
279 | text = text.gsub(%r{([\s\(,-^])(!)?(attachment|document|version)?((#|r)(\d+)|(:)([^"][^\s<>]+|"[^"]+"))(?=[[:punct:]]|\s|<|$)}) do |m| | |
280 | leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8 |
|
280 | leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8 | |
281 | link = nil |
|
281 | link = nil | |
282 | if esc.nil? |
|
282 | if esc.nil? | |
283 | if prefix.nil? && sep == 'r' |
|
283 | if prefix.nil? && sep == 'r' | |
284 | if project && (changeset = project.changesets.find_by_revision(oid)) |
|
284 | if project && (changeset = project.changesets.find_by_revision(oid)) | |
285 | link = link_to("r#{oid}", {:controller => 'repositories', :action => 'revision', :id => project.id, :rev => oid}, :class => 'changeset', |
|
285 | link = link_to("r#{oid}", {:controller => 'repositories', :action => 'revision', :id => project.id, :rev => oid}, :class => 'changeset', | |
286 | :title => truncate(changeset.comments, 100)) |
|
286 | :title => truncate(changeset.comments, 100)) | |
287 | end |
|
287 | end | |
288 | elsif sep == '#' |
|
288 | elsif sep == '#' | |
289 | oid = oid.to_i |
|
289 | oid = oid.to_i | |
290 | case prefix |
|
290 | case prefix | |
291 | when nil |
|
291 | when nil | |
292 | if issue = Issue.find_by_id(oid, :include => [:project, :status], :conditions => Project.visible_by(User.current)) |
|
292 | if issue = Issue.find_by_id(oid, :include => [:project, :status], :conditions => Project.visible_by(User.current)) | |
293 | link = link_to("##{oid}", {:controller => 'issues', :action => 'show', :id => oid}, :class => 'issue', |
|
293 | link = link_to("##{oid}", {:controller => 'issues', :action => 'show', :id => oid}, :class => 'issue', | |
294 | :title => "#{truncate(issue.subject, 100)} (#{issue.status.name})") |
|
294 | :title => "#{truncate(issue.subject, 100)} (#{issue.status.name})") | |
295 | link = content_tag('del', link) if issue.closed? |
|
295 | link = content_tag('del', link) if issue.closed? | |
296 | end |
|
296 | end | |
297 | when 'document' |
|
297 | when 'document' | |
298 | if document = Document.find_by_id(oid, :include => [:project], :conditions => Project.visible_by(User.current)) |
|
298 | if document = Document.find_by_id(oid, :include => [:project], :conditions => Project.visible_by(User.current)) | |
299 | link = link_to h(document.title), {:controller => 'documents', :action => 'show', :id => document}, :class => 'document' |
|
299 | link = link_to h(document.title), {:controller => 'documents', :action => 'show', :id => document}, :class => 'document' | |
300 | end |
|
300 | end | |
301 | when 'version' |
|
301 | when 'version' | |
302 | if version = Version.find_by_id(oid, :include => [:project], :conditions => Project.visible_by(User.current)) |
|
302 | if version = Version.find_by_id(oid, :include => [:project], :conditions => Project.visible_by(User.current)) | |
303 | link = link_to h(version.name), {:controller => 'versions', :action => 'show', :id => version}, :class => 'version' |
|
303 | link = link_to h(version.name), {:controller => 'versions', :action => 'show', :id => version}, :class => 'version' | |
304 | end |
|
304 | end | |
305 | end |
|
305 | end | |
306 | elsif sep == ':' |
|
306 | elsif sep == ':' | |
307 | # removes the double quotes if any |
|
307 | # removes the double quotes if any | |
308 | name = oid.gsub(%r{^"(.*)"$}, "\\1") |
|
308 | name = oid.gsub(%r{^"(.*)"$}, "\\1") | |
309 | case prefix |
|
309 | case prefix | |
310 | when 'document' |
|
310 | when 'document' | |
311 | if project && document = project.documents.find_by_title(name) |
|
311 | if project && document = project.documents.find_by_title(name) | |
312 | link = link_to h(document.title), {:controller => 'documents', :action => 'show', :id => document}, :class => 'document' |
|
312 | link = link_to h(document.title), {:controller => 'documents', :action => 'show', :id => document}, :class => 'document' | |
313 | end |
|
313 | end | |
314 | when 'version' |
|
314 | when 'version' | |
315 | if project && version = project.versions.find_by_name(name) |
|
315 | if project && version = project.versions.find_by_name(name) | |
316 | link = link_to h(version.name), {:controller => 'versions', :action => 'show', :id => version}, :class => 'version' |
|
316 | link = link_to h(version.name), {:controller => 'versions', :action => 'show', :id => version}, :class => 'version' | |
317 | end |
|
317 | end | |
318 | when 'attachment' |
|
318 | when 'attachment' | |
319 | if attachments && attachment = attachments.detect {|a| a.filename == name } |
|
319 | if attachments && attachment = attachments.detect {|a| a.filename == name } | |
320 | link = link_to h(attachment.filename), {:controller => 'attachments', :action => 'download', :id => attachment}, :class => 'attachment' |
|
320 | link = link_to h(attachment.filename), {:controller => 'attachments', :action => 'download', :id => attachment}, :class => 'attachment' | |
321 | end |
|
321 | end | |
322 | end |
|
322 | end | |
323 | end |
|
323 | end | |
324 | end |
|
324 | end | |
325 | leading + (link || "#{prefix}#{sep}#{oid}") |
|
325 | leading + (link || "#{prefix}#{sep}#{oid}") | |
326 | end |
|
326 | end | |
327 |
|
327 | |||
328 | text |
|
328 | text | |
329 | end |
|
329 | end | |
330 |
|
330 | |||
331 | # Same as Rails' simple_format helper without using paragraphs |
|
331 | # Same as Rails' simple_format helper without using paragraphs | |
332 | def simple_format_without_paragraph(text) |
|
332 | def simple_format_without_paragraph(text) | |
333 | text.to_s. |
|
333 | text.to_s. | |
334 | gsub(/\r\n?/, "\n"). # \r\n and \r -> \n |
|
334 | gsub(/\r\n?/, "\n"). # \r\n and \r -> \n | |
335 | gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br |
|
335 | gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br | |
336 | gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br |
|
336 | gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br | |
337 | end |
|
337 | end | |
338 |
|
338 | |||
339 | def error_messages_for(object_name, options = {}) |
|
339 | def error_messages_for(object_name, options = {}) | |
340 | options = options.symbolize_keys |
|
340 | options = options.symbolize_keys | |
341 | object = instance_variable_get("@#{object_name}") |
|
341 | object = instance_variable_get("@#{object_name}") | |
342 | if object && !object.errors.empty? |
|
342 | if object && !object.errors.empty? | |
343 | # build full_messages here with controller current language |
|
343 | # build full_messages here with controller current language | |
344 | full_messages = [] |
|
344 | full_messages = [] | |
345 | object.errors.each do |attr, msg| |
|
345 | object.errors.each do |attr, msg| | |
346 | next if msg.nil? |
|
346 | next if msg.nil? | |
347 | msg = msg.first if msg.is_a? Array |
|
347 | msg = msg.first if msg.is_a? Array | |
348 | if attr == "base" |
|
348 | if attr == "base" | |
349 | full_messages << l(msg) |
|
349 | full_messages << l(msg) | |
350 | else |
|
350 | else | |
351 | full_messages << "« " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " » " + l(msg) unless attr == "custom_values" |
|
351 | full_messages << "« " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " » " + l(msg) unless attr == "custom_values" | |
352 | end |
|
352 | end | |
353 | end |
|
353 | end | |
354 | # retrieve custom values error messages |
|
354 | # retrieve custom values error messages | |
355 | if object.errors[:custom_values] |
|
355 | if object.errors[:custom_values] | |
356 | object.custom_values.each do |v| |
|
356 | object.custom_values.each do |v| | |
357 | v.errors.each do |attr, msg| |
|
357 | v.errors.each do |attr, msg| | |
358 | next if msg.nil? |
|
358 | next if msg.nil? | |
359 | msg = msg.first if msg.is_a? Array |
|
359 | msg = msg.first if msg.is_a? Array | |
360 | full_messages << "« " + v.custom_field.name + " » " + l(msg) |
|
360 | full_messages << "« " + v.custom_field.name + " » " + l(msg) | |
361 | end |
|
361 | end | |
362 | end |
|
362 | end | |
363 | end |
|
363 | end | |
364 | content_tag("div", |
|
364 | content_tag("div", | |
365 | content_tag( |
|
365 | content_tag( | |
366 | options[:header_tag] || "span", lwr(:gui_validation_error, full_messages.length) + ":" |
|
366 | options[:header_tag] || "span", lwr(:gui_validation_error, full_messages.length) + ":" | |
367 | ) + |
|
367 | ) + | |
368 | content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }), |
|
368 | content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }), | |
369 | "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation" |
|
369 | "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation" | |
370 | ) |
|
370 | ) | |
371 | else |
|
371 | else | |
372 | "" |
|
372 | "" | |
373 | end |
|
373 | end | |
374 | end |
|
374 | end | |
375 |
|
375 | |||
376 | def lang_options_for_select(blank=true) |
|
376 | def lang_options_for_select(blank=true) | |
377 | (blank ? [["(auto)", ""]] : []) + |
|
377 | (blank ? [["(auto)", ""]] : []) + | |
378 | GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last } |
|
378 | GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last } | |
379 | end |
|
379 | end | |
380 |
|
380 | |||
381 | def label_tag_for(name, option_tags = nil, options = {}) |
|
381 | def label_tag_for(name, option_tags = nil, options = {}) | |
382 | label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") |
|
382 | label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") | |
383 | content_tag("label", label_text) |
|
383 | content_tag("label", label_text) | |
384 | end |
|
384 | end | |
385 |
|
385 | |||
386 | def labelled_tabular_form_for(name, object, options, &proc) |
|
386 | def labelled_tabular_form_for(name, object, options, &proc) | |
387 | options[:html] ||= {} |
|
387 | options[:html] ||= {} | |
388 | options[:html].store :class, "tabular" |
|
388 | options[:html].store :class, "tabular" | |
389 | form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc) |
|
389 | form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc) | |
390 | end |
|
390 | end | |
391 |
|
391 | |||
392 | def check_all_links(form_name) |
|
392 | def check_all_links(form_name) | |
393 | link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") + |
|
393 | link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") + | |
394 | " | " + |
|
394 | " | " + | |
395 | link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)") |
|
395 | link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)") | |
396 | end |
|
396 | end | |
397 |
|
397 | |||
398 | def progress_bar(pcts, options={}) |
|
398 | def progress_bar(pcts, options={}) | |
399 | pcts = [pcts, pcts] unless pcts.is_a?(Array) |
|
399 | pcts = [pcts, pcts] unless pcts.is_a?(Array) | |
400 | pcts[1] = pcts[1] - pcts[0] |
|
400 | pcts[1] = pcts[1] - pcts[0] | |
401 | pcts << (100 - pcts[1] - pcts[0]) |
|
401 | pcts << (100 - pcts[1] - pcts[0]) | |
402 | width = options[:width] || '100px;' |
|
402 | width = options[:width] || '100px;' | |
403 | legend = options[:legend] || '' |
|
403 | legend = options[:legend] || '' | |
404 | content_tag('table', |
|
404 | content_tag('table', | |
405 | content_tag('tr', |
|
405 | content_tag('tr', | |
406 | (pcts[0] > 0 ? content_tag('td', '', :width => "#{pcts[0].floor}%;", :class => 'closed') : '') + |
|
406 | (pcts[0] > 0 ? content_tag('td', '', :width => "#{pcts[0].floor}%;", :class => 'closed') : '') + | |
407 | (pcts[1] > 0 ? content_tag('td', '', :width => "#{pcts[1].floor}%;", :class => 'done') : '') + |
|
407 | (pcts[1] > 0 ? content_tag('td', '', :width => "#{pcts[1].floor}%;", :class => 'done') : '') + | |
408 | (pcts[2] > 0 ? content_tag('td', '', :width => "#{pcts[2].floor}%;", :class => 'todo') : '') |
|
408 | (pcts[2] > 0 ? content_tag('td', '', :width => "#{pcts[2].floor}%;", :class => 'todo') : '') | |
409 | ), :class => 'progress', :style => "width: #{width};") + |
|
409 | ), :class => 'progress', :style => "width: #{width};") + | |
410 | content_tag('p', legend, :class => 'pourcent') |
|
410 | content_tag('p', legend, :class => 'pourcent') | |
411 | end |
|
411 | end | |
412 |
|
412 | |||
413 | def context_menu_link(name, url, options={}) |
|
413 | def context_menu_link(name, url, options={}) | |
414 | options[:class] ||= '' |
|
414 | options[:class] ||= '' | |
415 | if options.delete(:selected) |
|
415 | if options.delete(:selected) | |
416 | options[:class] << ' icon-checked disabled' |
|
416 | options[:class] << ' icon-checked disabled' | |
417 | options[:disabled] = true |
|
417 | options[:disabled] = true | |
418 | end |
|
418 | end | |
419 | if options.delete(:disabled) |
|
419 | if options.delete(:disabled) | |
420 | options.delete(:method) |
|
420 | options.delete(:method) | |
421 | options.delete(:confirm) |
|
421 | options.delete(:confirm) | |
422 | options.delete(:onclick) |
|
422 | options.delete(:onclick) | |
423 | options[:class] << ' disabled' |
|
423 | options[:class] << ' disabled' | |
424 | url = '#' |
|
424 | url = '#' | |
425 | end |
|
425 | end | |
426 | link_to name, url, options |
|
426 | link_to name, url, options | |
427 | end |
|
427 | end | |
428 |
|
428 | |||
429 | def calendar_for(field_id) |
|
429 | def calendar_for(field_id) | |
430 | image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) + |
|
430 | image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) + | |
431 | javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });") |
|
431 | javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });") | |
432 | end |
|
432 | end | |
433 |
|
433 | |||
434 | def wikitoolbar_for(field_id) |
|
434 | def wikitoolbar_for(field_id) | |
435 | return '' unless Setting.text_formatting == 'textile' |
|
435 | return '' unless Setting.text_formatting == 'textile' | |
436 | javascript_include_tag('jstoolbar/jstoolbar') + |
|
436 | javascript_include_tag('jstoolbar/jstoolbar') + | |
437 | javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language}") + |
|
437 | javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language}") + | |
438 | javascript_tag("var toolbar = new jsToolBar($('#{field_id}')); toolbar.draw();") |
|
438 | javascript_tag("var toolbar = new jsToolBar($('#{field_id}')); toolbar.draw();") | |
439 | end |
|
439 | end | |
440 |
|
440 | |||
441 | def content_for(name, content = nil, &block) |
|
441 | def content_for(name, content = nil, &block) | |
442 | @has_content ||= {} |
|
442 | @has_content ||= {} | |
443 | @has_content[name] = true |
|
443 | @has_content[name] = true | |
444 | super(name, content, &block) |
|
444 | super(name, content, &block) | |
445 | end |
|
445 | end | |
446 |
|
446 | |||
447 | def has_content?(name) |
|
447 | def has_content?(name) | |
448 | (@has_content && @has_content[name]) || false |
|
448 | (@has_content && @has_content[name]) || false | |
449 | end |
|
449 | end | |
450 | end |
|
450 | end |
@@ -1,39 +1,39 | |||||
1 | <% labelled_tabular_form_for :issue, @issue, |
|
1 | <% labelled_tabular_form_for :issue, @issue, | |
2 | :url => {:action => 'edit', :id => @issue}, |
|
2 | :url => {:action => 'edit', :id => @issue}, | |
3 | :html => {:id => 'issue-form', |
|
3 | :html => {:id => 'issue-form', | |
4 | :multipart => true} do |f| %> |
|
4 | :multipart => true} do |f| %> | |
5 | <%= error_messages_for 'issue' %> |
|
5 | <%= error_messages_for 'issue' %> | |
6 | <div class="box"> |
|
6 | <div class="box"> | |
7 | <% if @edit_allowed || !@allowed_statuses.empty? %> |
|
7 | <% if @edit_allowed || !@allowed_statuses.empty? %> | |
8 | <fieldset> |
|
8 | <fieldset> | |
9 | <legend><%= l(:label_change_properties) %> |
|
9 | <legend><%= l(:label_change_properties) %> | |
10 | <% if !@issue.new_record? && !@issue.errors.any? && @edit_allowed %> |
|
10 | <% if !@issue.new_record? && !@issue.errors.any? && @edit_allowed %> | |
11 | <small>(<%= link_to l(:label_more), {}, :onclick => 'Effect.toggle("issue_descr_fields", "appear", {duration:0.3}); return false;' %>)</small> |
|
11 | <small>(<%= link_to l(:label_more), {}, :onclick => 'Effect.toggle("issue_descr_fields", "appear", {duration:0.3}); return false;' %>)</small> | |
12 | <% end %> |
|
12 | <% end %> | |
13 | </legend> |
|
13 | </legend> | |
14 | <%= render :partial => (@edit_allowed ? 'form' : 'form_update'), :locals => {:f => f} %> |
|
14 | <%= render :partial => (@edit_allowed ? 'form' : 'form_update'), :locals => {:f => f} %> | |
15 | </fieldset> |
|
15 | </fieldset> | |
16 | <% end %> |
|
16 | <% end %> | |
17 |
|
17 | |||
18 | <fieldset><legend><%= l(:field_notes) %></legend> |
|
18 | <fieldset><legend><%= l(:field_notes) %></legend> | |
19 | <%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %> |
|
19 | <%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %> | |
20 | <%= wikitoolbar_for 'notes' %> |
|
20 | <%= wikitoolbar_for 'notes' %> | |
21 |
|
21 | |||
22 | <p id="attachments_p"><label><%=l(:label_attachment_new)%> |
|
22 | <p id="attachments_p"><label><%=l(:label_attachment_new)%> | |
23 | <%= image_to_function 'add.png', 'addFileField();return false;' %></label> |
|
23 | <%= image_to_function 'add.png', 'addFileField();return false;' %></label> | |
24 | <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p> |
|
24 | <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p> | |
25 | </fieldset> |
|
25 | </fieldset> | |
26 | </div> |
|
26 | </div> | |
27 |
|
27 | |||
28 | <%= f.hidden_field :lock_version %> |
|
28 | <%= f.hidden_field :lock_version %> | |
29 | <%= submit_tag l(:button_submit) %> |
|
29 | <%= submit_tag l(:button_submit) %> | |
30 | <%= link_to_remote l(:label_preview), |
|
30 | <%= link_to_remote l(:label_preview), | |
31 | { :url => { :controller => 'issues', :action => 'preview', :id => @issue }, |
|
31 | { :url => { :controller => 'issues', :action => 'preview', :id => @issue }, | |
32 | :method => 'post', |
|
32 | :method => 'post', | |
33 | :update => 'preview', |
|
33 | :update => 'preview', | |
34 | :with => 'Form.serialize("issue-form")', |
|
34 | :with => 'Form.serialize("issue-form")', | |
35 |
:complete => " |
|
35 | :complete => "Element.scrollTo('preview')" | |
36 | }, :accesskey => accesskey(:preview) %> |
|
36 | }, :accesskey => accesskey(:preview) %> | |
37 | <% end %> |
|
37 | <% end %> | |
38 |
|
38 | |||
39 | <div id="preview" class="wiki"></div> |
|
39 | <div id="preview" class="wiki"></div> |
@@ -1,20 +1,19 | |||||
1 | <h2><%=l(:label_issue_new)%></h2> |
|
1 | <h2><%=l(:label_issue_new)%></h2> | |
2 |
|
2 | |||
3 | <% labelled_tabular_form_for :issue, @issue, |
|
3 | <% labelled_tabular_form_for :issue, @issue, | |
4 | :html => {:multipart => true, :id => 'issue-form'} do |f| %> |
|
4 | :html => {:multipart => true, :id => 'issue-form'} do |f| %> | |
5 | <%= error_messages_for 'issue' %> |
|
5 | <%= error_messages_for 'issue' %> | |
6 | <div class="box"> |
|
6 | <div class="box"> | |
7 | <%= render :partial => 'issues/form', :locals => {:f => f} %> |
|
7 | <%= render :partial => 'issues/form', :locals => {:f => f} %> | |
8 | </div> |
|
8 | </div> | |
9 | <%= submit_tag l(:button_create) %> |
|
9 | <%= submit_tag l(:button_create) %> | |
10 | <%= link_to_remote l(:label_preview), |
|
10 | <%= link_to_remote l(:label_preview), | |
11 | { :url => { :controller => 'issues', :action => 'preview', :id => @issue }, |
|
11 | { :url => { :controller => 'issues', :action => 'preview', :id => @issue }, | |
12 | :method => 'post', |
|
12 | :method => 'post', | |
13 | :update => 'preview', |
|
13 | :update => 'preview', | |
14 | :with => "Form.serialize('issue-form')", |
|
14 | :with => "Form.serialize('issue-form')", | |
15 |
:complete => " |
|
15 | :complete => "Element.scrollTo('preview')" | |
16 | }, :accesskey => accesskey(:preview) %> |
|
16 | }, :accesskey => accesskey(:preview) %> | |
17 | <% end %> |
|
17 | <% end %> | |
18 |
|
18 | |||
19 | <a name="preview-top"></a> |
|
|||
20 | <div id="preview" class="wiki"></div> |
|
19 | <div id="preview" class="wiki"></div> |
@@ -1,108 +1,107 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= show_and_goto_link(l(:button_update), 'update', :class => 'icon icon-edit', :accesskey => accesskey(:edit)) if authorize_for('issues', 'edit') %> |
|
2 | <%= show_and_goto_link(l(:button_update), 'update', :class => 'icon icon-edit', :accesskey => accesskey(:edit)) if authorize_for('issues', 'edit') %> | |
3 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %> |
|
3 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %> | |
4 | <%= watcher_tag(@issue, User.current) %> |
|
4 | <%= watcher_tag(@issue, User.current) %> | |
5 | <%= link_to_if_authorized l(:button_copy), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue }, :class => 'icon icon-copy' %> |
|
5 | <%= link_to_if_authorized l(:button_copy), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue }, :class => 'icon icon-copy' %> | |
6 | <%= link_to_if_authorized l(:button_move), {:controller => 'issues', :action => 'move', :id => @issue }, :class => 'icon icon-move' %> |
|
6 | <%= link_to_if_authorized l(:button_move), {:controller => 'issues', :action => 'move', :id => @issue }, :class => 'icon icon-move' %> | |
7 | <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> |
|
7 | <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> | |
8 | </div> |
|
8 | </div> | |
9 |
|
9 | |||
10 | <h2><%= @issue.tracker.name %> #<%= @issue.id %></h2> |
|
10 | <h2><%= @issue.tracker.name %> #<%= @issue.id %></h2> | |
11 |
|
11 | |||
12 | <div class="issue <%= "status-#{@issue.status.position} priority-#{@issue.priority.position}" %>"> |
|
12 | <div class="issue <%= "status-#{@issue.status.position} priority-#{@issue.priority.position}" %>"> | |
13 | <h3><%=h @issue.subject %></h3> |
|
13 | <h3><%=h @issue.subject %></h3> | |
14 | <p class="author"> |
|
14 | <p class="author"> | |
15 | <%= authoring @issue.created_on, @issue.author %>. |
|
15 | <%= authoring @issue.created_on, @issue.author %>. | |
16 | <%= l(:label_updated_time, distance_of_time_in_words(Time.now, @issue.updated_on)) if @issue.created_on != @issue.updated_on %>. |
|
16 | <%= l(:label_updated_time, distance_of_time_in_words(Time.now, @issue.updated_on)) if @issue.created_on != @issue.updated_on %>. | |
17 | </p> |
|
17 | </p> | |
18 |
|
18 | |||
19 | <table width="100%"> |
|
19 | <table width="100%"> | |
20 | <tr> |
|
20 | <tr> | |
21 | <td style="width:15%"><b><%=l(:field_status)%> :</b></td><td style="width:35%"><%= @issue.status.name %></td> |
|
21 | <td style="width:15%"><b><%=l(:field_status)%> :</b></td><td style="width:35%"><%= @issue.status.name %></td> | |
22 | <td style="width:15%"><b><%=l(:field_start_date)%> :</b></td><td style="width:35%"><%= format_date(@issue.start_date) %></td> |
|
22 | <td style="width:15%"><b><%=l(:field_start_date)%> :</b></td><td style="width:35%"><%= format_date(@issue.start_date) %></td> | |
23 | </tr> |
|
23 | </tr> | |
24 | <tr> |
|
24 | <tr> | |
25 | <td><b><%=l(:field_priority)%> :</b></td><td><%= @issue.priority.name %></td> |
|
25 | <td><b><%=l(:field_priority)%> :</b></td><td><%= @issue.priority.name %></td> | |
26 | <td><b><%=l(:field_due_date)%> :</b></td><td><%= format_date(@issue.due_date) %></td> |
|
26 | <td><b><%=l(:field_due_date)%> :</b></td><td><%= format_date(@issue.due_date) %></td> | |
27 | </tr> |
|
27 | </tr> | |
28 | <tr> |
|
28 | <tr> | |
29 | <td><b><%=l(:field_assigned_to)%> :</b></td><td><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td> |
|
29 | <td><b><%=l(:field_assigned_to)%> :</b></td><td><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td> | |
30 | <td><b><%=l(:field_done_ratio)%> :</b></td><td><%= progress_bar @issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%" %></td> |
|
30 | <td><b><%=l(:field_done_ratio)%> :</b></td><td><%= progress_bar @issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%" %></td> | |
31 | </tr> |
|
31 | </tr> | |
32 | <tr> |
|
32 | <tr> | |
33 | <td><b><%=l(:field_category)%> :</b></td><td><%=h @issue.category ? @issue.category.name : "-" %></td> |
|
33 | <td><b><%=l(:field_category)%> :</b></td><td><%=h @issue.category ? @issue.category.name : "-" %></td> | |
34 | <% if User.current.allowed_to?(:view_time_entries, @project) %> |
|
34 | <% if User.current.allowed_to?(:view_time_entries, @project) %> | |
35 | <td><b><%=l(:label_spent_time)%> :</b></td> |
|
35 | <td><b><%=l(:label_spent_time)%> :</b></td> | |
36 | <td><%= @issue.spent_hours > 0 ? (link_to lwr(:label_f_hour, @issue.spent_hours), {:controller => 'timelog', :action => 'details', :issue_id => @issue}, :class => 'icon icon-time') : "-" %></td> |
|
36 | <td><%= @issue.spent_hours > 0 ? (link_to lwr(:label_f_hour, @issue.spent_hours), {:controller => 'timelog', :action => 'details', :issue_id => @issue}, :class => 'icon icon-time') : "-" %></td> | |
37 | <% end %> |
|
37 | <% end %> | |
38 | </tr> |
|
38 | </tr> | |
39 | <tr> |
|
39 | <tr> | |
40 | <td><b><%=l(:field_fixed_version)%> :</b></td><td><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td> |
|
40 | <td><b><%=l(:field_fixed_version)%> :</b></td><td><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td> | |
41 | <% if @issue.estimated_hours %> |
|
41 | <% if @issue.estimated_hours %> | |
42 | <td><b><%=l(:field_estimated_hours)%> :</b></td><td><%= lwr(:label_f_hour, @issue.estimated_hours) %></td> |
|
42 | <td><b><%=l(:field_estimated_hours)%> :</b></td><td><%= lwr(:label_f_hour, @issue.estimated_hours) %></td> | |
43 | <% end %> |
|
43 | <% end %> | |
44 | </tr> |
|
44 | </tr> | |
45 | <tr> |
|
45 | <tr> | |
46 | <% n = 0 |
|
46 | <% n = 0 | |
47 | for custom_value in @custom_values %> |
|
47 | for custom_value in @custom_values %> | |
48 | <td valign="top"><b><%= custom_value.custom_field.name %> :</b></td><td valign="top"><%= simple_format(h(show_value(custom_value))) %></td> |
|
48 | <td valign="top"><b><%= custom_value.custom_field.name %> :</b></td><td valign="top"><%= simple_format(h(show_value(custom_value))) %></td> | |
49 | <% n = n + 1 |
|
49 | <% n = n + 1 | |
50 | if (n > 1) |
|
50 | if (n > 1) | |
51 | n = 0 %> |
|
51 | n = 0 %> | |
52 | </tr><tr> |
|
52 | </tr><tr> | |
53 | <%end |
|
53 | <%end | |
54 | end %> |
|
54 | end %> | |
55 | </tr> |
|
55 | </tr> | |
56 | </table> |
|
56 | </table> | |
57 | <hr /> |
|
57 | <hr /> | |
58 |
|
58 | |||
59 | <p><strong><%=l(:field_description)%></strong></p> |
|
59 | <p><strong><%=l(:field_description)%></strong></p> | |
60 | <div class="wiki"> |
|
60 | <div class="wiki"> | |
61 | <%= textilizable @issue, :description, :attachments => @issue.attachments %> |
|
61 | <%= textilizable @issue, :description, :attachments => @issue.attachments %> | |
62 | </div> |
|
62 | </div> | |
63 |
|
63 | |||
64 | <% if @issue.attachments.any? %> |
|
64 | <% if @issue.attachments.any? %> | |
65 | <%= link_to_attachments @issue.attachments, :delete_url => (authorize_for('issues', 'destroy_attachment') ? {:controller => 'issues', :action => 'destroy_attachment', :id => @issue} : nil) %> |
|
65 | <%= link_to_attachments @issue.attachments, :delete_url => (authorize_for('issues', 'destroy_attachment') ? {:controller => 'issues', :action => 'destroy_attachment', :id => @issue} : nil) %> | |
66 | <% end %> |
|
66 | <% end %> | |
67 |
|
67 | |||
68 | <% if authorize_for('issue_relations', 'new') || @issue.relations.any? %> |
|
68 | <% if authorize_for('issue_relations', 'new') || @issue.relations.any? %> | |
69 | <hr /> |
|
69 | <hr /> | |
70 | <div id="relations"> |
|
70 | <div id="relations"> | |
71 | <%= render :partial => 'relations' %> |
|
71 | <%= render :partial => 'relations' %> | |
72 | </div> |
|
72 | </div> | |
73 | <% end %> |
|
73 | <% end %> | |
74 |
|
74 | |||
75 | </div> |
|
75 | </div> | |
76 |
|
76 | |||
77 | <% if @issue.changesets.any? && User.current.allowed_to?(:view_changesets, @project) %> |
|
77 | <% if @issue.changesets.any? && User.current.allowed_to?(:view_changesets, @project) %> | |
78 | <div id="issue-changesets"> |
|
78 | <div id="issue-changesets"> | |
79 | <h3><%=l(:label_associated_revisions)%></h3> |
|
79 | <h3><%=l(:label_associated_revisions)%></h3> | |
80 | <%= render :partial => 'changesets', :locals => { :changesets => @issue.changesets} %> |
|
80 | <%= render :partial => 'changesets', :locals => { :changesets => @issue.changesets} %> | |
81 | </div> |
|
81 | </div> | |
82 | <% end %> |
|
82 | <% end %> | |
83 |
|
83 | |||
84 | <% if @journals.any? %> |
|
84 | <% if @journals.any? %> | |
85 | <div id="history"> |
|
85 | <div id="history"> | |
86 | <h3><%=l(:label_history)%></h3> |
|
86 | <h3><%=l(:label_history)%></h3> | |
87 | <%= render :partial => 'history', :locals => { :journals => @journals } %> |
|
87 | <%= render :partial => 'history', :locals => { :journals => @journals } %> | |
88 | </div> |
|
88 | </div> | |
89 | <% end %> |
|
89 | <% end %> | |
90 |
|
90 | |||
91 | <% if authorize_for('issues', 'edit') %> |
|
91 | <% if authorize_for('issues', 'edit') %> | |
92 | <a name="update-anchor"></a> |
|
|||
93 | <div id="update" style="display:none;"> |
|
92 | <div id="update" style="display:none;"> | |
94 | <h3><%= l(:button_update) %></h3> |
|
93 | <h3><%= l(:button_update) %></h3> | |
95 | <%= render :partial => 'edit' %> |
|
94 | <%= render :partial => 'edit' %> | |
96 | </div> |
|
95 | </div> | |
97 | <% end %> |
|
96 | <% end %> | |
98 |
|
97 | |||
99 | <div class="contextual"> |
|
98 | <div class="contextual"> | |
100 | <%= l(:label_export_to) %><%= link_to 'PDF', {:format => 'pdf'}, :class => 'icon icon-pdf' %> |
|
99 | <%= l(:label_export_to) %><%= link_to 'PDF', {:format => 'pdf'}, :class => 'icon icon-pdf' %> | |
101 | </div> |
|
100 | </div> | |
102 | |
|
101 | | |
103 |
|
102 | |||
104 | <% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %> |
|
103 | <% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %> | |
105 |
|
104 | |||
106 | <% content_for :sidebar do %> |
|
105 | <% content_for :sidebar do %> | |
107 | <%= render :partial => 'issues/sidebar' %> |
|
106 | <%= render :partial => 'issues/sidebar' %> | |
108 | <% end %> |
|
107 | <% end %> |
@@ -1,31 +1,30 | |||||
1 | <h2><%= @page.pretty_title %></h2> |
|
1 | <h2><%= @page.pretty_title %></h2> | |
2 |
|
2 | |||
3 | <% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %> |
|
3 | <% form_for :content, @content, :url => {:action => 'edit', :page => @page.title}, :html => {:id => 'wiki_form'} do |f| %> | |
4 | <%= f.hidden_field :version %> |
|
4 | <%= f.hidden_field :version %> | |
5 | <%= error_messages_for 'content' %> |
|
5 | <%= error_messages_for 'content' %> | |
6 | <div class="contextual"> |
|
6 | <div class="contextual"> | |
7 | <%= l(:setting_text_formatting) %>: |
|
7 | <%= l(:setting_text_formatting) %>: | |
8 | <%= link_to l(:label_help), compute_public_path('wiki_syntax', 'help', 'html'), |
|
8 | <%= link_to l(:label_help), compute_public_path('wiki_syntax', 'help', 'html'), | |
9 | :onclick => "window.open('#{ compute_public_path('wiki_syntax', 'help', 'html') }', '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes'); return false;" %> |
|
9 | :onclick => "window.open('#{ compute_public_path('wiki_syntax', 'help', 'html') }', '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes'); return false;" %> | |
10 | </div> |
|
10 | </div> | |
11 | <p><%= f.text_area :text, :cols => 100, :rows => 25, :class => 'wiki-edit', :accesskey => accesskey(:edit) %></p> |
|
11 | <p><%= f.text_area :text, :cols => 100, :rows => 25, :class => 'wiki-edit', :accesskey => accesskey(:edit) %></p> | |
12 | <p><label><%= l(:field_comments) %></label><br /><%= f.text_field :comments, :size => 120 %></p> |
|
12 | <p><label><%= l(:field_comments) %></label><br /><%= f.text_field :comments, :size => 120 %></p> | |
13 | <p><%= submit_tag l(:button_save) %> |
|
13 | <p><%= submit_tag l(:button_save) %> | |
14 | <%= link_to_remote l(:label_preview), |
|
14 | <%= link_to_remote l(:label_preview), | |
15 | { :url => { :controller => 'wiki', :action => 'preview', :id => @project, :page => @page.title }, |
|
15 | { :url => { :controller => 'wiki', :action => 'preview', :id => @project, :page => @page.title }, | |
16 | :method => 'post', |
|
16 | :method => 'post', | |
17 | :update => 'preview', |
|
17 | :update => 'preview', | |
18 | :with => "Form.serialize('wiki_form')", |
|
18 | :with => "Form.serialize('wiki_form')", | |
19 |
:complete => " |
|
19 | :complete => "Element.scrollTo('preview')" | |
20 | }, :accesskey => accesskey(:preview) %></p> |
|
20 | }, :accesskey => accesskey(:preview) %></p> | |
21 | <%= wikitoolbar_for 'content_text' %> |
|
21 | <%= wikitoolbar_for 'content_text' %> | |
22 | <% end %> |
|
22 | <% end %> | |
23 |
|
23 | |||
24 | <a name="preview-top"></a> |
|
|||
25 | <div id="preview" class="wiki"></div> |
|
24 | <div id="preview" class="wiki"></div> | |
26 |
|
25 | |||
27 | <% content_for :header_tags do %> |
|
26 | <% content_for :header_tags do %> | |
28 | <%= stylesheet_link_tag 'scm' %> |
|
27 | <%= stylesheet_link_tag 'scm' %> | |
29 | <% end %> |
|
28 | <% end %> | |
30 |
|
29 | |||
31 | <% html_title @page.pretty_title %> |
|
30 | <% html_title @page.pretty_title %> |
General Comments 0
You need to be logged in to leave comments.
Login now