Module: EffectiveResourcesHelper
- Defined in:
- app/helpers/effective_resources_helper.rb
Instance Method Summary collapse
- #approve_icon_to(path, options = {}) ⇒ Object
- #destroy_icon_to(path, options = {}) ⇒ Object
- #edit_icon_to(path, options = {}) ⇒ Object
- #glyphicon_to(icon, path, options = {}) ⇒ Object (also: #bootstrap_icon_to, #glyph_icon_to)
- #number_to_duration(duration) ⇒ Object
- #ok_icon_to(path, options = {}) ⇒ Object
- #remove_icon_to(path, options = {}) ⇒ Object
- #settings_icon_to(path, options = {}) ⇒ Object
-
#show_icon_to(path, options = {}) ⇒ Object
Icon Helpers for actions_column or elsewhere.
- #simple_form_save(form, options = {class: 'text-right'}, &block) ⇒ Object
- #simple_form_submit(form, options = {class: 'text-right'}, &block) ⇒ Object
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, = {}) glyphicon_to('ok', path, {title: 'Approve'}.merge()) 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, = {}) defaults = {title: 'Destroy', data: {method: :delete, confirm: 'Delete this item?'}} glyphicon_to('trash', path, defaults.merge()) end |
#edit_icon_to(path, options = {}) ⇒ Object
37 38 39 |
# File 'app/helpers/effective_resources_helper.rb', line 37 def edit_icon_to(path, = {}) glyphicon_to('edit', path, {title: 'Edit'}.merge()) 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, = {}) content_tag(:a, .merge(href: path)) do if icon.start_with?('glyphicon-') content_tag(:span, '', class: "glyphicon #{icon}") else content_tag(: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, = {}) glyphicon_to('ok', path, {title: 'OK'}.merge()) end |
#remove_icon_to(path, options = {}) ⇒ Object
58 59 60 |
# File 'app/helpers/effective_resources_helper.rb', line 58 def remove_icon_to(path, = {}) glyphicon_to('remove', path, {title: 'Remove'}.merge()) end |
#settings_icon_to(path, options = {}) ⇒ Object
46 47 48 |
# File 'app/helpers/effective_resources_helper.rb', line 46 def settings_icon_to(path, = {}) glyphicon_to('cog', path, {title: 'Settings'}.merge()) 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, = {}) glyphicon_to('eye-open', path, {title: 'Show'}.merge()) 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, = {class: 'text-right'}, &block) content_tag(:p, class: [:class]) do form.(: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, = {class: 'text-right'}, &block) content_tag(:p, class: [:class]) do [ form.(:submit, 'Save', data: { disable_with: 'Saving...' }), form.(:submit, 'Save and Continue', data: { disable_with: 'Saving...' }), form.(:submit, 'Save and Add New', data: { disable_with: 'Saving...' }), (capture(&block) if block_given?) ].compact.join(' ').html_safe end end |