Commit b774dc60 authored by jasonych99's avatar jasonych99
Browse files

Add Report Label - LIB

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