comparison app/helpers/.svn/text-base/issues_helper.rb.svn-base @ 245:051f544170fe

* Update to SVN trunk revision 4993
author Chris Cannam
date Thu, 03 Mar 2011 11:42:28 +0000
parents 8661b858af72
children cbce1fd3b1b7
comparison
equal deleted inserted replaced
244:8972b600f4fb 245:051f544170fe
1 # redMine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang 2 # Copyright (C) 2006-2011 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.
104 # User can see public queries and his own queries 104 # User can see public queries and his own queries
105 visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)]) 105 visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
106 # Project specific queries and global queries 106 # Project specific queries and global queries
107 visible << (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]) 107 visible << (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
108 @sidebar_queries = Query.find(:all, 108 @sidebar_queries = Query.find(:all,
109 :select => 'id, name', 109 :select => 'id, name, is_public',
110 :order => "name ASC", 110 :order => "name ASC",
111 :conditions => visible.conditions) 111 :conditions => visible.conditions)
112 end 112 end
113 @sidebar_queries 113 @sidebar_queries
114 end
115
116 def query_links(title, queries)
117 # links to #index on issues/show
118 url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
119
120 content_tag('h3', title) +
121 queries.collect {|query|
122 link_to(h(query.name), url_params.merge(:query_id => query))
123 }.join('<br />')
124 end
125
126 def render_sidebar_queries
127 out = ''
128 queries = sidebar_queries.select {|q| !q.is_public?}
129 out << query_links(l(:label_my_queries), queries) if queries.any?
130 queries = sidebar_queries.select {|q| q.is_public?}
131 out << query_links(l(:label_query_plural), queries) if queries.any?
132 out
114 end 133 end
115 134
116 def show_detail(detail, no_html=false) 135 def show_detail(detail, no_html=false)
117 case detail.property 136 case detail.property
118 when 'attr' 137 when 'attr'
162 else 181 else
163 value = content_tag("i", h(value)) if value 182 value = content_tag("i", h(value)) if value
164 end 183 end
165 end 184 end
166 185
167 if !detail.value.blank? 186 if detail.property == 'attr' && detail.prop_key == 'description'
187 s = l(:text_journal_changed_no_detail, :label => label)
188 unless no_html
189 diff_link = link_to 'diff',
190 {:controller => 'journals', :action => 'diff', :id => detail.journal_id, :detail_id => detail.id},
191 :title => l(:label_view_diff)
192 s << " (#{ diff_link })"
193 end
194 s
195 elsif !detail.value.blank?
168 case detail.property 196 case detail.property
169 when 'attr', 'cf' 197 when 'attr', 'cf'
170 if !detail.old_value.blank? 198 if !detail.old_value.blank?
171 l(:text_journal_changed, :label => label, :old => old_value, :new => value) 199 l(:text_journal_changed, :label => label, :old => old_value, :new => value)
172 else 200 else