Module: BatchLoad::BatchLoadHelper
- Defined in:
- app/helpers/batch_load/batch_load_helper.rb
Instance Method Summary collapse
- #batch_all_objects_count_td(rp) ⇒ Object
- #batch_data_created_td(rp) ⇒ Object
- #batch_data_errors_td(rp, sep = '; ') ⇒ Object
- #batch_line_link_td(line) ⇒ Object
- #batch_otu_name_td(otu) ⇒ Object
- #batch_parse_errors_td(rp, sep = '; ') ⇒ Object
- #batch_valid_objects_td(rp) ⇒ Object
- #warn_level_input(result) ⇒ Object
Instance Method Details
#batch_all_objects_count_td(rp) ⇒ Object
69 70 71 |
# File 'app/helpers/batch_load/batch_load_helper.rb', line 69 def batch_all_objects_count_td(rp) tag.td rp.total_objects end |
#batch_data_created_td(rp) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/batch_load/batch_load_helper.rb', line 13 def batch_data_created_td(rp) content_tag :td do content_tag :table do rp.objects.collect { |klass, objs| content_tag(:tr, content_tag(:td, klass), class: 'underlined_elements') + objs.collect { |o| content_tag( :tr, content_tag( :td, o.persisted? ? object_link(o) : content_tag(:span, object_tag(o), class: 'feedback feedback-warning') ) ) }.join.html_safe }.join.html_safe end end end |
#batch_data_errors_td(rp, sep = '; ') ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/batch_load/batch_load_helper.rb', line 31 def batch_data_errors_td(rp, sep = '; ') errors = {} rp.objects.each do |klass, objs| objs.each do |o| if !o.valid? errors[klass] ||= [] errors[klass].push o.errors..join(sep) end end end content_tag(:td) do content_tag(:table, border: true) do errors.collect { |klass, objs| content_tag(:tr, content_tag(:th, klass) + objs.collect { |o| content_tag(:tr, content_tag(:td, o, class: 'feedback feedback-thin feedback-warning').html_safe) }.join.html_safe ) }.join.html_safe end end end |
#batch_line_link_td(line) ⇒ Object
73 74 75 |
# File 'app/helpers/batch_load/batch_load_helper.rb', line 73 def batch_line_link_td(line) content_tag(:td, link_to(line, "#line_#{line}", id: "parse_#{line}", data: {'turbolinks': false}).html_safe) end |
#batch_otu_name_td(otu) ⇒ Object
77 78 79 80 81 82 83 |
# File 'app/helpers/batch_load/batch_load_helper.rb', line 77 def batch_otu_name_td(otu) if otu.present? content_tag(:td, "'#{otu.name}'" + (otu.new_record? ? '<br>(New)' : '').html_safe) else ('<td></td>').html_safe end end |
#batch_parse_errors_td(rp, sep = '; ') ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'app/helpers/batch_load/batch_load_helper.rb', line 55 def batch_parse_errors_td(rp, sep = '; ') if rp.parse_errors.present? tag.td( tag.span(rp.parse_errors.join(sep).html_safe, class: [:feedback,'feedback-thin', 'feedback-danger']) ) else tag.td end end |
#batch_valid_objects_td(rp) ⇒ Object
65 66 67 |
# File 'app/helpers/batch_load/batch_load_helper.rb', line 65 def batch_valid_objects_td(rp) tag.td(rp.has_valid_objects? ? rp.valid_objects.length : 0) end |
#warn_level_input(result) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/helpers/batch_load/batch_load_helper.rb', line 3 def warn_level_input(result) str = 'Import level:<br> ' = [(:import_level, :warn, selected: true) + ' warn'] << (:import_level, :line_strict) + ' line strict' if result.line_strict_level_ok? << (:import_level, :strict) + ' strict' if result.strict_level_ok? str += .join('<br> ').html_safe content_tag(:div, str.html_safe) end |