From fcf012c8280e2fd1c60ff14c31b252c952bec550 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Tue, 3 Aug 2010 14:41:54 -0700 Subject: [PATCH] [#4178] First port of the Contracts#show skin. --- app/helpers/contracts_helper.rb | 28 ++- app/views/contracts/show.html.erb | 369 ++++++++++++++++++++++++------ config/locales/en.yml | 3 +- 3 files changed, 322 insertions(+), 78 deletions(-) diff --git a/app/helpers/contracts_helper.rb b/app/helpers/contracts_helper.rb index bff44a4..b7b9612 100644 --- a/app/helpers/contracts_helper.rb +++ b/app/helpers/contracts_helper.rb @@ -8,10 +8,10 @@ module ContractsHelper def format_budget_for_deliverable(deliverable, spent, total) if total > 0 || spent > 0 - content_tag(:div, h(number_to_currency(spent, :unit => '')), :class => 'spent-amount') + - content_tag(:div, h(number_to_currency(total, :unit => '')), :class => 'total-amount') + content_tag(:td, h(number_to_currency(spent, :unit => '')), :class => 'spent-amount') + + content_tag(:td, h(number_to_currency(total, :unit => '')), :class => 'total-amount white') else - '---' + content_tag(:td, '----', :colspan => '2', :class => 'no-value') end end @@ -23,10 +23,12 @@ module ContractsHelper #

def show_field(object, field, options={}, &block) html_options = options[:html_options] || {} - label = content_tag(:span, l(("field_" + field.to_s.gsub(/\_id$/, "")).to_sym) + ": ", :class => 'contract-details-label') + label_html_options = options[:label_html_options] || {} + label = content_tag(:strong, l(("field_" + field.to_s.gsub(/\_id$/, "")).to_sym) + ": ", :class => 'contract-details-label') formatter = options[:format] raw_content = options[:raw] || false + wrap_in_td = options[:wrap_in_td] || true content = '' @@ -39,10 +41,16 @@ module ContractsHelper object.send(field) end end + + if raw_content + field_content = content + else + field_content = h(content) + end - content_tag(:p, - label + - (raw_content ? content : h(content)), + content_tag(:tr, + content_tag(:td, label, label_html_options) + + (wrap_in_td ? content_tag(:td, field_content) : field_content), html_options) end @@ -52,10 +60,10 @@ module ContractsHelper spent_content = send(formatter, object.send(spent_field)) total_content = send(formatter, object.send(total_field)) - show_field(object, spent_field, options.merge(:raw => true)) do + show_field(object, spent_field, options.merge(:raw => true, :wrap_in_td => false)) do - content_tag(:span, h(spent_content), :class => 'spent') + - content_tag(:span, h(total_content), :class => 'budget') + content_tag(:td, h(spent_content), :class => 'spent') + + content_tag(:td, h(total_content), :class => 'budget') end end diff --git a/app/views/contracts/show.html.erb b/app/views/contracts/show.html.erb index 781fb9a..8480fa4 100644 --- a/app/views/contracts/show.html.erb +++ b/app/views/contracts/show.html.erb @@ -1,82 +1,317 @@ -<%# TODO: Need skinning %> -<% div_for(resource) do %> +
<%= content_tag(:h2, h(resource.name)) %> + +
+ Log time - <%= show_field(resource, :status, :html_options => {:class => 'contract-status'}) %> - <%= show_field(resource, :account_executive, :html_options => {:class => 'contract-account-manager'}) %> - <%= show_field(resource, :contract_type, :html_options => {:class => 'contract-type'}) %> - <%= 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'}) %> + | + + Watch - <%= 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'}) %> + | + + Copy + | + +
+ <%= link_to(l(:button_update), edit_contract_path(@project, resource)) %> +
+
+
+<%# TODO: contract messages +
+

There is $243 worth of time clocked to issues that are not assigned to any deliverables. Please update the orphaned issues.

+
+%> +<% div_for(resource) do %> -
- <%= show_field(resource, :client_point_of_contact, :format => :textilizable, :raw => true, :html_options => {:class => 'contract-client-point-of-contact'}) %> - <%= show_field(resource, :executed, :html_options => {:class => 'contract-executed'}) %> - <%= show_field(resource, :discount_note, :format => :textilizable, :raw => true, :html_options => {:class => 'contract-discount-note'}) %> - <%= show_field(resource, :payment_terms, :format => :format_payment_terms, :html_options => {:class => 'contract-payment-terms'}) %> - <%= show_field(resource, :client_ap_contact_information, :format => :textilizable, :raw => true, :html_options => {:class => 'contract-client-ap-contact-information'}) %> - <%= show_field(resource, :po_number, :html_options => {:class => 'contract-po-number'}) %> - <%= show_field(resource, :details, :format => :textilizable, :raw => true, :html_options => {:class => 'contract-details'}) %> + <%= avatar(resource.account_executive, :size => 40) %> -
- <%= show_budget_field(resource, :labor_spent, :labor_budget, :html_options => {:class => 'contract-labor'}) %> +
+ + <%= show_field(resource, :status, :html_options => {:class => 'contract-status'}) %> + <%= show_field(resource, :account_executive, :html_options => {:class => 'contract-account-manager'}) %> + <%= show_field(resource, :contract_type, :html_options => {:class => 'contract-type'}) %> +
+ + + <%= 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_budget_field(resource, :labor_spent, :labor_budget, :html_options => {:class => 'contract-labor'}, :label_html_options => {:width => '49%'}) %> <%= 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'}) %> +
+ +
+ + <%= l(:text_terms_and_financial_overview) %> + +
+ +
+ + <%= show_field(resource, :client_point_of_contact, :format => :textilizable, :raw => true, :html_options => {:class => 'contract-client-point-of-contact padd'}, :label_html_options => {:width => '25%'}) %> + <%= show_field(resource, :executed, :html_options => {:class => 'contract-executed'}) %> + <%= show_field(resource, :discount_note, :format => :textilizable, :raw => true, :html_options => {:class => 'contract-discount-note'}) %> + <%= show_field(resource, :payment_terms, :format => :format_payment_terms, :html_options => {:class => 'contract-payment-terms'}) %> + <%= show_field(resource, :client_ap_contact_information, :format => :textilizable, :raw => true, :html_options => {:class => 'contract-client-ap-contact-information'}) %> + <%= show_field(resource, :po_number, :html_options => {:class => 'contract-po-number'}) %> + <%= show_field(resource, :details, :format => :textilizable, :raw => true, :html_options => {:class => 'contract-details'}) %> +
+
- <%= show_field(resource, :billable_rate, :format => :format_hourly_rate, :html_options => {:class => 'contract-billable-rate'}) %> - <%= show_budget_field(resource, :estimated_hour_spent, :estimated_hour_budget, :format => :l_hours, :html_options => {:class => 'contract-estimated-hour'}) %> + + <%= show_budget_field(resource, :labor_spent, :labor_budget, :html_options => {:class => 'contract-labor'}, :label_html_options => {:width => '46%'}) %> + <%= 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 total'}) %> + + <%= show_budget_field(resource, :estimated_hour_spent, :estimated_hour_budget, :format => :l_hours, :html_options => {:class => 'contract-estimated-hour total'}) %> + +
+
+
+
+
+
+
+ +
+ + <%= content_tag(:h3, l(:field_deliverable_plural)) %> + +
+ CSV + View All (9) + <%= link_to(l(:button_add_new), new_contract_deliverable_path(@project, resource), :id => 'new-deliverable') %>
-
-<% end %> +
-<%= link_to(l(:button_update), edit_contract_path(@project, resource)) %> + <% if resource.deliverables.empty? %> +

<%= l(:label_no_data) %>

+ <% else %> + + + + + + + + + + + + + -<%= link_to(l(:button_add_new), new_contract_deliverable_path(@project, resource), :id => 'new-deliverable') %> + + <% resource.deliverables.each do |deliverable| %> + <%#= TODO: even/'' class %> + <% content_tag_for(:tr, deliverable, :class => 'click') do %> + + + + + + <%= format_budget_for_deliverable(deliverable, deliverable.labor_budget_spent, deliverable.labor_budget_total) %> + <%= format_budget_for_deliverable(deliverable, deliverable.overhead_spent, deliverable.overhead_budget_total) %> + <%= format_budget_for_deliverable(deliverable, 0, 0) %><%# TODO: Fixed %> + <% end %> -<% if resource.deliverables.empty? %> -

<%= l(:label_no_data) %>

-<% else %> -
<%= l(:field_end_date) %> <%= l(:field_title) %><%= l(:field_status) %><%= l(:field_manager) %><%= l(:field_labor) %><%= l(:field_overhead) %><%= l(:field_fixed) %>
<%= h format_date(deliverable.end_date) %><%= h deliverable.short_type %><%= h deliverable.title %>TODO<%= h deliverable.manager.try(:name) %>
- - - - - <%# TODO: Status %> - - - - - - - - - <% resource.deliverables.each do |deliverable| %> - <% content_tag_for(:tr, deliverable) do %> - - - - <%# TODO: Status %> - - - - - - + + + + <% end %> + +
<%= l(:field_end_date) %> <%= l(:field_title) %><%= l(:field_manager) %><%= l(:field_labor) %><%= l(:field_overhead) %><%= l(:field_fixed) %><%= l(:button_edit) %><%= l(:button_delete) %>
<%= h format_date(deliverable.end_date) %><%= h deliverable.short_type %><%= h deliverable.title %><%= h deliverable.manager.try(:name) %> - <%= format_budget_for_deliverable(deliverable, deliverable.labor_budget_spent, deliverable.labor_budget_total) %> - - <%= format_budget_for_deliverable(deliverable, deliverable.overhead_spent, deliverable.overhead_budget_total) %> - ---<%= link_to(l(:button_edit), edit_contract_deliverable_path(@project, resource, deliverable), :class => 'icon icon-edit') %><%= link_to(l(:button_delete), contract_deliverable_path(@project, resource, deliverable), :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
+ +
+
+
+ <%= link_to(l(:button_edit), edit_contract_deliverable_path(@project, resource, deliverable), :class => 'icon icon-edit') %> + <%= link_to(l(:button_delete), contract_deliverable_path(@project, resource, deliverable), :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %> +
+ + <%= textilizable(deliverable, :notes) %> + + + <%= show_field(deliverable, :start_date, :format => :format_date, :html_options => {:class => 'deliverable-start-date'}) %> + <%= show_field(deliverable, :end_date, :format => :format_date, :html_options => {:class => 'deliverable-end-date'}) %> +
- <% end %> +
+ + <%# TODO: skinning port %> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%# TODO: Fixed %> + <%# TODO: Markup %> + + + + + + + + + + + + + +
SpentBudgetHours
Labor<%= h(deliverable.labor_budget_spent) %><%= h(deliverable.labor_budget_total) %> TODO / TODO hrs
Overhead<%= h(deliverable.overhead_spent) %><%= h(deliverable.overhead_budget_total) %> TODO / TODO hrs
Profit<%= h(deliverable.profit_left) %><%= h(deliverable.profit_budget) %>
Total:<%= h(deliverable.total_spent) %><%= h(deliverable.total) %>TODO
+
+ +
+ + + + + + + <%# TODO: Issue status counters + + + + + + + + + + + + + + + + + %> +
<%= l(:label_issue_status_plural) %>
Proposed1
On Hold1
Complete14
All16
+
+
+
+
<% end %> - - -<% end %> + +
+
+ +<% end %> <%# div_for(resource) %> + + +<%# TODO: history %> diff --git a/config/locales/en.yml b/config/locales/en.yml index c1b9531..fb422a4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -53,4 +53,5 @@ en: field_total_spent: "Contract Total" field_contract_type: "Type" field_deliverable: "Deliverable" - + field_deliverable_plural: "Deliverables" + text_terms_and_financial_overview: "Contract Terms and Financial Overview"