Module: Elabs::LinksHelper

Defined in:
app/helpers/elabs/links_helper.rb

Instance Method Summary collapse

Instance Method Details

#entity_nested_resource_url(entity, nested_type) ⇒ Object



45
46
47
48
# File 'app/helpers/elabs/links_helper.rb', line 45

def entity_nested_resource_url(entity, nested_type)
  entity_type = singular_type_name entity
  send "#{entity_type}_#{nested_type}_url", entity
end


33
34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/elabs/links_helper.rb', line 33

def namespace_destroy_link(namespace, singular_model, entity, confirm = true)
  link_params = {
    title:  _('Destroy'),
    method: :delete,
    class:  'btn btn--small btn--destroy'
  }
  link_params[:data] = { confirm: _('Are you sure?') } if confirm
  link_to send("#{namespace}_#{singular_model}_path".to_sym, entity), link_params do
    icon('trash', ['fw'])
  end
end


25
26
27
28
29
30
31
# File 'app/helpers/elabs/links_helper.rb', line 25

def namespace_edit_link(namespace, singular_model, entity)
  link_to send("edit_#{namespace}_#{singular_model}_path", entity),
          title: _('Edit'),
          class: 'btn btn--small btn--edit' do
    icon('pencil-alt', ['fw'])
  end
end


17
18
19
20
21
22
23
# File 'app/helpers/elabs/links_helper.rb', line 17

def namespace_show_link(namespace, singular_model, entity)
  link_to send("#{namespace}_#{singular_model}_path", entity),
          title: _('View'),
          class: 'btn btn--small btn--warning' do
    icon('eye', ['fw'])
  end
end


50
51
52
53
54
55
56
# File 'app/helpers/elabs/links_helper.rb', line 50

def related_content_show_all_link(amount, link)
  if amount.positive?
    link_to(_('Show all'), link, class: 'btn btn--small btn--link btn--primary')
  else
    ('a', _('Show all'), disabled: true, class: 'btn btn--small btn--link')
  end
end


3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/elabs/links_helper.rb', line 3

def show_online_link(entity)
  options = {
    title: _('View online'),
    class: 'btn btn--small btn--show'
  }
  if entity.respond_to?(:publicly_visible?) && !entity.publicly_visible?
    options[:disabled] = true
    return  'a', icon('eye', ['fw']), options
  end
  link_to entity, options do
    icon('eye', ['fw'])
  end
end