Module: Faalis::DashboardHelper
- Defined in:
- app/helpers/faalis/dashboard_helper.rb
Instance Method Summary collapse
- #action_buttons(buttons) ⇒ Object
- #draw_menu(menu) ⇒ Object
- #form_label(resource, name) ⇒ 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
Methods included from ActionView::Helpers::TranslationHelper
Methods included from Faalis::Dashboard::Helpers::BoxHelpers
Instance Method Details
#action_buttons(buttons) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 34 def () = '' .each do || href = .fetch(:href, '#') klass = .fetch(:class, 'btn-success') remote = .fetch(:remote, false).to_s icons = .fetch(:icon_class, "") label = .fetch(:name, '') 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
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 64 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 |
#form_label(resource, name) ⇒ Object
7 8 9 10 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 7 def form_label(resource, name) key = "forms.#{@resource.class.name.underscore.to_s.gsub('/', '.')}.#{name}" t(key) end |
#get_url(route_name, id = nil, engine = Rails.application) ⇒ Object
Translate route name to url dynamically
59 60 61 62 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 59 def get_url(route_name, id = nil, engine = Rails.application) return route_name.call if id.nil? return route_name.call(id) unless id.nil? end |
#link_button(title, **options) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 17 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-remote='#{remote}'>" if icon_class += "<i class='fa fa-#{icon_class}'></i>" end += "<span>#{title}</span>" + '</a>' .html_safe end |
#localized_time(time) ⇒ Object
12 13 14 15 |
# File 'app/helpers/faalis/dashboard_helper.rb', line 12 def localized_time(time) # Fixme: Setup and use Rails l10n time.strftime("%Y-%m-%d %H:%M") end |