Module: Tasks::CollectingEvents::Parse::Stepwise::DatesHelper

Defined in:
app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) make_dates_matching_table(*pieces, collection)

“identical matches” result table

Parameters:

  • pieces (String)

    is either piece, or lat, long

  • collection (Scope)

    is a scope of CollectingEvent



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb', line 60

def make_dates_matching_table(*pieces, collection)
  columns = ['CEID', 'Match', 'Start Date', 'End Date', 'Verbatim Date', 'Select']

  thead = (:thead) do
    (:tr) do
      columns.collect { |column| concat (:th, column) }.join.html_safe
    end
  end

  tbody =  (:tbody) do
    collection.collect { |item|
       (:tr) do
        item_data = ''
        no_verbatim_date = false
        columns.collect.with_index { |column, dex|
          case dex
            when 0 #'CEID'
              item_data = link_to(item.id, item)
            when 1 #'Match'
              item_data = (:vl, pieces.join(' '))
            when 2 # 'Start Date'
              item_data = item.start_y_m_d_string
            when 3 # 'End Date'
              item_data = item.end_y_m_d_string
            when 4 #'Verbatim Date'
              item_data = (:vd, item.verbatim_date, data: {help: item.verbatim_label})
              no_verbatim_date = !item.verbatim_date.blank?
            when 5 #'Select'
              # check_box_tag(name, value = "1", checked = false, options = {}) public
              options_for = {disabled: no_verbatim_date}
              options_for[:class] = 'selectable_select' unless no_verbatim_date
              options_for[:data] = {help: item.verbatim_label}
              item_data = check_box_tag('selected[]', item.id, false, options_for)
          end
          concat (:td, item_data, align: 'center')
        }.to_s.html_safe
        # item.attributes.collect { |column|
        #   concat content_tag(:td, item.attributes[column])
        # }.to_s.html_safe
      end
    }.join().html_safe
  end

  (:table, thead.concat(tbody), {id: 'matching_table', border: '1'}).html_safe
end

- (Object) make_dates_method_headers



8
9
10
11
12
13
14
15
16
# File 'app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb', line 8

def make_dates_method_headers
  list = Utilities::Dates::REGEXP_DATES
  selector_row = ""
  list.keys.each_with_index {|kee, dex|
    selector_row += (:th, Utilities::Dates::REGEXP_DATES[kee][:hdr],
                                data: {help: Utilities::Dates::REGEXP_DATES[kee][:hlp]})
  }
  selector_row.html_safe
end

- (Object) make_dates_rows(label, filters)



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb', line 31

def make_dates_rows(label, filters)
  return nil if label.nil?
  tests = Utilities::Dates.hunt_dates(label, filters)
  tests.keys.collect.with_index do |kee, dex|
    trial = tests[kee]
    method = trial.delete(:method) # extract the method from the trial and save it
    next if trial.blank? # if this leaves the trial empty, skip
    # ActionController::Redirecting.redirect_to dates_index_task_path(collecting_event_id: next_collecting_event_id,
    #                                                                 filters: parse_filters(params))
    verbatim_date_piece = Utilities::Dates::make_verbatim_date_piece(label, trial[:piece])
    (:tr, class: :extract_row) do
      (:td, method, align: 'center', class: :method_value) +
          # content_tag(:td, kee == method ? '' : kee) +
          # content_tag(:td, trial[:piece], class: :piece_value, align: 'center') +
          (:td, verbatim_date_piece, class: :piece_value, align: 'center') +
          (:td, trial[:start_date], class: :start_date_value, align: 'center') +
          (:td, trial[:end_date], class: :end_date_value, align: 'center') +
          (:td, radio_button_tag('select', dex, false, class: :select_dates), align: 'center')
    end
  end.join.html_safe
  # tests.keys.each { |kee|
  # next if tests[kee]
  # }
  # @matching_items = {@collecting_event.id.to_s => tests.first[:piece]}
end

- (Object) make_dates_selected_method_boxes(filters = Utilities::Dates::REGEXP_DATES.keys)

Parameters:

  • must (Array)

    be array of symbols from Utilities::Dates::REGEXP_DATES.keys (optional)



20
21
22
23
24
25
26
27
28
# File 'app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb', line 20

def make_dates_selected_method_boxes(filters = Utilities::Dates::REGEXP_DATES.keys)
  list = Utilities::Dates::REGEXP_DATES
  box_row = ""
  list.keys.each { |kee|
    checked = filters.include?(kee)
    box_row += (:td, check_box_tag("filters[]", kee.to_s, checked), align: 'center')
  }
  box_row.html_safe
end

- (Object) parse_date_skip(current_collecting_event_id, filters)



122
123
124
125
126
127
128
129
130
131
132
133
# File 'app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb', line 122

def parse_date_skip(current_collecting_event_id, filters)
  # TODO: Now this has to be bound to next hit
  # filters = Utilities::Geo::REGEXP_COORD.keys
  next_id = Queries::CollectingEventDatesExtractorQuery.new(
      collecting_event_id: current_collecting_event_id,
      filters: filters).all.with_project_id(sessions_current_project_id).first.try(:id)
  if next_id
    button_tag('Skip to next record', value: 'skip', id: 'skip')
  else
    (:span, 'no more matches')
  end + button_tag('Re-evaluate', value: 're_eval', id: 're_eval')
end

- (Object) parse_label(label)



3
4
5
6
# File 'app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb', line 3

def parse_label(label)
  retval = Utilities::Dates.hunt_wrapper(label)
  retval
end

- (Object) scan_c_e



135
136
137
138
139
140
141
142
143
144
# File 'app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb', line 135

def scan_c_e
  pile = Queries::CollectingEventDatesExtractorQuery.new(
      collecting_event_id: 0,
      filters: DEFAULT_SQL_REGEXS).all.with_project_id(sessions_current_project_id).order(:id)
  pile.each { |c_e|
    trials = Utilities::Dates.hunt_dates_full(c_e.verbatim_label)
    puts(c_e.id)
  }
  pile
end

- (Object) show_ce_vl(collecting_event)



114
115
116
117
118
119
120
# File 'app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb', line 114

def show_ce_vl(collecting_event)
  message = 'No collecting event available.'
  unless collecting_event.nil?
    message = collecting_event.verbatim_label
  end
  collecting_event_label_tag(message)
end

- (Object) test_end_date



110
111
112
# File 'app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb', line 110

def test_end_date
  @collecting_event.end_y_m_d_string unless @collecting_event.nil?
end

- (Object) test_start_date

what is “test” about this?



106
107
108
# File 'app/helpers/tasks/collecting_events/parse/stepwise/dates_helper.rb', line 106

def test_start_date # what is "test" about this?
  @collecting_event.start_y_m_d_string unless @collecting_event.nil?
end