##// END OF EJS Templates
tagged version 2.6.2...
tagged version 2.6.2 git-svn-id: http://svn.redmine.org/redmine/tags/2.6.2@14041 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r13491:3ba5e24a91ef
r13659:f6182db7de03 2.6.2
Show More
queries_helper.rb
206 lines | 7.1 KiB | text/x-ruby | RubyLexer
/ app / helpers / queries_helper.rb
Jean-Philippe Lang
Added encoding comment to helpers (#9792)....
r8090 # encoding: utf-8
#
Jean-Philippe Lang
Shortens filter param names....
r5159 # Redmine - project management software
Jean-Philippe Lang
Copyright update in 2.6-stable....
r13491 # Copyright (C) 2006-2015 Jean-Philippe Lang
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 #
# This program is free software; you can redistribute it and/or
# 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.
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/queries_helper.rb....
r6767 #
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 # 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.
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/queries_helper.rb....
r6767 #
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 # 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.
Jean-Philippe Lang
"queries" branch merged...
r92
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 module QueriesHelper
Jean-Philippe Lang
Fixed that Link custom fields are not displayed as links on the issue list (#16496)....
r12779 include ApplicationHelper
Jean-Philippe Lang
Build issue filters using javascript....
r9979 def filters_options_for_select(query)
Toshi MARUYAMA
split QueriesHelper filters_options_for_select method and add new unit test (#12018)...
r10339 options_for_select(filters_options(query))
end
def filters_options(query)
Jean-Philippe Lang
Build issue filters using javascript....
r9979 options = [[]]
Jean-Philippe Lang
Refactor: use an ordered hash to store available filters and remove :order option (#13154)....
r11142 options += query.available_filters.map do |field, field_options|
Jean-Philippe Lang
Build issue filters using javascript....
r9979 [field_options[:name], field]
end
Jean-Philippe Lang
"queries" branch merged...
r92 end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/queries_helper.rb....
r6767
Jean-Philippe Lang
Fixed that CSV Export of Spent Time ignores filters and columns selection (#13618)....
r11466 def query_filters_hidden_tags(query)
tags = ''.html_safe
query.filters.each do |field, options|
tags << hidden_field_tag("f[]", field, :id => nil)
tags << hidden_field_tag("op[#{field}]", options[:operator], :id => nil)
options[:values].each do |value|
tags << hidden_field_tag("v[#{field}][]", value, :id => nil)
end
end
tags
end
def query_columns_hidden_tags(query)
tags = ''.html_safe
query.columns.each do |column|
tags << hidden_field_tag("c[]", column.name, :id => nil)
end
tags
end
def query_hidden_tags(query)
query_filters_hidden_tags(query) + query_columns_hidden_tags(query)
end
Jean-Philippe Lang
Adds an option for displaying the issue description on the issue list (#3447)....
r10721 def available_block_columns_tags(query)
tags = ''.html_safe
query.available_block_columns.each do |column|
Jean-Philippe Lang
Removes duplicate ids (#15485)....
r12378 tags << content_tag('label', check_box_tag('c[]', column.name.to_s, query.has_column?(column), :id => nil) + " #{column.caption}", :class => 'inline')
Jean-Philippe Lang
Adds an option for displaying the issue description on the issue list (#3447)....
r10721 end
tags
end
Jean-Philippe Lang
Adds helpers for query columns selection....
r11221 def query_available_inline_columns_options(query)
(query.available_inline_columns - query.columns).reject(&:frozen?).collect {|column| [column.caption, column.name]}
end
def query_selected_inline_columns_options(query)
(query.inline_columns & query.available_inline_columns).reject(&:frozen?).collect {|column| [column.caption, column.name]}
end
Jean-Philippe Lang
Adds an helper for rendering query columns selection....
r11222 def render_query_columns_selection(query, options={})
tag_name = (options[:name] || 'c') + '[]'
render :partial => 'queries/columns', :locals => {:query => query, :tag_name => tag_name}
end
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 def column_header(column)
Jean-Philippe Lang
Validates sort_key and sort_order params (#2378)....
r2169 column.sortable ? sort_header_tag(column.name.to_s, :caption => column.caption,
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/queries_helper.rb....
r6767 :default_order => column.default_order) :
Jean-Philippe Lang
Additional escaping....
r6207 content_tag('th', h(column.caption))
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/queries_helper.rb....
r6767
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 def column_content(column, issue)
Jean-Philippe Lang
Fixed that Link custom fields are not displayed as links on the issue list (#16496)....
r12779 value = column.value_object(issue)
Jean-Philippe Lang
Adds support for multiselect custom fields (#1189)....
r8601 if value.is_a?(Array)
Jean-Philippe Lang
Makes related issues available for display and filtering on the issue list (#3239, #3265)....
r10303 value.collect {|v| column_value(column, issue, v)}.compact.join(', ').html_safe
Jean-Philippe Lang
Adds support for multiselect custom fields (#1189)....
r8601 else
column_value(column, issue, value)
end
end
def column_value(column, issue, value)
Jean-Philippe Lang
Extract generic formatting options to an helper....
r12087 case column.name
when :id
link_to value, issue_path(issue)
when :subject
link_to value, issue_path(issue)
Jean-Philippe Lang
Merged r13556 (#13673)....
r13246 when :parent
value ? (value.visible? ? link_to_issue(value, :subject => false) : "##{value.id}") : ''
Jean-Philippe Lang
Extract generic formatting options to an helper....
r12087 when :description
issue.description? ? content_tag('div', textilizable(issue, :description), :class => "wiki") : ''
when :done_ratio
progress_bar(value, :width => '80px')
when :relations
Jean-Philippe Lang
Makes related issues available for display and filtering on the issue list (#3239, #3265)....
r10303 other = value.other_issue(issue)
content_tag('span',
(l(value.label_for(issue)) + " " + link_to_issue(other, :subject => false, :tracker => false)).html_safe,
:class => value.css_classes_for(issue))
Jean-Philippe Lang
Fixed: "None" category issue count is empty while grouping by category (#4308)....
r2998 else
Jean-Philippe Lang
Extract generic formatting options to an helper....
r12087 format_object(value)
Jean-Philippe Lang
Added the ability to customize columns of a saved query....
r771 end
end
Eric Davis
Refactor: move method to helper....
r3577
Jean-Philippe Lang
Fixed that float custom fields do not use CSV decimal separator (#10364)....
r11211 def csv_content(column, issue)
Jean-Philippe Lang
Fixed that Link custom fields are not displayed as links on the issue list (#16496)....
r12779 value = column.value_object(issue)
Jean-Philippe Lang
Fixed that float custom fields do not use CSV decimal separator (#10364)....
r11211 if value.is_a?(Array)
value.collect {|v| csv_value(column, issue, v)}.compact.join(', ')
else
csv_value(column, issue, value)
end
end
Jean-Philippe Lang
Merged r13562 (#18269)....
r13248 def csv_value(column, object, value)
Jean-Philippe Lang
Fixed that Link custom fields are not displayed as links on the issue list (#16496)....
r12779 format_object(value, false) do |value|
case value.class.name
when 'Float'
sprintf("%.2f", value).gsub('.', l(:general_csv_decimal_separator))
when 'IssueRelation'
Jean-Philippe Lang
Merged r13562 (#18269)....
r13248 other = value.other_issue(object)
l(value.label_for(object)) + " ##{other.id}"
Jean-Philippe Lang
Merged r13555 (#13608)....
r13245 when 'Issue'
Jean-Philippe Lang
Merged r13562 (#18269)....
r13248 if object.is_a?(TimeEntry)
"#{value.tracker} ##{value.id}: #{value.subject}"
else
value.id
end
Jean-Philippe Lang
Fixed that Link custom fields are not displayed as links on the issue list (#16496)....
r12779 else
value
end
Jean-Philippe Lang
Fixed that float custom fields do not use CSV decimal separator (#10364)....
r11211 end
end
Jean-Philippe Lang
Refactor: #issues_to_csv and #entries_to_csv merged into QueriesHelper#query_to_csv....
r11218 def query_to_csv(items, query, options={})
encoding = l(:general_csv_encoding)
columns = (options[:columns] == 'all' ? query.available_inline_columns : query.inline_columns)
query.available_block_columns.each do |column|
if options[column.name].present?
columns << column
end
end
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
# csv header fields
csv << columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) }
# csv lines
items.each do |item|
csv << columns.collect {|c| Redmine::CodesetUtil.from_utf8(csv_content(c, item), encoding) }
end
end
export
end
Eric Davis
Refactor: move method to helper....
r3577 # Retrieve query from session or build a new query
def retrieve_query
if !params[:query_id].blank?
cond = "project_id IS NULL"
cond << " OR project_id = #{@project.id}" if @project
Jean-Philippe Lang
Cleanup of finders with :conditions option....
r11733 @query = IssueQuery.where(cond).find(params[:query_id])
Jean-Philippe Lang
Fixed: private queries should not be accessible to other users (#8729)....
r6043 raise ::Unauthorized unless @query.visible?
Etienne Massip
Reverted removal of project assignment to query (#9108)....
r7536 @query.project = @project
Eric Davis
Refactor: move method to helper....
r3577 session[:query] = {:id => @query.id, :project_id => @query.project_id}
sort_clear
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 elsif api_request? || params[:set_filter] || session[:query].nil? || session[:query][:project_id] != (@project ? @project.id : nil)
# Give it a name, required to be valid
Jean-Philippe Lang
Adds STI to Query model. Issue queries are now IssueQuery instances....
r10737 @query = IssueQuery.new(:name => "_")
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 @query.project = @project
Jean-Philippe Lang
Moved build_query_from_params helper to Query#build_from_params....
r10739 @query.build_from_params(params)
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names}
Eric Davis
Refactor: move method to helper....
r3577 else
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 # retrieve from session
Jean-Philippe Lang
Test failures with ruby1.8....
r11789 @query = nil
Jean-Philippe Lang
Adds STI to Query model. Issue queries are now IssueQuery instances....
r10737 @query = IssueQuery.find_by_id(session[:query][:id]) if session[:query][:id]
@query ||= IssueQuery.new(:name => "_", :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
Jean-Philippe Lang
Fixed that a cross-project custom query is not remembered inside project (#9738)....
r7993 @query.project = @project
Etienne Massip
Refactor : convert queries to REST resources (also fixes #9108)....
r7529 end
end
Etienne Massip
Reverted removal of project assignment to query (#9108)....
r7536
Jean-Philippe Lang
Adds previous/next links to issue (#2850)....
r8368 def retrieve_query_from_session
if session[:query]
Jean-Philippe Lang
Fixed previous/next links when navigating in a saved query....
r8537 if session[:query][:id]
Jean-Philippe Lang
Adds STI to Query model. Issue queries are now IssueQuery instances....
r10737 @query = IssueQuery.find_by_id(session[:query][:id])
Jean-Philippe Lang
Fixed previous/next links when navigating in a saved query....
r8537 return unless @query
else
Jean-Philippe Lang
Adds STI to Query model. Issue queries are now IssueQuery instances....
r10737 @query = IssueQuery.new(:name => "_", :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
Jean-Philippe Lang
Fixed previous/next links when navigating in a saved query....
r8537 end
Jean-Philippe Lang
Adds previous/next links to issue (#2850)....
r8368 if session[:query].has_key?(:project_id)
@query.project_id = session[:query][:project_id]
else
@query.project = @project
end
@query
end
end
Jean-Philippe Lang
"queries" branch merged...
r92 end