Module: Faalis::DashboardHelper
- Defined in:
- app/helpers/faalis/dashboard_helper.rb
Instance Method Summary collapse
- #action_buttons(buttons) ⇒ Object
- #draw_menu(menu) ⇒ Object
-
#get_url(route_name, id = nil, engine = Rails.application) ⇒ Object
Translate route name to url dynamically.
- #link_button(title, **options) ⇒ Object
- #localized_time(time) ⇒ Object
Instance Method Details
#action_buttons(buttons) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 28 def () = '' .each do || href = .fetch(:href, '#') klass = .fetch(:class, 'btn-success') remote = .fetch(:remote, false).to_s icons = .fetch(:icon_class, "") label = .fetch(:label, '') model = .fetch(:model, nil) action = .fetch(:policy, nil) with_policy(model, action) do += "<a class='action-button btn pull-right " + "#{klass}' href='#{href}' data-remote='#{remote}'"+ "data-disable-with='#{spinner} #{label}'>\n" + "<i class='fa fa-#{icons}'></i>" + label + '</a>' end end .html_safe end |
#draw_menu(menu) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 58 def () klass = .class || '' klass += 'treeview' if .children? href = .url || '#' result = "<li class='#{klass}'> \ <a href='#{href}'> \ <i class='#{.icon}'></i> <span>#{.title}</span> <span class='label label-primary pull-right'>4</span> </a>" if .respond_to? :children result += "<ul class='treeview-menu slide'>" .children.each do || result += "<li>\ <a href='#{.url}'> <i class='#{.icon}'></i> #{.title} </a>" result += result += '</li>' end result += '</ul>' end end |
#get_url(route_name, id = nil, engine = Rails.application) ⇒ Object
Translate route name to url dynamically
53 54 55 56 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 53 def get_url(route_name, id = nil, engine = Rails.application) return engine.routes.url_helpers.send(route_name, { id: id.to_s }) unless id.nil? engine.routes.url_helpers.send(route_name) end |
#link_button(title, **options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 9 def (title, **) classes = "btn pull-right btn-sm #{.fetch(:classes, '')}" icon_class = [:icon_class] href = .fetch(:href, '#') remote = .fetch(:remote, false).to_s = "<a class='#{classes}' href='#{href}'" + "data-disable-with='#{title} . . .' data-remote='#{remote}'" + "data-disable-class='disabled'>" if icon_class += "<i class='fa fa-#{icon_class}'></i>" end += title + '</a>' .html_safe end |
#localized_time(time) ⇒ Object
4 5 6 7 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 4 def localized_time(time) # Fixme: Setup and use Rails l10n time.strftime("%Y-%m-%d %H:%M") end |