このコミットが含まれているのは:
@@ -10,7 +10,21 @@ class CountsPivotLayout
|
||||
(1...keys.length).select { order.first(_1).sort == keys.first(_1).sort }
|
||||
end
|
||||
|
||||
def self.headers(values, depths, next_values: nil, grand: false)
|
||||
def self.label_key(row_count, column_count, row_depth, column_depth)
|
||||
total = row_count + column_count
|
||||
collapsed = total - row_depth - column_depth
|
||||
return nil if collapsed.zero?
|
||||
return 'grandTotal' if total >= 3 && collapsed == total
|
||||
if (collapsed == 1 &&
|
||||
((row_count > 1 && row_depth < row_count) ||
|
||||
(column_count > 1 && column_depth < column_count)))
|
||||
return 'subtotal'
|
||||
end
|
||||
'singleTotal'
|
||||
end
|
||||
|
||||
def self.headers(values, depths, next_values: nil, grand: false, axis_count: nil,
|
||||
other_count: 0, direction: :row)
|
||||
result = []
|
||||
values.each_with_index do |tuple, index|
|
||||
result << { values: tuple, kind: 'data' }
|
||||
@@ -23,6 +37,15 @@ class CountsPivotLayout
|
||||
end
|
||||
end
|
||||
result << { values: [], kind: 'grand_total' } if grand
|
||||
count = axis_count || values.first&.length || 0
|
||||
result.each do |header|
|
||||
depth = header[:values].length
|
||||
label = if header[:kind] != 'data'
|
||||
direction == :row ? label_key(count, other_count, depth, other_count) :
|
||||
label_key(other_count, count, other_count, depth)
|
||||
end
|
||||
header.merge!(depth:, axis_count: count, label_key: label)
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする