From 4860aec9ca8ddea86790b52f2fda1baba4416308 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 12 Dec 2011 17:10:18 +0100 Subject: [PATCH] Use the time_entries partial view to show time entries for a task (closes #e966ae) --- stoptime.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index db3642b..f891ff3 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -642,6 +642,11 @@ module StopTime::Controllers @customer_list = Customer.all.map do |c| [c.id, c.short_name.present? ? c.short_name : c.name] end + @time_entries = @task.time_entries.all(:order => "start DESC") + @time_entries.each do |te| + @input["bill_#{te.id}"] = true if te.bill? + end + @target = [CustomersNTasks, customer_id] @method = "create" return render :task_form @@ -694,12 +699,18 @@ module StopTime::Controllers [c.id, c.short_name.present? ? c.short_name : c.name] end @task = Task.find(task_id) - @target = [CustomersNTasksN, customer_id, task_id] - @method = "update" + @time_entries = @task.time_entries.all(:order => "start DESC") + @input = @task.attributes @input["type"] = @task.type @input["customer"] = @customer.id + @time_entries.each do |te| + @input["bill_#{te.id}"] = true if te.bill? + end + # FIXME: Check that task is of that customer. + @target = [CustomersNTasksN, customer_id, task_id] + @method = "update" render :task_form end