summaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-02-26 18:15:58 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-02-26 18:15:58 +0000
commit328df74dd1779963b80317b72e56aa2a4ea5e2f2 (patch)
treebc34c905768eeae2106de016d9887ba106c14a8a /app/helpers
parent792b7f30e32eec84d6106e947fc3987e4e26a0b0 (diff)
downloadredmine-328df74dd1779963b80317b72e56aa2a4ea5e2f2.tar.gz
redmine-328df74dd1779963b80317b72e56aa2a4ea5e2f2.zip
Adds date range filter and pagination on time entries detail view (closes #434).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1173 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--app/helpers/sort_helper.rb10
-rw-r--r--app/helpers/timelog_helper.rb47
3 files changed, 56 insertions, 5 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e39ea0906..af493b034 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -90,6 +90,10 @@ module ApplicationHelper
include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format)
end
+ def html_hours(text)
+ text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>')
+ end
+
def authoring(created, author)
time_tag = content_tag('acronym', distance_of_time_in_words(Time.now, created), :title => format_time(created))
l(:label_added_time_by, author || 'Anonymous', time_tag)
diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb
index 155e7e5e3..f16ff3c7d 100644
--- a/app/helpers/sort_helper.rb
+++ b/app/helpers/sort_helper.rb
@@ -108,13 +108,13 @@ module SortHelper
end
caption = titleize(Inflector::humanize(column)) unless caption
- url = {:sort_key => column, :sort_order => order, :status => params[:status],
- :issue_id => params[:issue_id],
- :project_id => params[:project_id]}
+ sort_options = { :sort_key => column, :sort_order => order }
+ # don't reuse params if filters are present
+ url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options)
link_to_remote(caption,
- {:update => "content", :url => url},
- {:href => url_for(url)}) +
+ {:update => "content", :url => url_options},
+ {:href => url_for(url_options)}) +
(icon ? nbsp(2) + image_tag(icon) : '')
end
diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb
index 22e4eba0b..2af748f6f 100644
--- a/app/helpers/timelog_helper.rb
+++ b/app/helpers/timelog_helper.rb
@@ -27,4 +27,51 @@ module TimelogHelper
end
sum
end
+
+ def options_for_period_select(value)
+ options_for_select([[l(:label_all_time), 'all'],
+ [l(:label_today), 'today'],
+ [l(:label_yesterday), 'yesterday'],
+ [l(:label_this_week), 'current_week'],
+ [l(:label_last_week), 'last_week'],
+ [l(:label_last_n_days, 7), '7_days'],
+ [l(:label_this_month), 'current_month'],
+ [l(:label_last_month), 'last_month'],
+ [l(:label_last_n_days, 30), '30_days'],
+ [l(:label_this_year), 'current_year']],
+ value)
+ end
+
+ def entries_to_csv(entries)
+ ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
+ export = StringIO.new
+ CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
+ # csv header fields
+ headers = [l(:field_spent_on),
+ l(:field_user),
+ l(:field_activity),
+ l(:field_issue),
+ l(:field_tracker),
+ l(:field_subject),
+ l(:field_hours),
+ l(:field_comments)
+ ]
+ csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
+ # csv lines
+ entries.each do |entry|
+ fields = [l_date(entry.spent_on),
+ entry.user,
+ entry.activity,
+ (entry.issue ? entry.issue.id : nil),
+ (entry.issue ? entry.issue.tracker : nil),
+ (entry.issue ? entry.issue.subject : nil),
+ entry.hours,
+ entry.comments
+ ]
+ csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
+ end
+ end
+ export.rewind
+ export
+ end
end