From 3d4e71ff933c939434707d15e155f56de4b451b0 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Wed, 7 Jul 2010 15:10:23 -0700 Subject: [PATCH] [#4183] Show budget fields on a single line: one for spent, one for budget. --- app/helpers/contracts_helper.rb | 15 ++++++++ app/views/contracts/show.html.erb | 33 ++++++------------ assets/stylesheets/redmine_contracts.css | 1 + test/integration/contracts_show_test.rb | 44 ++++++++++++------------ 4 files changed, 49 insertions(+), 44 deletions(-) diff --git a/app/helpers/contracts_helper.rb b/app/helpers/contracts_helper.rb index 927c856..07f5bf6 100644 --- a/app/helpers/contracts_helper.rb +++ b/app/helpers/contracts_helper.rb @@ -39,6 +39,21 @@ module ContractsHelper html_options) end + def show_budget_field(object, spent_field, total_field, options={}) + html_options = options[:html_options] || {} + label = content_tag(:span, l(("field_" + spent_field.to_s.gsub(/\_id$/, "")).to_sym) + ": ") + + spent_content = number_to_currency(object.send(spent_field)) + total_content = number_to_currency(object.send(total_field)) + + content_tag(:p, + label + + content_tag(:span, h(spent_content), :class => 'spent') + + content_tag(:span, h(total_content), :class => 'budget'), + html_options) + + end + def format_hourly_rate(decimal) number_to_currency(decimal) + "/hr" if decimal end diff --git a/app/views/contracts/show.html.erb b/app/views/contracts/show.html.erb index f009dc1..fcbc411 100644 --- a/app/views/contracts/show.html.erb +++ b/app/views/contracts/show.html.erb @@ -8,12 +8,9 @@ <%= show_field(resource, :start_date, :format => :format_date, :html_options => {:class => 'contract-start-date'}) %> <%= show_field(resource, :end_date, :format => :format_date, :html_options => {:class => 'contract-end-date'}) %> - <%= show_field(resource, :labor_spent, :html_options => {:class => 'contract-labor-spent'}) %> - <%= show_field(resource, :labor_budget, :html_options => {:class => 'contract-labor-budget'}) %> - <%= show_field(resource, :overhead_spent, :html_options => {:class => 'contract-overhead-spent'}) %> - <%= show_field(resource, :overhead_budget, :html_options => {:class => 'contract-overhead-budget'}) %> - <%= show_field(resource, :total_spent, :html_options => {:class => 'contract-total-spent'}) %> - <%= show_field(resource, :total_budget, :html_options => {:class => 'contract-total-budget'}) %> + <%= show_budget_field(resource, :labor_spent, :labor_budget, :html_options => {:class => 'contract-labor'}) %> + <%= show_budget_field(resource, :overhead_spent, :overhead_budget, :html_options => {:class => 'contract-overhead'}) %> + <%= show_budget_field(resource, :total_spent, :total_budget, :html_options => {:class => 'contract-total'}) %>
<%= show_field(resource, :client_point_of_contact, :html_options => {:class => 'contract-client-point-of-contact'}) %> @@ -24,24 +21,16 @@ <%= show_field(resource, :po_number, :html_options => {:class => 'contract-po-number'}) %> <%= show_field(resource, :details, :html_options => {:class => 'contract-details'}) %> - <%= show_field(resource, :labor_spent, :html_options => {:class => 'contract-labor-spent'}) %> - <%= show_field(resource, :labor_budget, :html_options => {:class => 'contract-labor-budget'}) %> - <%= show_field(resource, :overhead_spent, :html_options => {:class => 'contract-overhead-spent'}) %> - <%= show_field(resource, :overhead_budget, :html_options => {:class => 'contract-overhead-budget'}) %> - <%= show_field(resource, :fixed_spent, :html_options => {:class => 'contract-fixed-spent'}) %> - <%= show_field(resource, :fixed_budget, :html_options => {:class => 'contract-fixed-budget'}) %> - <%= show_field(resource, :markup_spent, :html_options => {:class => 'contract-markup-spent'}) %> - <%= show_field(resource, :markup_budget, :html_options => {:class => 'contract-markup-budget'}) %> - <%= show_field(resource, :profit_spent, :html_options => {:class => 'contract-profit-spent'}) %> - <%= show_field(resource, :profit_budget, :html_options => {:class => 'contract-profit-budget'}) %> - <%= show_field(resource, :discount_spent, :html_options => {:class => 'contract-discount-spent'}) %> - <%= show_field(resource, :discount_budget, :html_options => {:class => 'contract-discount-budget'}) %> - <%= show_field(resource, :total_spent, :html_options => {:class => 'contract-total-spent'}) %> - <%= show_field(resource, :total_budget, :html_options => {:class => 'contract-total-budget'}) %> + <%= show_budget_field(resource, :labor_spent, :labor_budget, :html_options => {:class => 'contract-labor'}) %> + <%= show_budget_field(resource, :overhead_spent, :overhead_budget, :html_options => {:class => 'contract-overhead'}) %> + <%= show_budget_field(resource, :fixed_spent, :fixed_budget, :html_options => {:class => 'contract-fixed'}) %> + <%= show_budget_field(resource, :markup_spent, :markup_budget, :html_options => {:class => 'contract-markup'}) %> + <%= show_budget_field(resource, :profit_spent, :profit_budget, :html_options => {:class => 'contract-profit'}) %> + <%= show_budget_field(resource, :discount_spent, :discount_budget, :html_options => {:class => 'contract-discount'}) %> + <%= show_budget_field(resource, :total_spent, :total_budget, :html_options => {:class => 'contract-total'}) %> <%= show_field(resource, :billable_rate, :format => :format_hourly_rate, :html_options => {:class => 'contract-billable-rate'}) %> - <%= show_field(resource, :estimated_hour_spent, :html_options => {:class => 'contract-estimated-hour-spent'}) %> - <%= show_field(resource, :estimated_hour_budget, :html_options => {:class => 'contract-estimated-hour-budget'}) %> + <%= show_budget_field(resource, :estimated_hour_spent, :estimated_hour_budget, :html_options => {:class => 'contract-estimated-hour'}) %>
<% end %> diff --git a/assets/stylesheets/redmine_contracts.css b/assets/stylesheets/redmine_contracts.css index 7f01cb4..f25d2ef 100644 --- a/assets/stylesheets/redmine_contracts.css +++ b/assets/stylesheets/redmine_contracts.css @@ -26,3 +26,4 @@ a.contract-delete {color: red; } #deliverables td.labor, #deliverables td.overhead, #deliverables td.fixed { text-align: center; } #deliverables td.labor div, #deliverables td.overhead div, #deliverables td.fixed div { text-align: right; display: inline; padding: 0 5px; width: 50%; } +.spent, .budget { text-align: right; padding: 0 5px; } diff --git a/test/integration/contracts_show_test.rb b/test/integration/contracts_show_test.rb index e137130..38e6ba7 100644 --- a/test/integration/contracts_show_test.rb +++ b/test/integration/contracts_show_test.rb @@ -30,12 +30,12 @@ class ContractsShowTest < ActionController::IntegrationTest assert_select '.contract-start-date' assert_select '.contract-end-date' - assert_select '.contract-labor-spent' - assert_select '.contract-labor-budget' - assert_select '.contract-overhead-spent' - assert_select '.contract-overhead-budget' - assert_select '.contract-total-spent' - assert_select '.contract-total-budget' + assert_select '.contract-labor .spent' + assert_select '.contract-labor .budget' + assert_select '.contract-overhead .spent' + assert_select '.contract-overhead .budget' + assert_select '.contract-total .spent' + assert_select '.contract-total .budget' assert_select '#contract-terms' do assert_select '.contract-client-point-of-contact' @@ -46,25 +46,25 @@ class ContractsShowTest < ActionController::IntegrationTest assert_select '.contract-po-number' assert_select '.contract-details' - assert_select '.contract-labor-spent' - assert_select '.contract-labor-budget' - assert_select '.contract-overhead-spent' - assert_select '.contract-overhead-budget' - assert_select '.contract-fixed-spent' - assert_select '.contract-fixed-budget' - assert_select '.contract-markup-spent' - assert_select '.contract-markup-budget' - assert_select '.contract-profit-spent' - assert_select '.contract-profit-budget' - assert_select '.contract-discount-spent' - assert_select '.contract-discount-budget' - assert_select '.contract-total-spent' - assert_select '.contract-total-budget' + assert_select '.contract-labor .spent' + assert_select '.contract-labor .budget' + assert_select '.contract-overhead .spent' + assert_select '.contract-overhead .budget' + assert_select '.contract-fixed .spent' + assert_select '.contract-fixed .budget' + assert_select '.contract-markup .spent' + assert_select '.contract-markup .budget' + assert_select '.contract-profit .spent' + assert_select '.contract-profit .budget' + assert_select '.contract-discount .spent' + assert_select '.contract-discount .budget' + assert_select '.contract-total .spent' + assert_select '.contract-total .budget' assert_select '.contract-billable-rate' - assert_select '.contract-estimated-hour-spent' - assert_select '.contract-estimated-hour-budget' + assert_select '.contract-estimated-hour .spent' + assert_select '.contract-estimated-hour .budget' end end end