Commit e977cb42 by Ivan Lan

feat: 空保护 & update export spec

parent 1cfae215
...@@ -42,7 +42,7 @@ class TalltyImportExport::ExportPayload::Cell ...@@ -42,7 +42,7 @@ class TalltyImportExport::ExportPayload::Cell
end end
def divise def divise
if @header.children.present? if @header.children.present? && @value.value
new_cells = @header.children.map do |child_header| new_cells = @header.children.map do |child_header|
if (child_header.children.present?) if (child_header.children.present?)
val = @value.value[child_header.key.to_sym] val = @value.value[child_header.key.to_sym]
......
...@@ -9,7 +9,7 @@ class TalltyImportExport::ExportPayload::CellColumn ...@@ -9,7 +9,7 @@ class TalltyImportExport::ExportPayload::CellColumn
@cell_clusters = [] @cell_clusters = []
@value_handler = value_handler @value_handler = value_handler
if header.children if header.children && @value.value
@cell_clusters = (@value.value[header.key.to_sym] || []).map do |val| @cell_clusters = (@value.value[header.key.to_sym] || []).map do |val|
TalltyImportExport::ExportPayload::Cell.new( TalltyImportExport::ExportPayload::Cell.new(
@header, @header,
...@@ -46,7 +46,7 @@ class TalltyImportExport::ExportPayload::CellColumn ...@@ -46,7 +46,7 @@ class TalltyImportExport::ExportPayload::CellColumn
depth_to_cells_mapping = @flatten_cells.group_by { |cell| [cell.header.seq] } depth_to_cells_mapping = @flatten_cells.group_by { |cell| [cell.header.seq] }
@tallest_cell_cluster = depth_to_cells_mapping.values.max { |a, b| a.count <=> b.count } @tallest_cell_cluster = depth_to_cells_mapping.values.max { |a, b| a.count <=> b.count } || []
self self
end end
......
...@@ -82,7 +82,7 @@ RSpec.describe TalltyImportExport::Importable do ...@@ -82,7 +82,7 @@ RSpec.describe TalltyImportExport::Importable do
it 'export' do it 'export' do
# TalltyImportExport::ExportForm.new.export_workbook nil, [@payload], { headers: @header_h[:items] } # TalltyImportExport::ExportForm.new.export_workbook nil, [@payload], { headers: @header_h[:items] }
TalltyImportExport::ExportForm.new(nil).export_xlsx [@payload, @payload], { headers: @header_h[:items] } TalltyImportExport::ExportForm.new(nil).export_xlsx [@payload, nil, @payload], { headers: @header_h[:items] }
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment