Module: PraisesHelper

Defined in:
app/helpers/praises_helper.rb

Instance Method Summary collapse

Instance Method Details



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

def create_praise_links(options={})
  Praise.praise_types.keys.map do |praise_type|
    _options = options.dup
    label = case(praise_type)
    when 'employee_praise'
      fa_icon('bullhorn', text: "New Shoutout")
    else
      "New #{praise_type.titleize}"
    end

    link_params = { praise: { praise_type: praise_type } }.deep_merge(_options.delete(:link_params) || {})
    link_to( label, new_praise_path( link_params ), **_options )
  end
end

#new_praise_buttonObject



22
23
24
25
26
# File 'app/helpers/praises_helper.rb', line 22

def new_praise_button
  render_simple_drop_down praises_command_options,
                              main_link_class: 'btn-primary btn-sm',
                              dropdown_options: { class: 'dropdown-menu dropdown-menu-end' }
end


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/praises_helper.rb', line 28

def praise_attachment_link(praise, thumbnail_size: nil)
  return unless praise.image&.stored?

  if praise.image.mime_type =~ /^image/
    if thumbnail_size
      thumbnail_url = praise.image.thumb(thumbnail_size).url
    else
      thumbnail_url = praise.image.url
    end
    link_to(image_tag(thumbnail_url, class: 'img-fluid'), praise.image.url, class: "thumbnail", data: { fancybox: 'praise-gallery', type: 'image' })
  else
    link_to(praise.image_name, praise.image.url, data: { fancybox: 'praise-gallery', type: 'iframe' })
  end
rescue Dragonfly::Job::Fetch::NotFound => exc
rescue StandardError => exc
end

#praises_command_optionsObject



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

def praises_command_options
  ["Create New"] + create_praise_links
end