Module: BiovisionHelper

Defined in:
app/helpers/biovision_helper.rb

Instance Method Summary collapse

Instance Method Details

#back_icon(path, title = t(:back), options = {}) ⇒ Object

Parameters:

  • path (String)
  • title (String) (defaults to: t(:back))
  • options (Hash) (defaults to: {})


39
40
41
# File 'app/helpers/biovision_helper.rb', line 39

def back_icon(path, title = t(:back), options = {})
  icon_with_link('biovision/base/icons/back.svg', path, title, options)
end

#create_icon(path, title = t(:create), options = {}) ⇒ Object

Parameters:

  • path (String)
  • title (String) (defaults to: t(:create))
  • options (Hash) (defaults to: {})


32
33
34
# File 'app/helpers/biovision_helper.rb', line 32

def create_icon(path, title = t(:create), options = {})
  icon_with_link('biovision/base/icons/create.svg', path, title, options)
end

#destroy_icon(entity, title = t(:delete), options = {}) ⇒ Object

Parameters:

  • entity (ApplicationRecord)
  • title (String) (defaults to: t(:delete))
  • options (Hash) (defaults to: {})


60
61
62
63
64
65
66
# File 'app/helpers/biovision_helper.rb', line 60

def destroy_icon(entity, title = t(:delete), options = {})
  default = {
    method: :delete,
    data:   { confirm: t(:are_you_sure), tootik: title, tootik_conf: 'danger' }
  }
  icon_with_link('biovision/base/icons/destroy.svg', entity, title, default.merge(options))
end

#destroy_path_icon(path, title = t(:delete), options = {}) ⇒ Object

Parameters:

  • path (String)
  • title (String) (defaults to: t(:delete))
  • options (Hash) (defaults to: {})


71
72
73
74
75
76
77
# File 'app/helpers/biovision_helper.rb', line 71

def destroy_path_icon(path, title = t(:delete), options = {})
  default = {
    method: :delete,
    data:   { confirm: t(:are_you_sure), tootik: title, tootik_conf: 'danger' }
  }
  icon_with_link('biovision/base/icons/destroy.svg', path, title, default.merge(options))
end

#edit_icon(path, title = t(:edit), options = {}) ⇒ Object

Parameters:

  • path (String)
  • title (String) (defaults to: t(:edit))
  • options (Hash) (defaults to: {})


53
54
55
# File 'app/helpers/biovision_helper.rb', line 53

def edit_icon(path, title = t(:edit), options = {})
  icon_with_link('biovision/base/icons/edit.svg', path, title, options)
end

#gear_icon(path, title = t(:view_as_administrator), options = {}) ⇒ Object

Parameters:

  • path (String)
  • title (String) (defaults to: t(:view_as_administrator))
  • options (Hash) (defaults to: {})


25
26
27
# File 'app/helpers/biovision_helper.rb', line 25

def gear_icon(path, title = t(:view_as_administrator), options = {})
  icon_with_link('biovision/base/icons/gear.svg', path, title, options)
end

Parameters:



82
83
84
85
# File 'app/helpers/biovision_helper.rb', line 82

def icon_with_link(source, path, title, options = {})
  default = { data: { tootik: title } }
  link_to(image_tag(source, alt: title), path, default.merge(options))
end

#lock_icons(entity, path) ⇒ Object

Parameters:



89
90
91
# File 'app/helpers/biovision_helper.rb', line 89

def lock_icons(entity, path)
  render partial: 'shared/actions/locks', locals: { path: path, entity: entity }
end

#return_icon(path, title = t(:back), options = {}) ⇒ Object

Parameters:

  • path (String)
  • title (String) (defaults to: t(:back))
  • options (Hash) (defaults to: {})


46
47
48
# File 'app/helpers/biovision_helper.rb', line 46

def return_icon(path, title = t(:back), options = {})
  icon_with_link('biovision/base/icons/return.svg', path, title, options)
end

#title_for_archive(year, month) ⇒ Object

Parameters:

  • year (Integer)
  • month (Integer)


4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/biovision_helper.rb', line 4

def title_for_archive(year, month)
  if year && month
    month_name = t('date.nominative_months')[month.to_i]
    t(:archive_month, year: year.to_i, month: month_name)
  elsif year
    t(:archive_year, year: year.to_i)
  else
    ''
  end
end

#world_icon(path, title = t(:view_as_visitor), options = {}) ⇒ Object

Parameters:

  • path (String)
  • title (String) (defaults to: t(:view_as_visitor))
  • options (Hash) (defaults to: {})


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

def world_icon(path, title = t(:view_as_visitor), options = {})
  icon_with_link('biovision/base/icons/world.svg', path, title, options)
end