Merge pull request #169 from HDinger/fix/21624-broken-table-layout-budget-page-FF-IE

[21624] Broken table layout on budget page (FF and IE)
pull/6827/head
Magdalena Kafka 9 years ago
commit 374f76e6ca
  1. 497
      app/views/cost_objects/_show_variable_cost_object.html.erb

@ -22,16 +22,88 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<div class="grid-block"> <div class="grid-block">
<div class="grid-content"> <div class="grid-content">
<h4><%= VariableCostObject.human_attribute_name(:material_budget) %></h4> <h4><%= VariableCostObject.human_attribute_name(:material_budget) %></h4>
<div class="generic-table--container"> <div>
<div class="generic-table--results-container"> <div class="generic-table--container">
<table interactive-table role="grid" class="generic-table material_budget_items"> <div class="generic-table--results-container">
<colgroup> <table interactive-table role="grid" class="generic-table material_budget_items">
<col highlight-col> <colgroup>
<col highlight-col> <col highlight-col>
<col highlight-col> <col highlight-col>
<col highlight-col> <col highlight-col>
</colgroup> <col highlight-col>
<thead> </colgroup>
<thead>
<tr>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= MaterialBudgetItem.human_attribute_name(:units) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= MaterialBudgetItem.human_attribute_name(:cost_type) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= MaterialBudgetItem.human_attribute_name(:comment) %>
</span>
</div>
</div>
</th>
<th class="currency">
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= MaterialBudgetItem.human_attribute_name(:budget) %>
</span>
</div>
</div>
</th>
</tr>
</thead>
<tbody>
<% @cost_object.material_budget_items.each do |material_budget_item| %>
<tr>
<td class="units"><%=h pluralize(material_budget_item.units, material_budget_item.cost_type.unit, material_budget_item.cost_type.unit_plural) %></td>
<td><%=h material_budget_item.cost_type.name %></td>
<td class="comments"><%=h material_budget_item.comments %></td>
<td class="currency"><%= material_budget_item.costs_visible_by?(User.current) ? number_to_currency(material_budget_item.costs) : "" %></td>
</tr>
<% end %>
<% if User.current.allowed_to?(:view_cost_rates, @project) %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.material_budget) %></strong></td></tr>
<% end %>
</tbody>
</table>
<div class="generic-table--header-background"></div>
</div>
</div>
</div>
</div>
<div class="grid-content">
<h4><%= l(:caption_material_costs) %></h4>
<div>
<div class="generic-table--container">
<div class="generic-table--results-container">
<table interactive-table role="grid" class="generic-table material_budget_items">
<colgroup>
<col highlight-col>
<col highlight-col>
<col highlight-col>
<col highlight-col>
</colgroup>
<thead>
<tr> <tr>
<th> <th>
<div class="generic-table--sort-header-outer"> <div class="generic-table--sort-header-outer">
@ -70,106 +142,38 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</div> </div>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @cost_object.material_budget_items.each do |material_budget_item| %> <% @cost_object.cost_entries.visible(User.current, @project).includes(:cost_type).group_by(&:work_package).each do |work_package, cost_entries|
<tr> entries = cost_entries.inject(Hash.new) do |results, entry|
<td class="units"><%=h pluralize(material_budget_item.units, material_budget_item.cost_type.unit, material_budget_item.cost_type.unit_plural) %></td> result = results[entry.cost_type.id.to_s]
<td><%=h material_budget_item.cost_type.name %></td> unless result
<td class="comments"><%=h material_budget_item.comments %></td> result = CostEntry.new(cost_type: entry.cost_type, overridden_costs: 0.0, units: 0)
<td class="currency"><%= material_budget_item.costs_visible_by?(User.current) ? number_to_currency(material_budget_item.costs) : "" %></td> results[entry.cost_type.id.to_s] = result
</tr> end
<% end %>
<% if User.current.allowed_to?(:view_cost_rates, @project) %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.material_budget) %></strong></td></tr>
<% end %>
</tbody>
</table>
<div class="generic-table--header-background"></div>
</div>
</div>
</div>
<div class="grid-content">
<h4><%= l(:caption_material_costs) %></h4>
<div class="generic-table--container">
<div class="generic-table--results-container">
<table interactive-table role="grid" class="generic-table material_budget_items">
<colgroup>
<col highlight-col>
<col highlight-col>
<col highlight-col>
<col highlight-col>
</colgroup>
<thead>
<tr>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= CostEntry.human_attribute_name(:work_package)%>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= CostEntry.human_attribute_name(:units) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= CostEntry.human_attribute_name(:cost_type) %>
</span>
</div>
</div>
</th>
<th class="currency">
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= CostEntry.human_attribute_name(:costs) %>
</span>
</div>
</div>
</th>
</tr>
</thead>
<tbody>
<% @cost_object.cost_entries.visible(User.current, @project).includes(:cost_type).group_by(&:work_package).each do |work_package, cost_entries|
entries = cost_entries.inject(Hash.new) do |results, entry|
result = results[entry.cost_type.id.to_s]
unless result
result = CostEntry.new(cost_type: entry.cost_type, overridden_costs: 0.0, units: 0)
results[entry.cost_type.id.to_s] = result
end
result.overridden_costs += entry.real_costs result.overridden_costs += entry.real_costs
result.units += entry.units result.units += entry.units
results results
end.values end.values
entries.each do |c| entries.each do |c|
%> %>
<tr> <tr>
<td class="subject"><%= link_to_work_package work_package %></td> <td class="subject"><%= link_to_work_package work_package %></td>
<td><%= link_to pluralize(c.units, c.cost_type.unit, c.cost_type.unit_plural), {:controller => "/costlog", :action => "index", :cost_type_id => c.cost_type, :work_package_id => work_package} %></td> <td><%= link_to pluralize(c.units, c.cost_type.unit, c.cost_type.unit_plural), {:controller => "/costlog", :action => "index", :cost_type_id => c.cost_type, :work_package_id => work_package} %></td>
<td><%= c.cost_type %></td> <td><%= c.cost_type %></td>
<td class="currency"><%= c.costs_visible_by?(User.current) ? number_to_currency(c.real_costs) : "" %></td> <td class="currency"><%= c.costs_visible_by?(User.current) ? number_to_currency(c.real_costs) : "" %></td>
</tr> </tr>
<% end %> <% end %>
<% end %> <% end %>
<% if User.current.allowed_to?(:view_cost_rates, @project) %> <% if User.current.allowed_to?(:view_cost_rates, @project) %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.spent_material) %></strong></td></tr> <tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.spent_material) %></strong></td></tr>
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<div class="generic-table--header-background"></div> <div class="generic-table--header-background"></div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -180,161 +184,164 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<div class="grid-block"> <div class="grid-block">
<div class="grid-content"> <div class="grid-content">
<h4><%= VariableCostObject.human_attribute_name(:labor_budget)%></h4> <h4><%= VariableCostObject.human_attribute_name(:labor_budget)%></h4>
<div class="generic-table--container"> <div>
<div class="generic-table--results-container"> <div class="generic-table--container">
<table interactive-table role="grid" class="generic-table labor_budget_items"> <div class="generic-table--results-container">
<colgroup> <table interactive-table role="grid" class="generic-table labor_budget_items">
<col highlight-col> <colgroup>
<col highlight-col> <col highlight-col>
<col highlight-col> <col highlight-col>
<col highlight-col> <col highlight-col>
</colgroup> <col highlight-col>
<thead> </colgroup>
<tr> <thead>
<th> <tr>
<div class="generic-table--sort-header-outer"> <th>
<div class="generic-table--sort-header"> <div class="generic-table--sort-header-outer">
<span> <div class="generic-table--sort-header">
<%= LaborBudgetItem.human_attribute_name(:hours) %> <span>
</span> <%= LaborBudgetItem.human_attribute_name(:hours) %>
</span>
</div>
</div> </div>
</div> </th>
</th> <th>
<th> <div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header-outer"> <div class="generic-table--sort-header">
<div class="generic-table--sort-header"> <span>
<span> <%= LaborBudgetItem.human_attribute_name(:user) %>
<%= LaborBudgetItem.human_attribute_name(:user) %> </span>
</span> </div>
</div> </div>
</div> </th>
</th> <th>
<th> <div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header-outer"> <div class="generic-table--sort-header">
<div class="generic-table--sort-header"> <span>
<span> <%= LaborBudgetItem.human_attribute_name(:comment) %>
<%= LaborBudgetItem.human_attribute_name(:comment) %> </span>
</span> </div>
</div> </div>
</div> </th>
</th> <th class="currency">
<th class="currency"> <div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header-outer"> <div class="generic-table--sort-header">
<div class="generic-table--sort-header"> <span>
<span> <%= LaborBudgetItem.human_attribute_name(:budget) %>
<%= LaborBudgetItem.human_attribute_name(:budget) %> </span>
</span> </div>
</div> </div>
</div> </th>
</th> </tr>
</tr> </thead>
</thead> <tbody>
<tbody> <% @cost_object.labor_budget_items.each do |labor_budget_item| %>
<% @cost_object.labor_budget_items.each do |labor_budget_item| %> <tr>
<tr> <td class="hours"><%= labor_budget_item.hours %>h</td>
<td class="hours"><%= labor_budget_item.hours %>h</td> <td><%=h labor_budget_item.user.name %></td>
<td><%=h labor_budget_item.user.name %></td> <td class="comments"><%=h labor_budget_item.comments %></td>
<td class="comments"><%=h labor_budget_item.comments %></td> <% if labor_budget_item.costs_visible_by?(User.current) %>
<% if labor_budget_item.costs_visible_by?(User.current) %> <td class="currency">
<td class="currency"> <%= number_to_currency(labor_budget_item.costs)%>
<%= number_to_currency(labor_budget_item.costs)%> </td>
</td> <% else %>
<% else %> <td></td>
<td></td> <% end %>
</tr>
<% end %> <% end %>
</tr> <% if User.current.allowed_to?(:view_hourly_rates, @project) || User.current.allowed_to?(:view_own_hourly_rate, @project) %>
<% end %> <tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.labor_budget) %></strong></td></tr>
<% if User.current.allowed_to?(:view_hourly_rates, @project) || User.current.allowed_to?(:view_own_hourly_rate, @project) %> <% end %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.labor_budget) %></strong></td></tr> </tbody>
<% end %> </table>
</tbody> <div class="generic-table--header-background"></div>
</table> </div>
<div class="generic-table--header-background"></div>
</div> </div>
</div> </div>
</div> </div>
<div class="grid-content"> <div class="grid-content">
<h4><%= l(:caption_labor_costs) %></h4> <h4><%= l(:caption_labor_costs) %></h4>
<div class="generic-table--container"> <div>
<div class="generic-table--results-container"> <div class="generic-table--container">
<table interactive-table role="grid" class="generic-table labor_budget_items"> <div class="generic-table--results-container">
<colgroup> <table interactive-table role="grid" class="generic-table labor_budget_items">
<col highlight-col> <colgroup>
<col highlight-col> <col highlight-col>
<col highlight-col> <col highlight-col>
<col highlight-col> <col highlight-col>
</colgroup> <col highlight-col>
<thead> </colgroup>
<tr> <thead>
<th> <tr>
<div class="generic-table--sort-header-outer"> <th>
<div class="generic-table--sort-header"> <div class="generic-table--sort-header-outer">
<span> <div class="generic-table--sort-header">
<%= TimeEntry.human_attribute_name(:work_package) %> <span>
</span> <%= TimeEntry.human_attribute_name(:work_package) %>
</span>
</div>
</div> </div>
</div> </th>
</th> <th>
<th> <div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header-outer"> <div class="generic-table--sort-header">
<div class="generic-table--sort-header"> <span>
<span> <%= TimeEntry.human_attribute_name(:hours) %>
<%= TimeEntry.human_attribute_name(:hours) %> </span>
</span> </div>
</div> </div>
</div> </th>
</th> <th>
<th> <div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header-outer"> <div class="generic-table--sort-header">
<div class="generic-table--sort-header"> <span>
<span> <%= TimeEntry.human_attribute_name(:user) %>
<%= TimeEntry.human_attribute_name(:user) %> </span>
</span> </div>
</div> </div>
</div> </th>
</th> <th class="currency">
<th class="currency"> <div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header-outer"> <div class="generic-table--sort-header">
<div class="generic-table--sort-header"> <span>
<span> <%= TimeEntry.human_attribute_name(:costs) %>
<%= TimeEntry.human_attribute_name(:costs) %> </span>
</span> </div>
</div> </div>
</div> </th>
</th> </tr>
</tr> </thead>
</thead> <tbody>
<tbody> <% @cost_object.time_entries.visible(User.current, @project).group_by(&:work_package).each do |work_package, time_entries|
<% @cost_object.time_entries.visible(User.current, @project).group_by(&:work_package).each do |work_package, time_entries| entries = time_entries.inject(Hash.new) do |results, entry|
entries = time_entries.inject(Hash.new) do |results, entry| result = results[entry.user.id.to_s]
result = results[entry.user.id.to_s] unless result
unless result result = TimeEntry.new(:user => entry.user, :overridden_costs => 0)
result = TimeEntry.new(:user => entry.user, :overridden_costs => 0) result.hours = 0
result.hours = 0 results[entry.user.id.to_s] = result
results[entry.user.id.to_s] = result end
end
result.overridden_costs += entry.real_costs result.overridden_costs += entry.real_costs
result.hours += entry.hours result.hours += entry.hours
results results
end.values end.values
entries.each do |t| entries.each do |t|
%> %>
<tr> <tr>
<td class="subject"><%= link_to_work_package work_package %></td> <td class="subject"><%= link_to_work_package work_package %></td>
<td class="hours"><%= link_to "#{t.hours}h", {:controller => "/timelog", :action => "index", :work_package_id => work_package} %></td> <td class="hours"><%= link_to "#{t.hours}h", {:controller => "/timelog", :action => "index", :work_package_id => work_package} %></td>
<td><%=h t.user.name %></td> <td><%=h t.user.name %></td>
<td class="currency"><%= number_to_currency(t.real_costs) %></td> <td class="currency"><%= number_to_currency(t.real_costs) %></td>
</tr> </tr>
<% end %>
<% end %> <% end %>
<% end %> <tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.spent_labor) %></strong></td></tr>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.spent_labor) %></strong></td></tr>
</tbody> </tbody>
</table> </table>
<div class="generic-table--header-background"></div> <div class="generic-table--header-background"></div>
</div>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save