Module: ActionAdmin::MarkupHelper
- Defined in:
- app/helpers/action_admin/markup_helper.rb
Instance Method Summary collapse
- #admin_action_links(action = nil) ⇒ Object
- #admin_icon(name, options = {}) ⇒ Object
- #admin_pagination(records, options = {}) ⇒ Object
- #admin_primary_menu ⇒ Object
- #admin_secondary_menu ⇒ Object
- #admin_settings_menu(records, label_method = :id) ⇒ Object
- #admin_sidebar_status ⇒ Object
- #admin_table_action_links(record, actions = nil) ⇒ Object
- #admin_table_pagination(records) ⇒ Object
- #admin_topbar_menu(position) ⇒ Object
Instance Method Details
#admin_action_links(action = nil) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'app/helpers/action_admin/markup_helper.rb', line 102 def admin_action_links(action=nil) name = action || action_name links = controller.action_header.action_links(name, self).map do |link| unless link[:url].nil? opts = Hash(link[:html]).merge(method: link[:method]) classes = "button small hollow #{opts[:class]}".strip label = admin_icon(link[:icon], text: link[:label]) link_to label, link[:url], opts.merge(class: classes) end end links.reject(&:blank?).join(' ').html_safe end |
#admin_icon(name, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/helpers/action_admin/markup_helper.rb', line 3 def admin_icon(name, ={}) opts = .except(:text, :revert).merge(class: "mdi mdi-#{name}") icon = content_tag :i, nil, opts if name.present? text = [:text] data = [:revert].present? ? [text, icon] : [icon, text] data.join(' ').html_safe end |
#admin_pagination(records, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/action_admin/markup_helper.rb', line 12 def admin_pagination(records, ={}) = .merge({ previous_class: 'pagination-previous', next_class: 'pagination-next', active_class: 'current' }) smart_pagination_for(records, ) end |
#admin_primary_menu ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/helpers/action_admin/markup_helper.rb', line 47 def = { menu_class: 'vertical menu icons icon-left accordion-menu', menu_html: { 'data-accordion-menu': '', 'data-submenu-toggle': true }, menu_icons: true, submenu_icons: false, submenu_class: 'vertical menu nested', active_class: 'is-current', active_submenu_class: 'is-current', icon_prefix: 'mdi mdi-', icon_position: 'left', keep_defaults: false } ActionAdmin.config..primary, end |
#admin_secondary_menu ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/helpers/action_admin/markup_helper.rb', line 64 def = { menu_class: 'vertical menu secondary icons icon-right', menu_icons: true, active_class: 'is-current', icon_prefix: 'mdi mdi-', icon_position: 'right', keep_defaults: false } ActionAdmin.config..secondary, end |
#admin_settings_menu(records, label_method = :id) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/action_admin/markup_helper.rb', line 30 def (records, label_method=:id) = { menu_class: 'vertical menu icons icon-left', active_class: 'active', keep_defaults: false } items = records.map do |record| label = record.send(label_method) url = edit_record_url(record) [:"#{label.downcase.underscore}", { label: label, url: url }] end Hash[items], end |
#admin_sidebar_status ⇒ Object
134 135 136 |
# File 'app/helpers/action_admin/markup_helper.rb', line 134 def 'is-collapsed' unless [:"_sidebar-collapsed"].nil? end |
#admin_table_action_links(record, actions = nil) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'app/helpers/action_admin/markup_helper.rb', line 117 def admin_table_action_links(record, actions=nil) app_url = method(ActionAdmin.config.app_urls).call(record) rescue nil app_link = link_to admin_icon('web'), app_url, title: 'Web', target: :_blank, class: 'button hollow info' if app_url.present? = { # show: { label: admin_icon('eye'), title: 'View', class: 'success' }, edit: { label: admin_icon('pencil'), title: 'Edit' }, destroy: { label: admin_icon('delete'), title: 'Delete', class: 'alert' } } = .select { |k, _v| k.in? actions } if actions.present? = .merge(html: { class: 'button hollow' }) all_links = record_links_to record, app_link.nil? ? all_links : (app_link + all_links) end |
#admin_table_pagination(records) ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/helpers/action_admin/markup_helper.rb', line 22 def admin_table_pagination(records) info = content_tag :div, smart_pagination_info_for(records), class: 'shrink cell' links = admin_pagination(records, wrapper_class: 'pagination margin-0') links = content_tag :div, links, class: 'auto cell text-right' content_tag :div, info + links, class: 'grid-x' end |
#admin_topbar_menu(position) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/helpers/action_admin/markup_helper.rb', line 77 def (position) items = { left: { toggle: { icon: 'menu', html: { 'data-toggle': 'sidebar' } } }, right: { website: { url: :root_url, icon: 'web', html: { target: :_blank } } } } = { menu_class: 'menu icons icon-left', menu_icons: true, submenu_class: 'vertical menu nested', icon_prefix: 'mdi mdi-', icon_position: 'left', keep_defaults: false } custom = ActionAdmin.config..send(:"topbar_#{position}") items = items[position].merge(Hash(custom).symbolize_keys) items, end |