Commit b774dc60 authored by jasonych99's avatar jasonych99
Browse files

Add Report Label - LIB

parent 0cf47e00
......@@ -7,6 +7,7 @@ module Reporter
@font_family = args[:font_family]
@index = args[:index] || 0
@template = args[:template]
@mol_serials = args[:mol_serials] || []
end
def content
......@@ -72,17 +73,16 @@ module Reporter
end
def synthesis_title_delta
delta = [{"insert"=>"[4.#{@index + 1}] "}]
delta = [{ 'insert' => "[4.#{@index + 1}] " }]
obj.products.each do |p|
delta = delta +
sample_molecule_name_delta(p) +
[{"insert"=>" / "}]
sample_molecule_name_delta(p) +
[{ 'insert' => ' (' }] +
mol_serial_delta(p[:molecule][:id]) +
[{ 'insert' => ')' }] +
[{ 'insert' => ', ' }]
end
delta.pop
delta = delta +
[{"insert"=>" ("}] +
[{"attributes"=>{"bold"=>"true"}, "insert"=>"xx"}] +
[{"insert"=>")"}]
delta
end
......@@ -394,7 +394,7 @@ module Reporter
m = material_hash(material, false)
counter += 1
delta += [{"insert"=>"{#{alphabet(counter)}|"},
{"attributes"=>{"bold"=>"true"}, "insert"=>"xx"},
*mol_serial_delta(material[:molecule][:id]),
{"insert"=>"} "},
*sample_molecule_name_delta(m),
{"insert"=>" (#{m[:mass]} g, #{m[:mol]} mmol, " +
......@@ -413,7 +413,7 @@ module Reporter
p = material_hash(material, true)
counter += 1
delta += [{"insert"=>"{#{alphabet(counter)}|"},
{"attributes"=>{"bold"=>"true"}, "insert"=>"xx"},
*mol_serial_delta(material[:molecule][:id]),
{"insert"=>"} = #{p[:equiv]} (#{p[:mass]} g, " +
"#{p[:mol]} mmol)"},
{"insert"=>"; "}]
......@@ -473,6 +473,16 @@ module Reporter
counter = counter >= 1 && counter <=26 ? counter - 1 : 25
alphabets[counter]
end
def mol_serial(mol_id)
s = @mol_serials.select { |x| x['mol'] && x['mol']['id'] == mol_id }[0]
s.present? && s['value'].present? && s['value'] || 'xx'
end
def mol_serial_delta(mol_id)
serial = mol_serial(mol_id)
[{ 'insert' => serial }]
end
end
end
end
......@@ -11,6 +11,7 @@ module Reporter
@img_format = args[:img_format]
@font_family = args[:font_family]
@template = args[:template]
@mol_serials = args[:mol_serials]
end
def convert
......@@ -33,7 +34,8 @@ module Reporter
last_id: last_id,
img_format: @img_format,
font_family: @font_family,
template: @template
template: @template,
mol_serials: @mol_serials,
).content
end
......
......@@ -16,7 +16,8 @@ module Reporter
configs: @configs,
img_format: img_format,
font_family: "Times New Roman",
template: "supporting_information"
template: "supporting_information",
mol_serials: @mol_serials
).convert
end
......@@ -28,7 +29,8 @@ module Reporter
configs: procedure_config,
img_format: img_format,
font_family: "Times New Roman",
template: "supporting_information"
template: "supporting_information",
mol_serials: @mol_serials
).convert
end
......
......@@ -10,6 +10,7 @@ module Reporter
@configs = @report.configs
@img_format = @report.img_format
@template_path = args[:template_path]
@mol_serials = @report.mol_serials
end
def process
......
Supports Markdown
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