remove trailing white-spaces from app/helpers/timelog_helper.rb.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6911 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7fc67f02f9
commit
dbc616c928
@ -1,23 +1,23 @@
|
|||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
module TimelogHelper
|
module TimelogHelper
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def render_timelog_breadcrumb
|
def render_timelog_breadcrumb
|
||||||
links = []
|
links = []
|
||||||
links << link_to(l(:label_project_all), {:project_id => nil, :issue_id => nil})
|
links << link_to(l(:label_project_all), {:project_id => nil, :issue_id => nil})
|
||||||
@ -52,15 +52,15 @@ module TimelogHelper
|
|||||||
activities.each { |a| collection << [a.name, a.id] }
|
activities.each { |a| collection << [a.name, a.id] }
|
||||||
collection
|
collection
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_hours(data, criteria, value)
|
def select_hours(data, criteria, value)
|
||||||
if value.to_s.empty?
|
if value.to_s.empty?
|
||||||
data.select {|row| row[criteria].blank? }
|
data.select {|row| row[criteria].blank? }
|
||||||
else
|
else
|
||||||
data.select {|row| row[criteria].to_s == value.to_s}
|
data.select {|row| row[criteria].to_s == value.to_s}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sum_hours(data)
|
def sum_hours(data)
|
||||||
sum = 0
|
sum = 0
|
||||||
data.each do |row|
|
data.each do |row|
|
||||||
@ -68,7 +68,7 @@ module TimelogHelper
|
|||||||
end
|
end
|
||||||
sum
|
sum
|
||||||
end
|
end
|
||||||
|
|
||||||
def options_for_period_select(value)
|
def options_for_period_select(value)
|
||||||
options_for_select([[l(:label_all_time), 'all'],
|
options_for_select([[l(:label_all_time), 'all'],
|
||||||
[l(:label_today), 'today'],
|
[l(:label_today), 'today'],
|
||||||
@ -82,9 +82,9 @@ module TimelogHelper
|
|||||||
[l(:label_this_year), 'current_year']],
|
[l(:label_this_year), 'current_year']],
|
||||||
value)
|
value)
|
||||||
end
|
end
|
||||||
|
|
||||||
def entries_to_csv(entries)
|
def entries_to_csv(entries)
|
||||||
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)
|
decimal_separator = l(:general_csv_decimal_separator)
|
||||||
custom_fields = TimeEntryCustomField.find(:all)
|
custom_fields = TimeEntryCustomField.find(:all)
|
||||||
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
|
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
|
||||||
@ -101,7 +101,7 @@ module TimelogHelper
|
|||||||
]
|
]
|
||||||
# Export custom fields
|
# Export custom fields
|
||||||
headers += custom_fields.collect(&:name)
|
headers += custom_fields.collect(&:name)
|
||||||
|
|
||||||
csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
||||||
# csv lines
|
# csv lines
|
||||||
entries.each do |entry|
|
entries.each do |entry|
|
||||||
@ -116,13 +116,13 @@ module TimelogHelper
|
|||||||
entry.comments
|
entry.comments
|
||||||
]
|
]
|
||||||
fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
|
fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
|
||||||
|
|
||||||
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
export
|
export
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_criteria_value(criteria, value)
|
def format_criteria_value(criteria, value)
|
||||||
if value.blank?
|
if value.blank?
|
||||||
l(:label_none)
|
l(:label_none)
|
||||||
@ -137,7 +137,7 @@ module TimelogHelper
|
|||||||
format_value(value, @available_criterias[criteria][:format])
|
format_value(value, @available_criterias[criteria][:format])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def report_to_csv(criterias, periods, hours)
|
def report_to_csv(criterias, periods, hours)
|
||||||
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
|
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
|
||||||
# Column headers
|
# Column headers
|
||||||
@ -160,7 +160,7 @@ module TimelogHelper
|
|||||||
end
|
end
|
||||||
export
|
export
|
||||||
end
|
end
|
||||||
|
|
||||||
def report_criteria_to_csv(csv, criterias, periods, hours, level=0)
|
def report_criteria_to_csv(csv, criterias, periods, hours, level=0)
|
||||||
hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value|
|
hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value|
|
||||||
hours_for_value = select_hours(hours, criterias[level], value)
|
hours_for_value = select_hours(hours, criterias[level], value)
|
||||||
@ -176,13 +176,13 @@ module TimelogHelper
|
|||||||
end
|
end
|
||||||
row << "%.2f" %total
|
row << "%.2f" %total
|
||||||
csv << row
|
csv << row
|
||||||
|
|
||||||
if criterias.length > level + 1
|
if criterias.length > level + 1
|
||||||
report_criteria_to_csv(csv, criterias, periods, hours_for_value, level + 1)
|
report_criteria_to_csv(csv, criterias, periods, hours_for_value, level + 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_utf8(s)
|
def to_utf8(s)
|
||||||
@ic ||= Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
@ic ||= Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||||
begin; @ic.iconv(s.to_s); rescue; s.to_s; end
|
begin; @ic.iconv(s.to_s); rescue; s.to_s; end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user