Mercurial > hg > soundsoftware-site
diff app/helpers/issues_helper.rb @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 051f544170fe |
children | cbb26bc654de |
line wrap: on
line diff
--- a/app/helpers/issues_helper.rb Thu Mar 03 11:42:28 2011 +0000 +++ b/app/helpers/issues_helper.rb Mon Jun 06 14:24:13 2011 +0100 @@ -5,12 +5,12 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -54,20 +54,30 @@ "<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" + "<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}" end - + + def issue_heading(issue) + h("#{issue.tracker} ##{issue.id}") + end + def render_issue_subject_with_tree(issue) s = '' - issue.ancestors.each do |ancestor| + ancestors = issue.root? ? [] : issue.ancestors.visible.all + ancestors.each do |ancestor| s << '<div>' + content_tag('p', link_to_issue(ancestor)) end - s << '<div>' + content_tag('h3', h(issue.subject)) - s << '</div>' * (issue.ancestors.size + 1) + s << '<div>' + subject = h(issue.subject) + if issue.is_private? + subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject + end + s << content_tag('h3', subject) + s << '</div>' * (ancestors.size + 1) s end - + def render_descendants_tree(issue) s = '<form><table class="list issues">' - issue_list(issue.descendants.sort_by(&:lft)) do |child, level| + issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level| s << content_tag('tr', content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') + content_tag('td', link_to_issue(child, :truncate => 60), :class => 'subject') + @@ -79,7 +89,7 @@ s << '</form></table>' s end - + def render_custom_fields_rows(issue) return if issue.custom_field_values.empty? ordered_values = [] @@ -98,14 +108,32 @@ s << "</tr>\n" s end - + + def issues_destroy_confirmation_message(issues) + issues = [issues] unless issues.is_a?(Array) + message = l(:text_issues_destroy_confirmation) + descendant_count = issues.inject(0) {|memo, i| memo += (i.right - i.left - 1)/2} + if descendant_count > 0 + issues.each do |issue| + next if issue.root? + issues.each do |other_issue| + descendant_count -= 1 if issue.is_descendant_of?(other_issue) + end + end + if descendant_count > 0 + message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count) + end + end + message + end + def sidebar_queries unless @sidebar_queries # User can see public queries and his own queries visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)]) # Project specific queries and global queries visible << (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]) - @sidebar_queries = Query.find(:all, + @sidebar_queries = Query.find(:all, :select => 'id, name, is_public', :order => "name ASC", :conditions => visible.conditions) @@ -116,13 +144,13 @@ def query_links(title, queries) # links to #index on issues/show url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params - + content_tag('h3', title) + queries.collect {|query| link_to(h(query.name), url_params.merge(:query_id => query)) }.join('<br />') end - + def render_sidebar_queries out = '' queries = sidebar_queries.select {|q| !q.is_public?} @@ -154,6 +182,10 @@ label = l(:field_parent_issue) value = "##{detail.value}" unless detail.value.blank? old_value = "##{detail.old_value}" unless detail.old_value.blank? + + when detail.prop_key == 'is_private' + value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank? + old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank? end when 'cf' custom_field = CustomField.find_by_id(detail.prop_key) @@ -170,7 +202,7 @@ label ||= detail.prop_key value ||= detail.value old_value ||= detail.old_value - + unless no_html label = content_tag('strong', label) old_value = content_tag("i", h(old_value)) if detail.old_value @@ -182,11 +214,11 @@ value = content_tag("i", h(value)) if value end end - + if detail.property == 'attr' && detail.prop_key == 'description' s = l(:text_journal_changed_no_detail, :label => label) unless no_html - diff_link = link_to 'diff', + diff_link = link_to 'diff', {:controller => 'journals', :action => 'diff', :id => detail.journal_id, :detail_id => detail.id}, :title => l(:label_view_diff) s << " (#{ diff_link })" @@ -216,7 +248,7 @@ return record.name if record end end - + # Renders issue children recursively def render_api_issue_children(issue, api) return if issue.leaf? @@ -230,14 +262,14 @@ end end end - + def issues_to_csv(issues, project = nil) - ic = Iconv.new(l(:general_csv_encoding), 'UTF-8') + ic = Iconv.new(l(:general_csv_encoding), 'UTF-8') decimal_separator = l(:general_csv_decimal_separator) export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv| # csv header fields headers = [ "#", - l(:field_status), + l(:field_status), l(:field_project), l(:field_tracker), l(:field_priority), @@ -264,9 +296,9 @@ # csv lines issues.each do |issue| fields = [issue.id, - issue.status.name, + issue.status.name, issue.project.name, - issue.tracker.name, + issue.tracker.name, issue.priority.name, issue.subject, issue.assigned_to, @@ -278,7 +310,7 @@ issue.done_ratio, issue.estimated_hours.to_s.gsub('.', decimal_separator), issue.parent_id, - format_time(issue.created_on), + format_time(issue.created_on), format_time(issue.updated_on) ] custom_fields.each {|f| fields << show_value(issue.custom_value_for(f)) }