Module: RailsAdmin::Application::HancockHelper
- Defined in:
- app/helpers/rails_admin/application/hancock_helper.rb
Instance Method Summary collapse
- #hancock_edit_path(obj, opts = {}) ⇒ Object
- #hancock_navigation(nodes_stack, nodes, level = 0) ⇒ Object
- #hancock_show_path(obj, opts = {}) ⇒ Object
Instance Method Details
#hancock_edit_path(obj, opts = {}) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/helpers/rails_admin/application/hancock_helper.rb', line 27 def hancock_edit_path(obj, opts = {}) if obj.is_a?(Hash) (opts ||= {}).merge!(obj) else (opts ||= {}).merge!({model_name: obj.rails_admin_model, id: obj.id}) end edit_path(opts) end |
#hancock_navigation(nodes_stack, nodes, level = 0) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/rails_admin/application/hancock_helper.rb', line 5 def (nodes_stack, nodes, level = 0) nodes.collect do |node| model_param = node.abstract_model.to_param url = rails_admin.url_for(action: :index, controller: 'rails_admin/main', model_name: model_param) level_class = " nav-level-#{level}" if level > 0 nav_icon = node. ? %(<i class="#{node.}"></i>).html_safe : '' li = content_tag :li, data: {model: model_param, "name-synonyms": node.name_synonyms} do link_to nav_icon + capitalize_first_letter(node.label_plural), url, class: "pjax#{level_class}", title: capitalize_first_letter(node.label_plural) end li + (nodes_stack, nodes_stack.select { |n| n.parent.to_s == node.abstract_model.model_name }, level + 1) end.join.html_safe end |
#hancock_show_path(obj, opts = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/helpers/rails_admin/application/hancock_helper.rb', line 18 def hancock_show_path(obj, opts = {}) if obj.is_a?(Hash) (opts ||= {}).merge!(obj) else (opts ||= {}).merge!({model_name: obj.rails_admin_model, id: obj.id}) end show_path(opts) end |