Skip to content

Commit 19f974f

Browse files
committed
Fix 'uninitialized constant Timesheet::FCSV'; fixes #58
1 parent 112959d commit 19f974f

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

app/helpers/timesheet_helper.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ def link_to_csv_export(timesheet)
3939
:class => 'icon icon-timesheet')
4040
end
4141

42+
def form_for_to_timesheet(timesheet)
43+
params_like_decode_url = CGI.unescape({:timesheet => timesheet.to_param}.to_query)
44+
inputs = ""
45+
form = form_tag :controller => 'timesheet', :action => 'report' do
46+
params_like_decode_url.split("&").each do |param|
47+
param_arr = param.split("=")
48+
inputs << hidden_field_tag(param_arr.first, param_arr.last, :id => "")
49+
end
50+
inputs << submit_tag(l(:timesheet_permalink))
51+
inputs.html_safe
52+
end
53+
form.html_safe
54+
end
55+
56+
4257
def toggle_arrows(element, js_function)
4358
js = "#{js_function}('#{element}');"
4459

app/models/timesheet.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ def to_param
162162

163163
def to_csv
164164
out = "";
165+
166+
167+
handle_time_entries = {}
168+
time_entries.each do |k,v|
169+
if k.is_a? String
170+
handle_time_entries[k] = v
171+
next;
172+
end
173+
handle_time_entries[k.name] = v
174+
end
175+
176+
time_entries = handle_time_entries
177+
178+
165179
FCSV.generate(out, :encoding => 'utf-8', :force_quotes => true) do |csv|
166180
csv << csv_header
167181

app/views/timesheet/report.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="contextual">
22
<%= link_to_csv_export(@timesheet) %>
3-
<%= permalink_to_timesheet(@timesheet) %>
3+
<%= form_for_to_timesheet(@timesheet) %>
44
</div>
55

66
<h2><%= l(:timesheet_title)%></h2>

init.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
require 'redmine'
22

3-
## Taken from lib/redmine.rb
4-
#if RUBY_VERSION < '1.9'
5-
# require 'faster_csv'
6-
#else
7-
# require 'csv'
8-
# FCSV = CSV
9-
#end
3+
# Taken from lib/redmine.rb
4+
if RUBY_VERSION < '1.9'
5+
require 'faster_csv'
6+
else
7+
require 'csv'
8+
FCSV = CSV
9+
end
1010

1111
if Rails::VERSION::MAJOR < 3
1212
require 'dispatcher'

0 commit comments

Comments
 (0)