Fix quantity header borders
This commit is contained in:
parent
7d096748bf
commit
53e8db20d1
@ -58,7 +58,7 @@ module BodyTrackersHelper
|
||||
# ordered the way they were added). Hash values determine cell property:
|
||||
# * int > 0 - quantity name-labelled cell with 'int' size colspan
|
||||
# * int < 0 - quantity name-labelled cell with 'int' size rowspan
|
||||
# * nil - non-labelled cell without col-/rowspan
|
||||
# * 0 - non-labelled cell without col-/rowspan
|
||||
spec = []
|
||||
default_row = Hash.new(0)
|
||||
|
||||
@ -68,16 +68,16 @@ module BodyTrackersHelper
|
||||
spec[i] ||= default_row.dup
|
||||
spec[i][a] += 1
|
||||
end
|
||||
spec[ancestors.length...spec.length].each { |row| row[ancestors.last] = nil }
|
||||
default_row[ancestors.last] = nil
|
||||
spec[ancestors.length...spec.length].each { |row| row[ancestors.last] = 0 }
|
||||
default_row[ancestors.last] = 0
|
||||
end
|
||||
|
||||
# ...then rowspans
|
||||
single_columns = []
|
||||
spec[1..-1].each_with_index do |row, i|
|
||||
row.each do |q, span|
|
||||
# Current span is nil and previous span == 1
|
||||
if span.nil? && (spec[i][q] == 1)
|
||||
# Current span is 0 and previous span == 1
|
||||
if (span == 0) && (spec[i][q] == 1)
|
||||
spec[i][q] = -(spec.length - i)
|
||||
single_columns << q
|
||||
end
|
||||
|
@ -21,14 +21,14 @@
|
||||
|
||||
<% row.each do |q, span| %>
|
||||
<% row_classes = [] %>
|
||||
<% row_classes << 'quantity' unless i == header.length-1 %>
|
||||
<% row_classes << 'empty' unless span %>
|
||||
<% row_classes << 'quantity' if (i < header.length-1) && (span >= 0) %>
|
||||
<% row_classes << 'empty' if span == 0 %>
|
||||
<th <%= raw "class=\"#{row_classes.join(' ')}\"" unless row_classes.empty? %>
|
||||
<%= "colspan=#{span}" if span && span > 0 %>
|
||||
<%= "rowspan=#{-span}" if span && span < 0 %>
|
||||
style="width: <%= (span && span > 0 ? span : 1) * 100/total_width %>%;"
|
||||
<%= "colspan=#{span}" if span > 0 %>
|
||||
<%= "rowspan=#{-span}" if span < 0 %>
|
||||
style="width: <%= [span, 1].max * 100/total_width %>%;"
|
||||
title="<%= q.description %>">
|
||||
<%= q.name if span %>
|
||||
<%= q.name unless span == 0 %>
|
||||
</th>
|
||||
<% end %>
|
||||
|
||||
|
Reference in New Issue
Block a user