##// END OF EJS Templates
Makes time entry custom fields available for display on the time entries list (#1766)....
Makes time entry custom fields available for display on the time entries list (#1766). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10972 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r10745:0ce6eb92850b
r10745:0ce6eb92850b
Show More
queries_helper.rb
162 lines | 5.6 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....
r9453 # Copyright (C) 2006-2012 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
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 = [[]]
Toshi MARUYAMA
sort custom field issue filter by type and position (#12018)...
r10344 sorted_options = query.available_filters.sort do |a, b|
ord = 0
if !(a[1][:order] == 20 && b[1][:order] == 20)
ord = a[1][:order] <=> b[1][:order]
else
cn = (CustomField::CUSTOM_FIELDS_NAMES.index(a[1][:field].class.name) <=>
CustomField::CUSTOM_FIELDS_NAMES.index(b[1][:field].class.name))
if cn != 0
ord = cn
else
f = (a[1][:field] <=> b[1][:field])
if f != 0
ord = f
else
# assigned_to or author
ord = (a[0] <=> b[0])
end
end
end
ord
end
options += sorted_options.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
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|
tags << content_tag('label', check_box_tag('c[]', column.name.to_s, query.has_column?(column)) + " #{column.caption}", :class => 'inline')
end
tags
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: "None" category issue count is empty while grouping by category (#4308)....
r2998 value = column.value(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
Fixed: "None" category issue count is empty while grouping by category (#4308)....
r2998 case value.class.name
when 'String'
if column.name == :subject
link_to(h(value), :controller => 'issues', :action => 'show', :id => issue)
Jean-Philippe Lang
Adds an option for displaying the issue description on the issue list (#3447)....
r10721 elsif column.name == :description
issue.description? ? content_tag('div', textilizable(issue, :description), :class => "wiki") : ''
Jean-Philippe Lang
Fixed: "None" category issue count is empty while grouping by category (#4308)....
r2998 else
h(value)
end
when 'Time'
format_time(value)
when 'Date'
format_date(value)
when 'Fixnum', 'Float'
if column.name == :done_ratio
progress_bar(value, :width => '80px')
Jean-Philippe Lang
Makes spent time column available on the issue list (#971)....
r7953 elsif column.name == :spent_hours
sprintf "%.2f", value
Jean-Philippe Lang
Makes time entry custom fields available for display on the time entries list (#1766)....
r10745 elsif column.name == :hours
html_hours("%.2f" % value)
Jean-Philippe Lang
Roadmap: more accurate completion percentage calculation (done ratio of open issues is now taken into account)....
r895 else
Toshi MARUYAMA
HTML escape at app/helpers/queries_helper.rb....
r6233 h(value.to_s)
Jean-Philippe Lang
Custom fields can now be displayed as columns on the issue list....
r876 end
Jean-Philippe Lang
Fixed: "None" category issue count is empty while grouping by category (#4308)....
r2998 when 'User'
link_to_user value
when 'Project'
Jean-Baptiste Barth
Refactor: added link_to_project helper to handle links to projects...
r3810 link_to_project value
Jean-Philippe Lang
Fixed: "None" category issue count is empty while grouping by category (#4308)....
r2998 when 'Version'
link_to(h(value), :controller => 'versions', :action => 'show', :id => value)
when 'TrueClass'
l(:general_text_Yes)
when 'FalseClass'
l(:general_text_No)
Jean-Philippe Lang
Issue list improvements for subtasking (#5196):...
r3504 when 'Issue'
Jean-Philippe Lang
Makes time entry custom fields available for display on the time entries list (#1766)....
r10745 value.visible? ? link_to_issue(value) : "##{value.id}"
Jean-Philippe Lang
Makes related issues available for display and filtering on the issue list (#3239, #3265)....
r10303 when 'IssueRelation'
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
h(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
# 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
Adds STI to Query model. Issue queries are now IssueQuery instances....
r10737 @query = IssueQuery.find(params[:query_id], :conditions => cond)
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
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