@@ -1,234 +1,241 | |||||
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 |
|
19 | |||
20 | # Return current logged in user or nil |
|
20 | # Return current logged in user or nil | |
21 | def loggedin? |
|
21 | def loggedin? | |
22 | @logged_in_user |
|
22 | @logged_in_user | |
23 | end |
|
23 | end | |
24 |
|
24 | |||
25 | # Return true if user is logged in and is admin, otherwise false |
|
25 | # Return true if user is logged in and is admin, otherwise false | |
26 | def admin_loggedin? |
|
26 | def admin_loggedin? | |
27 | @logged_in_user and @logged_in_user.admin? |
|
27 | @logged_in_user and @logged_in_user.admin? | |
28 | end |
|
28 | end | |
29 |
|
29 | |||
30 | # Return true if user is authorized for controller/action, otherwise false |
|
30 | # Return true if user is authorized for controller/action, otherwise false | |
31 | def authorize_for(controller, action) |
|
31 | def authorize_for(controller, action) | |
32 | # check if action is allowed on public projects |
|
32 | # check if action is allowed on public projects | |
33 | if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ controller, action ] |
|
33 | if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ controller, action ] | |
34 | return true |
|
34 | return true | |
35 | end |
|
35 | end | |
36 | # check if user is authorized |
|
36 | # check if user is authorized | |
37 | if @logged_in_user and (@logged_in_user.admin? or Permission.allowed_to_role( "%s/%s" % [ controller, action ], @logged_in_user.role_for_project(@project) ) ) |
|
37 | if @logged_in_user and (@logged_in_user.admin? or Permission.allowed_to_role( "%s/%s" % [ controller, action ], @logged_in_user.role_for_project(@project) ) ) | |
38 | return true |
|
38 | return true | |
39 | end |
|
39 | end | |
40 | return false |
|
40 | return false | |
41 | end |
|
41 | end | |
42 |
|
42 | |||
43 | # Display a link if user is authorized |
|
43 | # Display a link if user is authorized | |
44 | def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference) |
|
44 | def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference) | |
45 | link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller], options[:action]) |
|
45 | link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller], options[:action]) | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | # Display a link to user's account page |
|
48 | # Display a link to user's account page | |
49 | def link_to_user(user) |
|
49 | def link_to_user(user) | |
50 | link_to user.display_name, :controller => 'account', :action => 'show', :id => user |
|
50 | link_to user.display_name, :controller => 'account', :action => 'show', :id => user | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | def link_to_issue(issue) |
|
53 | def link_to_issue(issue) | |
54 | link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue |
|
54 | link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
|
57 | def toggle_link(name, id, options={}) | |||
|
58 | onclick = "Element.toggle('#{id}'); " | |||
|
59 | onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ") | |||
|
60 | onclick << "return false;" | |||
|
61 | link_to(name, "#", :onclick => onclick) | |||
|
62 | end | |||
|
63 | ||||
57 | def image_to_function(name, function, html_options = {}) |
|
64 | def image_to_function(name, function, html_options = {}) | |
58 | html_options.symbolize_keys! |
|
65 | html_options.symbolize_keys! | |
59 | tag(:input, html_options.merge({ |
|
66 | tag(:input, html_options.merge({ | |
60 | :type => "image", :src => image_path(name), |
|
67 | :type => "image", :src => image_path(name), | |
61 | :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};" |
|
68 | :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};" | |
62 | })) |
|
69 | })) | |
63 | end |
|
70 | end | |
64 |
|
71 | |||
65 | def format_date(date) |
|
72 | def format_date(date) | |
66 | l_date(date) if date |
|
73 | l_date(date) if date | |
67 | end |
|
74 | end | |
68 |
|
75 | |||
69 | def format_time(time) |
|
76 | def format_time(time) | |
70 | l_datetime((time.is_a? String) ? time.to_time : time) if time |
|
77 | l_datetime((time.is_a? String) ? time.to_time : time) if time | |
71 | end |
|
78 | end | |
72 |
|
79 | |||
73 | def day_name(day) |
|
80 | def day_name(day) | |
74 | l(:general_day_names).split(',')[day-1] |
|
81 | l(:general_day_names).split(',')[day-1] | |
75 | end |
|
82 | end | |
76 |
|
83 | |||
77 | def month_name(month) |
|
84 | def month_name(month) | |
78 | l(:actionview_datehelper_select_month_names).split(',')[month-1] |
|
85 | l(:actionview_datehelper_select_month_names).split(',')[month-1] | |
79 | end |
|
86 | end | |
80 |
|
87 | |||
81 | def pagination_links_full(paginator, options={}, html_options={}) |
|
88 | def pagination_links_full(paginator, options={}, html_options={}) | |
82 | html = '' |
|
89 | html = '' | |
83 | html << link_to_remote(('« ' + l(:label_previous)), |
|
90 | html << link_to_remote(('« ' + l(:label_previous)), | |
84 | {:update => "content", :url => options.merge(:page => paginator.current.previous)}, |
|
91 | {:update => "content", :url => options.merge(:page => paginator.current.previous)}, | |
85 | {:href => url_for(:params => options.merge(:page => paginator.current.previous))}) + ' ' if paginator.current.previous |
|
92 | {:href => url_for(:params => options.merge(:page => paginator.current.previous))}) + ' ' if paginator.current.previous | |
86 |
|
93 | |||
87 | html << (pagination_links_each(paginator, options) do |n| |
|
94 | html << (pagination_links_each(paginator, options) do |n| | |
88 | link_to_remote(n.to_s, |
|
95 | link_to_remote(n.to_s, | |
89 | {:url => {:action => 'list', :params => options.merge(:page => n)}, :update => 'content'}, |
|
96 | {:url => {:action => 'list', :params => options.merge(:page => n)}, :update => 'content'}, | |
90 | {:href => url_for(:params => options.merge(:page => n))}) |
|
97 | {:href => url_for(:params => options.merge(:page => n))}) | |
91 | end || '') |
|
98 | end || '') | |
92 |
|
99 | |||
93 | html << ' ' + link_to_remote((l(:label_next) + ' »'), |
|
100 | html << ' ' + link_to_remote((l(:label_next) + ' »'), | |
94 | {:update => "content", :url => options.merge(:page => paginator.current.next)}, |
|
101 | {:update => "content", :url => options.merge(:page => paginator.current.next)}, | |
95 | {:href => url_for(:params => options.merge(:page => paginator.current.next))}) if paginator.current.next |
|
102 | {:href => url_for(:params => options.merge(:page => paginator.current.next))}) if paginator.current.next | |
96 | html |
|
103 | html | |
97 | end |
|
104 | end | |
98 |
|
105 | |||
99 | # textilize text according to system settings and RedCloth availability |
|
106 | # textilize text according to system settings and RedCloth availability | |
100 | def textilizable(text, options = {}) |
|
107 | def textilizable(text, options = {}) | |
101 | # different methods for formatting wiki links |
|
108 | # different methods for formatting wiki links | |
102 | case options[:wiki_links] |
|
109 | case options[:wiki_links] | |
103 | when :local |
|
110 | when :local | |
104 | # used for local links to html files |
|
111 | # used for local links to html files | |
105 | format_wiki_link = Proc.new {|title| "#{title}.html" } |
|
112 | format_wiki_link = Proc.new {|title| "#{title}.html" } | |
106 | when :anchor |
|
113 | when :anchor | |
107 | # used for single-file wiki export |
|
114 | # used for single-file wiki export | |
108 | format_wiki_link = Proc.new {|title| "##{title}" } |
|
115 | format_wiki_link = Proc.new {|title| "##{title}" } | |
109 | else |
|
116 | else | |
110 | if @project |
|
117 | if @project | |
111 | format_wiki_link = Proc.new {|title| url_for :controller => 'wiki', :action => 'index', :id => @project, :page => title } |
|
118 | format_wiki_link = Proc.new {|title| url_for :controller => 'wiki', :action => 'index', :id => @project, :page => title } | |
112 | else |
|
119 | else | |
113 | format_wiki_link = Proc.new {|title| title } |
|
120 | format_wiki_link = Proc.new {|title| title } | |
114 | end |
|
121 | end | |
115 | end |
|
122 | end | |
116 |
|
123 | |||
117 | # turn wiki links into textile links: |
|
124 | # turn wiki links into textile links: | |
118 | # example: |
|
125 | # example: | |
119 | # [[link]] -> "link":link |
|
126 | # [[link]] -> "link":link | |
120 | # [[link|title]] -> "title":link |
|
127 | # [[link|title]] -> "title":link | |
121 | text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + format_wiki_link.call(Wiki.titleize($1)) } |
|
128 | text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + format_wiki_link.call(Wiki.titleize($1)) } | |
122 |
|
129 | |||
123 | # turn issue ids to textile links |
|
130 | # turn issue ids to textile links | |
124 | # example: |
|
131 | # example: | |
125 | # #52 -> "#52":/issues/show/52 |
|
132 | # #52 -> "#52":/issues/show/52 | |
126 | text = text.gsub(/#(\d+)(?=\b)/) {|m| "\"##{$1}\":" + url_for(:controller => 'issues', :action => 'show', :id => $1) } |
|
133 | text = text.gsub(/#(\d+)(?=\b)/) {|m| "\"##{$1}\":" + url_for(:controller => 'issues', :action => 'show', :id => $1) } | |
127 |
|
134 | |||
128 | # turn revision ids to textile links (@project needed) |
|
135 | # turn revision ids to textile links (@project needed) | |
129 | # example: |
|
136 | # example: | |
130 | # r52 -> "r52":/repositories/revision/6?rev=52 (@project.id is 6) |
|
137 | # r52 -> "r52":/repositories/revision/6?rev=52 (@project.id is 6) | |
131 | text = text.gsub(/r(\d+)(?=\b)/) {|m| "\"r#{$1}\":" + url_for(:controller => 'repositories', :action => 'revision', :id => @project.id, :rev => $1) } if @project |
|
138 | text = text.gsub(/r(\d+)(?=\b)/) {|m| "\"r#{$1}\":" + url_for(:controller => 'repositories', :action => 'revision', :id => @project.id, :rev => $1) } if @project | |
132 |
|
139 | |||
133 | # finally textilize text |
|
140 | # finally textilize text | |
134 | @do_textilize ||= (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") |
|
141 | @do_textilize ||= (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") | |
135 | text = @do_textilize ? auto_link(RedCloth.new(text).to_html) : simple_format(auto_link(h(text))) |
|
142 | text = @do_textilize ? auto_link(RedCloth.new(text).to_html) : simple_format(auto_link(h(text))) | |
136 | end |
|
143 | end | |
137 |
|
144 | |||
138 | def error_messages_for(object_name, options = {}) |
|
145 | def error_messages_for(object_name, options = {}) | |
139 | options = options.symbolize_keys |
|
146 | options = options.symbolize_keys | |
140 | object = instance_variable_get("@#{object_name}") |
|
147 | object = instance_variable_get("@#{object_name}") | |
141 | if object && !object.errors.empty? |
|
148 | if object && !object.errors.empty? | |
142 | # build full_messages here with controller current language |
|
149 | # build full_messages here with controller current language | |
143 | full_messages = [] |
|
150 | full_messages = [] | |
144 | object.errors.each do |attr, msg| |
|
151 | object.errors.each do |attr, msg| | |
145 | next if msg.nil? |
|
152 | next if msg.nil? | |
146 | msg = msg.first if msg.is_a? Array |
|
153 | msg = msg.first if msg.is_a? Array | |
147 | if attr == "base" |
|
154 | if attr == "base" | |
148 | full_messages << l(msg) |
|
155 | full_messages << l(msg) | |
149 | else |
|
156 | else | |
150 | full_messages << "« " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " » " + l(msg) unless attr == "custom_values" |
|
157 | full_messages << "« " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " » " + l(msg) unless attr == "custom_values" | |
151 | end |
|
158 | end | |
152 | end |
|
159 | end | |
153 | # retrieve custom values error messages |
|
160 | # retrieve custom values error messages | |
154 | if object.errors[:custom_values] |
|
161 | if object.errors[:custom_values] | |
155 | object.custom_values.each do |v| |
|
162 | object.custom_values.each do |v| | |
156 | v.errors.each do |attr, msg| |
|
163 | v.errors.each do |attr, msg| | |
157 | next if msg.nil? |
|
164 | next if msg.nil? | |
158 | msg = msg.first if msg.is_a? Array |
|
165 | msg = msg.first if msg.is_a? Array | |
159 | full_messages << "« " + v.custom_field.name + " » " + l(msg) |
|
166 | full_messages << "« " + v.custom_field.name + " » " + l(msg) | |
160 | end |
|
167 | end | |
161 | end |
|
168 | end | |
162 | end |
|
169 | end | |
163 | content_tag("div", |
|
170 | content_tag("div", | |
164 | content_tag( |
|
171 | content_tag( | |
165 | options[:header_tag] || "h2", lwr(:gui_validation_error, full_messages.length) + " :" |
|
172 | options[:header_tag] || "h2", lwr(:gui_validation_error, full_messages.length) + " :" | |
166 | ) + |
|
173 | ) + | |
167 | content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }), |
|
174 | content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }), | |
168 | "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation" |
|
175 | "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation" | |
169 | ) |
|
176 | ) | |
170 | else |
|
177 | else | |
171 | "" |
|
178 | "" | |
172 | end |
|
179 | end | |
173 | end |
|
180 | end | |
174 |
|
181 | |||
175 | def lang_options_for_select(blank=true) |
|
182 | def lang_options_for_select(blank=true) | |
176 | (blank ? [["(auto)", ""]] : []) + |
|
183 | (blank ? [["(auto)", ""]] : []) + | |
177 | (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]} |
|
184 | (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]} | |
178 | end |
|
185 | end | |
179 |
|
186 | |||
180 | def label_tag_for(name, option_tags = nil, options = {}) |
|
187 | def label_tag_for(name, option_tags = nil, options = {}) | |
181 | label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") |
|
188 | label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") | |
182 | content_tag("label", label_text) |
|
189 | content_tag("label", label_text) | |
183 | end |
|
190 | end | |
184 |
|
191 | |||
185 | def labelled_tabular_form_for(name, object, options, &proc) |
|
192 | def labelled_tabular_form_for(name, object, options, &proc) | |
186 | options[:html] ||= {} |
|
193 | options[:html] ||= {} | |
187 | options[:html].store :class, "tabular" |
|
194 | options[:html].store :class, "tabular" | |
188 | form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc) |
|
195 | form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc) | |
189 | end |
|
196 | end | |
190 |
|
197 | |||
191 | def check_all_links(form_name) |
|
198 | def check_all_links(form_name) | |
192 | link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") + |
|
199 | link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") + | |
193 | " | " + |
|
200 | " | " + | |
194 | link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)") |
|
201 | link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)") | |
195 | end |
|
202 | end | |
196 |
|
203 | |||
197 | def calendar_for(field_id) |
|
204 | def calendar_for(field_id) | |
198 | image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) + |
|
205 | image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) + | |
199 | javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });") |
|
206 | javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });") | |
200 | end |
|
207 | end | |
201 | end |
|
208 | end | |
202 |
|
209 | |||
203 | class TabularFormBuilder < ActionView::Helpers::FormBuilder |
|
210 | class TabularFormBuilder < ActionView::Helpers::FormBuilder | |
204 | include GLoc |
|
211 | include GLoc | |
205 |
|
212 | |||
206 | def initialize(object_name, object, template, options, proc) |
|
213 | def initialize(object_name, object, template, options, proc) | |
207 | set_language_if_valid options.delete(:lang) |
|
214 | set_language_if_valid options.delete(:lang) | |
208 | @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc |
|
215 | @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc | |
209 | end |
|
216 | end | |
210 |
|
217 | |||
211 | (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector| |
|
218 | (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector| | |
212 | src = <<-END_SRC |
|
219 | src = <<-END_SRC | |
213 | def #{selector}(field, options = {}) |
|
220 | def #{selector}(field, options = {}) | |
214 | return super if options.delete :no_label |
|
221 | return super if options.delete :no_label | |
215 | label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") |
|
222 | label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") | |
216 | label = @template.content_tag("label", label_text, |
|
223 | label = @template.content_tag("label", label_text, | |
217 | :class => (@object && @object.errors[field] ? "error" : nil), |
|
224 | :class => (@object && @object.errors[field] ? "error" : nil), | |
218 | :for => (@object_name.to_s + "_" + field.to_s)) |
|
225 | :for => (@object_name.to_s + "_" + field.to_s)) | |
219 | label + super |
|
226 | label + super | |
220 | end |
|
227 | end | |
221 | END_SRC |
|
228 | END_SRC | |
222 | class_eval src, __FILE__, __LINE__ |
|
229 | class_eval src, __FILE__, __LINE__ | |
223 | end |
|
230 | end | |
224 |
|
231 | |||
225 | def select(field, choices, options = {}, html_options = {}) |
|
232 | def select(field, choices, options = {}, html_options = {}) | |
226 | label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") |
|
233 | label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "") | |
227 | label = @template.content_tag("label", label_text, |
|
234 | label = @template.content_tag("label", label_text, | |
228 | :class => (@object && @object.errors[field] ? "error" : nil), |
|
235 | :class => (@object && @object.errors[field] ? "error" : nil), | |
229 | :for => (@object_name.to_s + "_" + field.to_s)) |
|
236 | :for => (@object_name.to_s + "_" + field.to_s)) | |
230 | label + super |
|
237 | label + super | |
231 | end |
|
238 | end | |
232 |
|
239 | |||
233 | end |
|
240 | end | |
234 |
|
241 |
@@ -1,33 +1,32 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= link_to_if_authorized l(:button_edit), {:controller => 'news', :action => 'edit', :id => @news}, :class => 'icon icon-edit' %> |
|
2 | <%= link_to_if_authorized l(:button_edit), {:controller => 'news', :action => 'edit', :id => @news}, :class => 'icon icon-edit' %> | |
3 | <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy', :id => @news}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> |
|
3 | <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy', :id => @news}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> | |
4 | </div> |
|
4 | </div> | |
5 |
|
5 | |||
6 | <h2><%=h @news.title %></h2> |
|
6 | <h2><%=h @news.title %></h2> | |
7 |
|
7 | |||
8 | <p><em><% unless @news.summary.empty? %><%=h @news.summary %><br /><% end %> |
|
8 | <p><em><% unless @news.summary.empty? %><%=h @news.summary %><br /><% end %> | |
9 | <%= @news.author.display_name %>, <%= format_time(@news.created_on) %></em></p> |
|
9 | <%= @news.author.display_name %>, <%= format_time(@news.created_on) %></em></p> | |
10 | <br /> |
|
10 | <br /> | |
11 | <%= textilizable auto_link @news.description %> |
|
11 | <%= textilizable auto_link @news.description %> | |
12 | <br /> |
|
12 | <br /> | |
13 |
|
13 | |||
14 | <div id="comments" style="margin-bottom:16px;"> |
|
14 | <div id="comments" style="margin-bottom:16px;"> | |
15 | <h3 class="icon22 icon22-comment"><%= l(:label_comment_plural) %></h3> |
|
15 | <h3 class="icon22 icon22-comment"><%= l(:label_comment_plural) %></h3> | |
16 | <% @news.comments.each do |comment| %> |
|
16 | <% @news.comments.each do |comment| %> | |
17 | <% next if comment.new_record? %> |
|
17 | <% next if comment.new_record? %> | |
18 | <h4><%= format_time(comment.created_on) %> - <%= comment.author.name %></h4> |
|
18 | <h4><%= format_time(comment.created_on) %> - <%= comment.author.name %></h4> | |
19 | <div class="contextual"> |
|
19 | <div class="contextual"> | |
20 | <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy_comment', :id => @news, :comment_id => comment}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> |
|
20 | <%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy_comment', :id => @news, :comment_id => comment}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> | |
21 | </div> |
|
21 | </div> | |
22 | <%= simple_format(auto_link(h comment.comment))%> |
|
22 | <%= simple_format(auto_link(h comment.comment))%> | |
23 | <% end if @news.comments_count > 0 %> |
|
23 | <% end if @news.comments_count > 0 %> | |
24 | </div> |
|
24 | </div> | |
25 |
|
25 | |||
26 | <% if authorize_for 'news', 'add_comment' %> |
|
26 | <% if authorize_for 'news', 'add_comment' %> | |
27 | <% form_tag({:action => 'add_comment', :id => @news}) do %> |
|
27 | <p><%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comment" %></p> | |
28 | <%= error_messages_for 'comment' %> |
|
28 | <% form_tag({:action => 'add_comment', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %> | |
29 | <p><label for="comment_comment"><%= l(:label_comment_add) %></label><br /> |
|
29 | <%= text_area 'comment', 'comment', :cols => 60, :rows => 6 %> | |
30 | <%= text_area 'comment', 'comment', :cols => 60, :rows => 6 %></p> |
|
30 | <p><%= submit_tag l(:button_add) %></p> | |
31 | <%= submit_tag l(:button_add) %> |
|
|||
32 | <% end %> |
|
31 | <% end %> | |
33 | <% end %> No newline at end of file |
|
32 | <% end %> |
@@ -1,90 +1,90 | |||||
1 | <h2><%= l(:label_calendar) %></h2> |
|
1 | <h2><%= l(:label_calendar) %></h2> | |
2 |
|
2 | |||
3 | <% form_tag do %> |
|
3 | <% form_tag do %> | |
4 | <table width="100%"> |
|
4 | <table width="100%"> | |
5 | <tr> |
|
5 | <tr> | |
6 | <td align="left" style="width:15%"> |
|
6 | <td align="left" style="width:15%"> | |
7 | <%= link_to_remote ('« ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")), |
|
7 | <%= link_to_remote ('« ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")), | |
8 | {:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }}, |
|
8 | {:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }}, | |
9 | {:href => url_for(:action => 'calendar', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects])} |
|
9 | {:href => url_for(:action => 'calendar', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects])} | |
10 | %> |
|
10 | %> | |
11 | </td> |
|
11 | </td> | |
12 | <td align="center" style="width:55%"> |
|
12 | <td align="center" style="width:55%"> | |
13 | <%= select_month(@month, :prefix => "month", :discard_type => true) %> |
|
13 | <%= select_month(@month, :prefix => "month", :discard_type => true) %> | |
14 | <%= select_year(@year, :prefix => "year", :discard_type => true) %> |
|
14 | <%= select_year(@year, :prefix => "year", :discard_type => true) %> | |
15 | <%= submit_tag l(:button_submit), :class => "button-small" %> |
|
15 | <%= submit_tag l(:button_submit), :class => "button-small" %> | |
16 | </td> |
|
16 | </td> | |
17 | <td align="left" style="width:15%"> |
|
17 | <td align="left" style="width:15%"> | |
18 | <a href="#" onclick="Element.toggle('trackerselect')"><%= l(:label_options) %></a> |
|
18 | <%= toggle_link l(:label_options), "trackerselect" %> | |
19 | <div id="trackerselect" class="rightbox overlay" style="width:140px; display:none;"> |
|
19 | <div id="trackerselect" class="rightbox overlay" style="width:140px; display:none;"> | |
20 | <p><strong><%=l(:label_tracker_plural)%></strong></p> |
|
20 | <p><strong><%=l(:label_tracker_plural)%></strong></p> | |
21 | <% @trackers.each do |tracker| %> |
|
21 | <% @trackers.each do |tracker| %> | |
22 | <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> |
|
22 | <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> | |
23 | <%= tracker.name %><br /> |
|
23 | <%= tracker.name %><br /> | |
24 | <% end %> |
|
24 | <% end %> | |
25 | <% if @project.children.any? %> |
|
25 | <% if @project.children.any? %> | |
26 | <p><strong><%=l(:label_subproject_plural)%></strong></p> |
|
26 | <p><strong><%=l(:label_subproject_plural)%></strong></p> | |
27 | <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %> |
|
27 | <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %> | |
28 | <% end %> |
|
28 | <% end %> | |
29 | <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p> |
|
29 | <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p> | |
30 | </div> |
|
30 | </div> | |
31 | </td> |
|
31 | </td> | |
32 | <td align="right" style="width:15%"> |
|
32 | <td align="right" style="width:15%"> | |
33 | <%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'), |
|
33 | <%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'), | |
34 | {:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }}, |
|
34 | {:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }}, | |
35 | {:href => url_for(:action => 'calendar', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects])} |
|
35 | {:href => url_for(:action => 'calendar', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects])} | |
36 | %> |
|
36 | %> | |
37 | </td> |
|
37 | </td> | |
38 | </tr> |
|
38 | </tr> | |
39 | </table> |
|
39 | </table> | |
40 | <% end %> |
|
40 | <% end %> | |
41 |
|
41 | |||
42 | <table class="list with-cells"> |
|
42 | <table class="list with-cells"> | |
43 | <thead> |
|
43 | <thead> | |
44 | <tr> |
|
44 | <tr> | |
45 | <th></th> |
|
45 | <th></th> | |
46 | <% 1.upto(7) do |d| %> |
|
46 | <% 1.upto(7) do |d| %> | |
47 | <th style="width:14%"><%= day_name(d) %></th> |
|
47 | <th style="width:14%"><%= day_name(d) %></th> | |
48 | <% end %> |
|
48 | <% end %> | |
49 | </tr> |
|
49 | </tr> | |
50 | </thead> |
|
50 | </thead> | |
51 | <tbody> |
|
51 | <tbody> | |
52 | <tr style="height:100px"> |
|
52 | <tr style="height:100px"> | |
53 | <% day = @date_from |
|
53 | <% day = @date_from | |
54 | while day <= @date_to |
|
54 | while day <= @date_to | |
55 | if day.cwday == 1 %> |
|
55 | if day.cwday == 1 %> | |
56 | <th><%= day.cweek %></th> |
|
56 | <th><%= day.cweek %></th> | |
57 | <% end %> |
|
57 | <% end %> | |
58 | <td valign="top" class="<%= day.month==@month ? "even" : "odd" %>" style="width:14%; <%= Date.today == day ? 'background:#FDFED0;' : '' %>"> |
|
58 | <td valign="top" class="<%= day.month==@month ? "even" : "odd" %>" style="width:14%; <%= Date.today == day ? 'background:#FDFED0;' : '' %>"> | |
59 | <p class="textright"><%= day==Date.today ? "<b>#{day.day}</b>" : day.day %></p> |
|
59 | <p class="textright"><%= day==Date.today ? "<b>#{day.day}</b>" : day.day %></p> | |
60 | <% ((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq.each do |i| %> |
|
60 | <% ((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq.each do |i| %> | |
61 | <% if i.is_a? Issue %> |
|
61 | <% if i.is_a? Issue %> | |
62 | <div class="tooltip"> |
|
62 | <div class="tooltip"> | |
63 | <%= if day == i.start_date and day == i.due_date |
|
63 | <%= if day == i.start_date and day == i.due_date | |
64 | image_tag('arrow_bw.png') |
|
64 | image_tag('arrow_bw.png') | |
65 | elsif day == i.start_date |
|
65 | elsif day == i.start_date | |
66 | image_tag('arrow_from.png') |
|
66 | image_tag('arrow_from.png') | |
67 | elsif day == i.due_date |
|
67 | elsif day == i.due_date | |
68 | image_tag('arrow_to.png') |
|
68 | image_tag('arrow_to.png') | |
69 | end %> |
|
69 | end %> | |
70 | <small><%= link_to_issue i %>: <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small> |
|
70 | <small><%= link_to_issue i %>: <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small> | |
71 | <span class="tip"> |
|
71 | <span class="tip"> | |
72 | <%= render :partial => "issues/tooltip", :locals => { :issue => i }%> |
|
72 | <%= render :partial => "issues/tooltip", :locals => { :issue => i }%> | |
73 | </span> |
|
73 | </span> | |
74 | </div> |
|
74 | </div> | |
75 | <% else %> |
|
75 | <% else %> | |
76 | <%= image_tag('milestone.png') %> <small><%= "#{l(:label_version)}: #{i.name}" %></small> |
|
76 | <%= image_tag('milestone.png') %> <small><%= "#{l(:label_version)}: #{i.name}" %></small> | |
77 | <% end %> |
|
77 | <% end %> | |
78 | <% end %> |
|
78 | <% end %> | |
79 | </td> |
|
79 | </td> | |
80 | <%= '</tr><tr style="height:100px">' if day.cwday >= 7 and day!=@date_to %> |
|
80 | <%= '</tr><tr style="height:100px">' if day.cwday >= 7 and day!=@date_to %> | |
81 | <% |
|
81 | <% | |
82 | day = day + 1 |
|
82 | day = day + 1 | |
83 | end %> |
|
83 | end %> | |
84 | </tr> |
|
84 | </tr> | |
85 | </tbody> |
|
85 | </tbody> | |
86 | </table> |
|
86 | </table> | |
87 |
|
87 | |||
88 | <%= image_tag 'arrow_from.png' %> <%= l(:text_tip_task_begin_day) %><br /> |
|
88 | <%= image_tag 'arrow_from.png' %> <%= l(:text_tip_task_begin_day) %><br /> | |
89 | <%= image_tag 'arrow_to.png' %> <%= l(:text_tip_task_end_day) %><br /> |
|
89 | <%= image_tag 'arrow_to.png' %> <%= l(:text_tip_task_end_day) %><br /> | |
90 | <%= image_tag 'arrow_bw.png' %> <%= l(:text_tip_task_begin_end_day) %><br /> No newline at end of file |
|
90 | <%= image_tag 'arrow_bw.png' %> <%= l(:text_tip_task_begin_end_day) %><br /> |
@@ -1,239 +1,239 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= l(:label_export_to) %> |
|
2 | <%= l(:label_export_to) %> | |
3 | <%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :output => 'pdf'}, :class => 'icon icon-pdf' %> |
|
3 | <%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :output => 'pdf'}, :class => 'icon icon-pdf' %> | |
4 | </div> |
|
4 | </div> | |
5 |
|
5 | |||
6 | <h2><%= l(:label_gantt) %></h2> |
|
6 | <h2><%= l(:label_gantt) %></h2> | |
7 |
|
7 | |||
8 | <% form_tag do %> |
|
8 | <% form_tag do %> | |
9 | <table width="100%"> |
|
9 | <table width="100%"> | |
10 | <tr> |
|
10 | <tr> | |
11 | <td align="left"> |
|
11 | <td align="left"> | |
12 | <input type="text" name="months" size="2" value="<%= @months %>" /> |
|
12 | <input type="text" name="months" size="2" value="<%= @months %>" /> | |
13 | <%= l(:label_months_from) %> |
|
13 | <%= l(:label_months_from) %> | |
14 | <%= select_month(@month_from, :prefix => "month", :discard_type => true) %> |
|
14 | <%= select_month(@month_from, :prefix => "month", :discard_type => true) %> | |
15 | <%= select_year(@year_from, :prefix => "year", :discard_type => true) %> |
|
15 | <%= select_year(@year_from, :prefix => "year", :discard_type => true) %> | |
16 | <%= hidden_field_tag 'zoom', @zoom %> |
|
16 | <%= hidden_field_tag 'zoom', @zoom %> | |
17 | <%= submit_tag l(:button_submit), :class => "button-small" %> |
|
17 | <%= submit_tag l(:button_submit), :class => "button-small" %> | |
18 | </td> |
|
18 | </td> | |
19 | <td> |
|
19 | <td> | |
20 | <a href="#" onclick="Element.toggle('trackerselect')"><%= l(:label_options) %></a> |
|
20 | <%= toggle_link l(:label_options), "trackerselect" %> | |
21 | <div id="trackerselect" class="rightbox overlay" style="width:140px; display: none;"> |
|
21 | <div id="trackerselect" class="rightbox overlay" style="width:140px; display: none;"> | |
22 | <p><strong><%=l(:label_tracker_plural)%></strong></p> |
|
22 | <p><strong><%=l(:label_tracker_plural)%></strong></p> | |
23 | <% @trackers.each do |tracker| %> |
|
23 | <% @trackers.each do |tracker| %> | |
24 | <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> |
|
24 | <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> | |
25 | <%= tracker.name %><br /> |
|
25 | <%= tracker.name %><br /> | |
26 | <% end %> |
|
26 | <% end %> | |
27 | <% if @project.children.any? %> |
|
27 | <% if @project.children.any? %> | |
28 | <p><strong><%=l(:label_subproject_plural)%></strong></p> |
|
28 | <p><strong><%=l(:label_subproject_plural)%></strong></p> | |
29 | <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %> |
|
29 | <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %> | |
30 | <% end %> |
|
30 | <% end %> | |
31 | <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p> |
|
31 | <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p> | |
32 | </div> |
|
32 | </div> | |
33 | </td> |
|
33 | </td> | |
34 | <td align="right"> |
|
34 | <td align="right"> | |
35 | <%= if @zoom < 4 |
|
35 | <%= if @zoom < 4 | |
36 | link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]} |
|
36 | link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]} | |
37 | else |
|
37 | else | |
38 | image_tag 'zoom_in_g.png' |
|
38 | image_tag 'zoom_in_g.png' | |
39 | end %> |
|
39 | end %> | |
40 | <%= if @zoom > 1 |
|
40 | <%= if @zoom > 1 | |
41 | link_to image_tag('zoom_out.png'),{:zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]} |
|
41 | link_to image_tag('zoom_out.png'),{:zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]} | |
42 | else |
|
42 | else | |
43 | image_tag 'zoom_out_g.png' |
|
43 | image_tag 'zoom_out_g.png' | |
44 | end %> |
|
44 | end %> | |
45 | </td> |
|
45 | </td> | |
46 | </tr> |
|
46 | </tr> | |
47 | </table> |
|
47 | </table> | |
48 | <% end %> |
|
48 | <% end %> | |
49 |
|
49 | |||
50 | <% zoom = 1 |
|
50 | <% zoom = 1 | |
51 | @zoom.times { zoom = zoom * 2 } |
|
51 | @zoom.times { zoom = zoom * 2 } | |
52 |
|
52 | |||
53 | subject_width = 260 |
|
53 | subject_width = 260 | |
54 | header_heigth = 18 |
|
54 | header_heigth = 18 | |
55 |
|
55 | |||
56 | headers_height = header_heigth |
|
56 | headers_height = header_heigth | |
57 | show_weeks = false |
|
57 | show_weeks = false | |
58 | show_days = false |
|
58 | show_days = false | |
59 |
|
59 | |||
60 | if @zoom >1 |
|
60 | if @zoom >1 | |
61 | show_weeks = true |
|
61 | show_weeks = true | |
62 | headers_height = 2*header_heigth |
|
62 | headers_height = 2*header_heigth | |
63 | if @zoom > 2 |
|
63 | if @zoom > 2 | |
64 | show_days = true |
|
64 | show_days = true | |
65 | headers_height = 3*header_heigth |
|
65 | headers_height = 3*header_heigth | |
66 | end |
|
66 | end | |
67 | end |
|
67 | end | |
68 |
|
68 | |||
69 | g_width = (@date_to - @date_from + 1)*zoom |
|
69 | g_width = (@date_to - @date_from + 1)*zoom | |
70 | g_height = [(20 * @events.length + 6)+150, 206].max |
|
70 | g_height = [(20 * @events.length + 6)+150, 206].max | |
71 | t_height = g_height + headers_height |
|
71 | t_height = g_height + headers_height | |
72 | %> |
|
72 | %> | |
73 |
|
73 | |||
74 | <table width="100%" style="border:0; border-collapse: collapse;"> |
|
74 | <table width="100%" style="border:0; border-collapse: collapse;"> | |
75 | <tr> |
|
75 | <tr> | |
76 | <td style="width:260px;"> |
|
76 | <td style="width:260px;"> | |
77 |
|
77 | |||
78 | <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;"> |
|
78 | <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;"> | |
79 | <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div> |
|
79 | <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div> | |
80 | <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div> |
|
80 | <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div> | |
81 | <% |
|
81 | <% | |
82 | # |
|
82 | # | |
83 | # Tasks subjects |
|
83 | # Tasks subjects | |
84 | # |
|
84 | # | |
85 | top = headers_height + 8 |
|
85 | top = headers_height + 8 | |
86 | @events.each do |i| %> |
|
86 | @events.each do |i| %> | |
87 | <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small> |
|
87 | <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small> | |
88 | <% if i.is_a? Issue %> |
|
88 | <% if i.is_a? Issue %> | |
89 | <%= link_to_issue i %>: |
|
89 | <%= link_to_issue i %>: | |
90 | <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %> |
|
90 | <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %> | |
91 | <% else %> |
|
91 | <% else %> | |
92 | <strong><%= "#{l(:label_version)}: #{i.name}" %></strong> |
|
92 | <strong><%= "#{l(:label_version)}: #{i.name}" %></strong> | |
93 | <% end %> |
|
93 | <% end %> | |
94 | </small></div> |
|
94 | </small></div> | |
95 | <% top = top + 20 |
|
95 | <% top = top + 20 | |
96 | end %> |
|
96 | end %> | |
97 | </div> |
|
97 | </div> | |
98 | </td> |
|
98 | </td> | |
99 | <td> |
|
99 | <td> | |
100 |
|
100 | |||
101 | <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;"> |
|
101 | <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;"> | |
102 | <div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"> </div> |
|
102 | <div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"> </div> | |
103 | <% |
|
103 | <% | |
104 | # |
|
104 | # | |
105 | # Months headers |
|
105 | # Months headers | |
106 | # |
|
106 | # | |
107 | month_f = @date_from |
|
107 | month_f = @date_from | |
108 | left = 0 |
|
108 | left = 0 | |
109 | height = (show_weeks ? header_heigth : header_heigth + g_height) |
|
109 | height = (show_weeks ? header_heigth : header_heigth + g_height) | |
110 | @months.times do |
|
110 | @months.times do | |
111 | width = ((month_f >> 1) - month_f) * zoom - 1 |
|
111 | width = ((month_f >> 1) - month_f) * zoom - 1 | |
112 | %> |
|
112 | %> | |
113 | <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> |
|
113 | <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> | |
114 | <%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }, :title => "#{month_name(month_f.month)} #{month_f.year}"%> |
|
114 | <%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }, :title => "#{month_name(month_f.month)} #{month_f.year}"%> | |
115 | </div> |
|
115 | </div> | |
116 | <% |
|
116 | <% | |
117 | left = left + width + 1 |
|
117 | left = left + width + 1 | |
118 | month_f = month_f >> 1 |
|
118 | month_f = month_f >> 1 | |
119 | end %> |
|
119 | end %> | |
120 |
|
120 | |||
121 | <% |
|
121 | <% | |
122 | # |
|
122 | # | |
123 | # Weeks headers |
|
123 | # Weeks headers | |
124 | # |
|
124 | # | |
125 | if show_weeks |
|
125 | if show_weeks | |
126 | left = 0 |
|
126 | left = 0 | |
127 | height = (show_days ? header_heigth-1 : header_heigth-1 + g_height) |
|
127 | height = (show_days ? header_heigth-1 : header_heigth-1 + g_height) | |
128 | if @date_from.cwday == 1 |
|
128 | if @date_from.cwday == 1 | |
129 | # @date_from is monday |
|
129 | # @date_from is monday | |
130 | week_f = @date_from |
|
130 | week_f = @date_from | |
131 | else |
|
131 | else | |
132 | # find next monday after @date_from |
|
132 | # find next monday after @date_from | |
133 | week_f = @date_from + (7 - @date_from.cwday + 1) |
|
133 | week_f = @date_from + (7 - @date_from.cwday + 1) | |
134 | width = (7 - @date_from.cwday + 1) * zoom-1 |
|
134 | width = (7 - @date_from.cwday + 1) * zoom-1 | |
135 | %> |
|
135 | %> | |
136 | <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> </div> |
|
136 | <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> </div> | |
137 | <% |
|
137 | <% | |
138 | left = left + width+1 |
|
138 | left = left + width+1 | |
139 | end %> |
|
139 | end %> | |
140 | <% |
|
140 | <% | |
141 | while week_f <= @date_to |
|
141 | while week_f <= @date_to | |
142 | width = (week_f + 6 <= @date_to) ? 7 * zoom -1 : (@date_to - week_f + 1) * zoom-1 |
|
142 | width = (week_f + 6 <= @date_to) ? 7 * zoom -1 : (@date_to - week_f + 1) * zoom-1 | |
143 | %> |
|
143 | %> | |
144 | <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> |
|
144 | <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> | |
145 | <small><%= week_f.cweek if width >= 16 %></small> |
|
145 | <small><%= week_f.cweek if width >= 16 %></small> | |
146 | </div> |
|
146 | </div> | |
147 | <% |
|
147 | <% | |
148 | left = left + width+1 |
|
148 | left = left + width+1 | |
149 | week_f = week_f+7 |
|
149 | week_f = week_f+7 | |
150 | end |
|
150 | end | |
151 | end %> |
|
151 | end %> | |
152 |
|
152 | |||
153 | <% |
|
153 | <% | |
154 | # |
|
154 | # | |
155 | # Days headers |
|
155 | # Days headers | |
156 | # |
|
156 | # | |
157 | if show_days |
|
157 | if show_days | |
158 | left = 0 |
|
158 | left = 0 | |
159 | height = g_height + header_heigth - 1 |
|
159 | height = g_height + header_heigth - 1 | |
160 | wday = @date_from.cwday |
|
160 | wday = @date_from.cwday | |
161 | (@date_to - @date_from + 1).to_i.times do |
|
161 | (@date_to - @date_from + 1).to_i.times do | |
162 | width = zoom - 1 |
|
162 | width = zoom - 1 | |
163 | %> |
|
163 | %> | |
164 | <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr"> |
|
164 | <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr"> | |
165 | <%= day_name(wday)[0,1] %> |
|
165 | <%= day_name(wday)[0,1] %> | |
166 | </div> |
|
166 | </div> | |
167 | <% |
|
167 | <% | |
168 | left = left + width+1 |
|
168 | left = left + width+1 | |
169 | wday = wday + 1 |
|
169 | wday = wday + 1 | |
170 | wday = 1 if wday > 7 |
|
170 | wday = 1 if wday > 7 | |
171 | end |
|
171 | end | |
172 | end %> |
|
172 | end %> | |
173 |
|
173 | |||
174 | <% |
|
174 | <% | |
175 | # |
|
175 | # | |
176 | # Today red line |
|
176 | # Today red line | |
177 | # |
|
177 | # | |
178 | if Date.today >= @date_from and Date.today <= @date_to %> |
|
178 | if Date.today >= @date_from and Date.today <= @date_to %> | |
179 | <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;"> </div> |
|
179 | <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;"> </div> | |
180 | <% end %> |
|
180 | <% end %> | |
181 |
|
181 | |||
182 | <% |
|
182 | <% | |
183 | # |
|
183 | # | |
184 | # Tasks |
|
184 | # Tasks | |
185 | # |
|
185 | # | |
186 | top = headers_height + 10 |
|
186 | top = headers_height + 10 | |
187 | @events.each do |i| |
|
187 | @events.each do |i| | |
188 | if i.is_a? Issue |
|
188 | if i.is_a? Issue | |
189 | i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from ) |
|
189 | i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from ) | |
190 | i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to ) |
|
190 | i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to ) | |
191 |
|
191 | |||
192 | i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor |
|
192 | i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor | |
193 | i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date ) |
|
193 | i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date ) | |
194 | i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date ) |
|
194 | i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date ) | |
195 |
|
195 | |||
196 | i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today |
|
196 | i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today | |
197 |
|
197 | |||
198 | i_left = ((i_start_date - @date_from)*zoom).floor |
|
198 | i_left = ((i_start_date - @date_from)*zoom).floor | |
199 | i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders) |
|
199 | i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders) | |
200 | d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width |
|
200 | d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width | |
201 | l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width |
|
201 | l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width | |
202 | %> |
|
202 | %> | |
203 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo"> </div> |
|
203 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo"> </div> | |
204 | <% if l_width > 0 %> |
|
204 | <% if l_width > 0 %> | |
205 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late"> </div> |
|
205 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late"> </div> | |
206 | <% end %> |
|
206 | <% end %> | |
207 | <% if d_width > 0 %> |
|
207 | <% if d_width > 0 %> | |
208 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done"> </div> |
|
208 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done"> </div> | |
209 | <% end %> |
|
209 | <% end %> | |
210 | <div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task"> |
|
210 | <div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task"> | |
211 | <%= i.status.name %> |
|
211 | <%= i.status.name %> | |
212 | <%= (i.done_ratio).to_i %>% |
|
212 | <%= (i.done_ratio).to_i %>% | |
213 | </div> |
|
213 | </div> | |
214 | <% # === tooltip === %> |
|
214 | <% # === tooltip === %> | |
215 | <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;"> |
|
215 | <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;"> | |
216 | <span class="tip"> |
|
216 | <span class="tip"> | |
217 | <%= render :partial => "issues/tooltip", :locals => { :issue => i }%> |
|
217 | <%= render :partial => "issues/tooltip", :locals => { :issue => i }%> | |
218 | </span></div> |
|
218 | </span></div> | |
219 | <% else |
|
219 | <% else | |
220 | i_left = ((i.start_date - @date_from)*zoom).floor |
|
220 | i_left = ((i.start_date - @date_from)*zoom).floor | |
221 | %> |
|
221 | %> | |
222 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone"> </div> |
|
222 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone"> </div> | |
223 | <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task"> |
|
223 | <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task"> | |
224 | <strong><%= i.name %></strong> |
|
224 | <strong><%= i.name %></strong> | |
225 | </div> |
|
225 | </div> | |
226 | <% end %> |
|
226 | <% end %> | |
227 | <% top = top + 20 |
|
227 | <% top = top + 20 | |
228 | end %> |
|
228 | end %> | |
229 | </div> |
|
229 | </div> | |
230 | </td> |
|
230 | </td> | |
231 | </tr> |
|
231 | </tr> | |
232 | </table> |
|
232 | </table> | |
233 |
|
233 | |||
234 | <table width="100%"> |
|
234 | <table width="100%"> | |
235 | <tr> |
|
235 | <tr> | |
236 | <td align="left"><%= link_to ('« ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td> |
|
236 | <td align="left"><%= link_to ('« ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td> | |
237 | <td align="right"><%= link_to (l(:label_next) + ' »'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td> |
|
237 | <td align="right"><%= link_to (l(:label_next) + ' »'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td> | |
238 | </tr> |
|
238 | </tr> | |
239 | </table> No newline at end of file |
|
239 | </table> |
General Comments 0
You need to be logged in to leave comments.
Login now