Module: EffectiveResourcesHelper

Defined in:
app/helpers/effective_resources_helper.rb

Instance Method Summary collapse

Instance Method Details

#approve_icon_to(path, options = {}) ⇒ Object



54
55
56
# File 'app/helpers/effective_resources_helper.rb', line 54

def approve_icon_to(path, options = {})
  glyphicon_to('ok', path, {title: 'Approve'}.merge(options))
end

#destroy_icon_to(path, options = {}) ⇒ Object



41
42
43
44
# File 'app/helpers/effective_resources_helper.rb', line 41

def destroy_icon_to(path, options = {})
  defaults = {title: 'Destroy', data: {method: :delete, confirm: 'Delete this item?'}}
  glyphicon_to('trash', path, defaults.merge(options))
end

#edit_icon_to(path, options = {}) ⇒ Object



37
38
39
# File 'app/helpers/effective_resources_helper.rb', line 37

def edit_icon_to(path, options = {})
  glyphicon_to('edit', path, {title: 'Edit'}.merge(options))
end

#glyphicon_to(icon, path, options = {}) ⇒ Object Also known as: bootstrap_icon_to, glyph_icon_to



62
63
64
65
66
67
68
69
70
# File 'app/helpers/effective_resources_helper.rb', line 62

def glyphicon_to(icon, path, options = {})
  (:a, options.merge(href: path)) do
    if icon.start_with?('glyphicon-')
      (:span, '', class: "glyphicon #{icon}")
    else
      (:span, '', class: "glyphicon glyphicon-#{icon}")
    end
  end
end

#number_to_duration(duration) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/effective_resources_helper.rb', line 20

def number_to_duration(duration)
  duration = duration.to_i
  value = duration.abs

  [
    ('-' if duration < 0),
    ("#{value / 60}h " if value >= 60),
    ("#{'%0.2d' % (value % 60)}m" if value > 0),
    ('0m' if value == 0),
  ].compact.join
end

#ok_icon_to(path, options = {}) ⇒ Object



50
51
52
# File 'app/helpers/effective_resources_helper.rb', line 50

def ok_icon_to(path, options = {})
  glyphicon_to('ok', path, {title: 'OK'}.merge(options))
end

#remove_icon_to(path, options = {}) ⇒ Object



58
59
60
# File 'app/helpers/effective_resources_helper.rb', line 58

def remove_icon_to(path, options = {})
  glyphicon_to('remove', path, {title: 'Remove'}.merge(options))
end

#settings_icon_to(path, options = {}) ⇒ Object



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

def settings_icon_to(path, options = {})
  glyphicon_to('cog', path, {title: 'Settings'}.merge(options))
end

#show_icon_to(path, options = {}) ⇒ Object

Icon Helpers for actions_column or elsewhere



33
34
35
# File 'app/helpers/effective_resources_helper.rb', line 33

def show_icon_to(path, options = {})
  glyphicon_to('eye-open', path, {title: 'Show'}.merge(options))
end

#simple_form_save(form, options = {class: 'text-right'}, &block) ⇒ Object



14
15
16
17
18
# File 'app/helpers/effective_resources_helper.rb', line 14

def simple_form_save(form, options = {class: 'text-right'}, &block)
  (:p, class: options[:class]) do
    form.button(:submit, 'Save', data: { disable_with: 'Saving...' }) + (capture(&:block) if block_given?)
  end
end

#simple_form_submit(form, options = {class: 'text-right'}, &block) ⇒ Object



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

def simple_form_submit(form, options = {class: 'text-right'}, &block)
  (:p, class: options[:class]) do
    [
      form.button(:submit, 'Save', data: { disable_with: 'Saving...' }),
      form.button(:submit, 'Save and Continue', data: { disable_with: 'Saving...' }),
      form.button(:submit, 'Save and Add New', data: { disable_with: 'Saving...' }),
      (capture(&block) if block_given?)
    ].compact.join(' ').html_safe
  end
end