From df37d248a1c6eec1c8211fe0894eab7e262e9d8e Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Tue, 20 May 2008 23:11:43 -0700 Subject: [PATCH] Updated the JS API to be singleton, #1135 --- app/helpers/deliverables_helper.rb | 4 +- app/views/deliverables/_form.html.erb | 91 +++++++++++++++++++-------- 2 files changed, 67 insertions(+), 28 deletions(-) diff --git a/app/helpers/deliverables_helper.rb b/app/helpers/deliverables_helper.rb index d9ff59c..d93e901 100644 --- a/app/helpers/deliverables_helper.rb +++ b/app/helpers/deliverables_helper.rb @@ -5,8 +5,8 @@ module DeliverablesHelper content_tag(:span, 0, :class => "budget-calculation", - :id => 'deliverable_' + field.to_s + '_subtotal' + :id => field.to_s + '_subtotal' ) - ) + observe_field('deliverable_' + field.to_s, :function => "new Budget().updateSubtotal('deliverable_#{field.to_s}'); new Budget().updateBudget('deliverable_budget');") + ) + observe_field('deliverable_' + field.to_s, :function => "new Budget.updateAmounts();") end end diff --git a/app/views/deliverables/_form.html.erb b/app/views/deliverables/_form.html.erb index 19d8629..716293c 100644 --- a/app/views/deliverables/_form.html.erb +++ b/app/views/deliverables/_form.html.erb @@ -21,13 +21,13 @@

TODO: Fixed cost

<%= f.text_field :cost_per_hour, :size => 7 %>

- <%= observe_field('deliverable_cost_per_hour', :function => "new Budget().updateBaseSubtotal(); new Budget().updateBudget('deliverable_budget');") %> + <%= observe_field('deliverable_cost_per_hour', :function => "new Budget.updateAmounts();") %>

<%= f.text_field :total_hours, :size => 7 %> - <%= content_tag(:span, 0, :class => "budget-calculation", :id => 'deliverable_base_subtotal') %> + <%= content_tag(:span, 0, :class => "budget-calculation", :id => 'variableCost') %>

- <%= observe_field('deliverable_total_hours', :function => "new Budget().updateBaseSubtotal(); new Budget().updateBudget('deliverable_budget');") %> + <%= observe_field('deliverable_total_hours', :function => "new Budget.updateAmounts();") %> <%= field_with_budget_observer_and_totals(f, :overhead) %> <%= field_with_budget_observer_and_totals(f, :materials) %> @@ -62,10 +62,9 @@ <% content_for :header_tags do %>