Module: BatchLoad::BatchLoadHelper

Defined in:
app/helpers/batch_load/batch_load_helper.rb

Instance Method Summary collapse

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

Parameters:

  • rp


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)
   :td do
     :table do
      rp.objects.collect { |klass, objs|
        (:tr, (:td, klass), class: 'underlined_elements') +
          objs.collect { |o| (
            :tr,
            (
              :td,
              o.persisted? ? object_link(o) : (: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.full_messages.join(sep)
      end
    end
  end

  (:td) do
    (:table, border: true) do
      errors.collect { |klass, objs|
        (:tr, (:th, klass) +
                    objs.collect { |o|
                      (:tr, (:td, o, class: 'feedback feedback-thin feedback-warning').html_safe)
                    }.join.html_safe
                   )
      }.join.html_safe
    end
  end
end


73
74
75
# File 'app/helpers/batch_load/batch_load_helper.rb', line 73

def batch_line_link_td(line)
  (: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?
    (: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>&nbsp;'
  options = [radio_button_tag(:import_level, :warn, selected: true) + ' warn']
  options << radio_button_tag(:import_level, :line_strict) + ' line strict' if result.line_strict_level_ok?
  options << radio_button_tag(:import_level, :strict) + ' strict' if result.strict_level_ok?
  str += options.join('<br>&nbsp;').html_safe
  (:div, str.html_safe)
end