Module: SerialsHelper

Defined in:
app/helpers/serials_helper.rb

Instance Method Summary collapse

Instance Method Details

#serial_autocomplete_tag(serial, term = '') ⇒ Object



8
9
10
11
12
13
14
15
# File 'app/helpers/serials_helper.rb', line 8

def serial_autocomplete_tag(serial, term = '')
  return nil if serial.nil?
  [ serial.name.gsub(/#{Regexp.escape(term)}/, "<mark>#{term}</mark>"), 
    (:span, "Project uses: #{Serial.joins(sources: [:project_sources]).where('project_sources.project_id = ? and serials.id = ?', sessions_current_project_id, serial.id).count}", class: [:feedback, 'feedback-primary', 'feedback-thin']),
    (:span, "All uses: #{serial.sources.count}", class: [:feedback, 'feedback-secondary', 'feedback-thin'])

  ].join('&nbsp;').html_safe
end

#serial_for_select(serial) ⇒ Object



26
27
28
# File 'app/helpers/serials_helper.rb', line 26

def serial_for_select(serial)
  serial.name if serial
end


17
18
19
20
# File 'app/helpers/serials_helper.rb', line 17

def serial_link(serial)
  return nil if serial.nil?
  link_to(serial_tag(serial).html_safe, serial)
end

#serial_tag(serial) ⇒ Object



3
4
5
6
# File 'app/helpers/serials_helper.rb', line 3

def serial_tag(serial)
  return nil if serial.nil?
  serial.name
end

#serials_search_formObject



22
23
24
# File 'app/helpers/serials_helper.rb', line 22

def serials_search_form
  render('/serials/quick_search_form')
end