From 8a69714981816eb2a5f8bb571f6d807140f469a6 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 12 Jun 2008 14:54:37 -0700 Subject: [PATCH] Converted side form to a table. #1274 --- app/helpers/deliverables_helper.rb | 18 +++--- app/views/deliverables/_form.html.erb | 82 +++++++++++++++++++-------- assets/stylesheets/budget.css | 4 +- 3 files changed, 71 insertions(+), 33 deletions(-) diff --git a/app/helpers/deliverables_helper.rb b/app/helpers/deliverables_helper.rb index dd6b02e..57fad5f 100644 --- a/app/helpers/deliverables_helper.rb +++ b/app/helpers/deliverables_helper.rb @@ -3,14 +3,16 @@ module DeliverablesHelper # Helper to generate a form used to calculate the total budget while editing # a Deliverable def field_with_budget_observer_and_totals(form, field) - content_tag(:p, - form.text_field(field, :size => 7) + - content_tag(:span, - 0, - :class => "budget-calculation", - :id => field.to_s + '_subtotal' - ) - ) + observe_field('deliverable_' + field.to_s, :function => "new Budget.updateAmounts();") + content_tag(:tr, + content_tag(:td, "") + + content_tag(:td, text_field(:deliverable, field, :size => 7)) + + content_tag(:td, + content_tag(:span, + 0, + :class => "budget-calculation", + :id => field.to_s + '_subtotal' + ) + observe_field('deliverable_' + field.to_s, :function => "new Budget.updateAmounts();"))) + end # Helper to generate a consistant HTML format for displaying basic data diff --git a/app/views/deliverables/_form.html.erb b/app/views/deliverables/_form.html.erb index 6a39fe3..e0faa8e 100644 --- a/app/views/deliverables/_form.html.erb +++ b/app/views/deliverables/_form.html.erb @@ -14,36 +14,70 @@
-

- - <%= check_box(:deliverable, :type, {}, FixedDeliverable.name, HourlyDeliverable.name) %> -

- <%= observe_field('deliverable_type', :function => "new Budget.changeType();") %> + -

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

- <%= 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 => 'variableCost') %> -

- <%= observe_field('deliverable_total_hours', :function => "new Budget.updateAmounts();") %> + + + + + - - <%= observe_field('deliverable_fixed_cost', :function => "new Budget.updateAmounts();") %> + + + + + - <%= field_with_budget_observer_and_totals(f, :overhead) %> - <%= field_with_budget_observer_and_totals(f, :materials) %> - <%= field_with_budget_observer_and_totals(f, :profit) %> + + + + + - <%= content_tag(:p,"Total Budget:" + content_tag(:span, 0, :id => 'total-budget-calculation', :class => "budget-calculation"), - :class => "total-budget") %> + <%= field_with_budget_observer_and_totals(f, :overhead) %> + <%= field_with_budget_observer_and_totals(f, :materials) %> + <%= field_with_budget_observer_and_totals(f, :profit) %> -

<%= f.hidden_field :budget %>

- + + + + + + +
+ + + <%= check_box(:deliverable, :type, {}, FixedDeliverable.name, HourlyDeliverable.name) %> + <%= observe_field('deliverable_type', :function => "new Budget.changeType();") %> + +
+ + + <%= text_field :deliverable, :cost_per_hour, :size => 7 %> + <%= observe_field('deliverable_cost_per_hour', :function => "new Budget.updateAmounts();") %> + +
+ + + <%= text_field :deliverable, :total_hours, :size => 7 %> + <%= observe_field('deliverable_total_hours', :function => "new Budget.updateAmounts();") %> + + <%= content_tag(:span, 0, :class => "budget-calculation", :id => 'variableCost') %> +
<%= content_tag(:span, 0, :id => 'total-budget-calculation', :class => "budget-calculation") %>
+ <%= f.hidden_field :budget %>
diff --git a/assets/stylesheets/budget.css b/assets/stylesheets/budget.css index 5fe95f2..93f3a9b 100644 --- a/assets/stylesheets/budget.css +++ b/assets/stylesheets/budget.css @@ -37,4 +37,6 @@ span.budget-calculation { color:#999999; font-weight:bold; display:block; text-a p.total-budget { font-weight: bold; } p.total-budget #total-budget-calculation { } -.jstElements button { padding: 0; margin-right: 0px;} \ No newline at end of file +/* Rest some defaults */ +.jstElements button { padding: 0; margin-right: 0px;} +.tabular label { margin-left: 0; float: none;} \ No newline at end of file