Module: ApplicationHelper
- Defined in:
- app/helpers/admin_helper.rb
Instance Method Summary collapse
- #body_class ⇒ Object
- #body_data_controller ⇒ Object
- #body_id ⇒ Object
- #sidebar_item_classes(c_names, *a_names) ⇒ Object
- #sidebar_item_link_classes(c_names, *a_names) ⇒ Object
- #sort_opt(model, column) ⇒ Object
- #sub_item_active?(sub_c_names = []) ⇒ Boolean
Instance Method Details
#body_class ⇒ Object
9 10 11 |
# File 'app/helpers/admin_helper.rb', line 9 def body_class controller_path.gsub(%r{^v\d+/}, '').tr('/', '-').dasherize end |
#body_data_controller ⇒ Object
13 14 15 |
# File 'app/helpers/admin_helper.rb', line 13 def body_data_controller @body_data_controller ||= controller_name.tr('_', '-').split('/').join('-') end |
#body_id ⇒ Object
4 5 6 7 |
# File 'app/helpers/admin_helper.rb', line 4 def body_id ctrl_name = controller_path.gsub(%r{^v\d+/}, '').tr('/', '-') [ctrl_name, action_name].map(&:dasherize).join('-') end |
#sidebar_item_classes(c_names, *a_names) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/admin_helper.rb', line 31 def (c_names, *a_names) class_names = 'sidebar-item' if a_names.any? class_names += ' selected' if controller_name.in?(c_names) && action_name.in?(a_names) else class_names += ' selected' if controller_name.in? c_names end class_names end |
#sidebar_item_link_classes(c_names, *a_names) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/admin_helper.rb', line 43 def (c_names, *a_names) class_names = 'sidebar-link waves-effect waves-dark sidebar-link' if a_names.any? class_names += ' active' if controller_name.in?(c_names) && action_name.in?(a_names) else class_names += ' active' if controller_name.in? c_names end class_names end |
#sort_opt(model, column) ⇒ Object
17 18 19 |
# File 'app/helpers/admin_helper.rb', line 17 def sort_opt(model, column) { model: model, column: column }.to_json end |
#sub_item_active?(sub_c_names = []) ⇒ Boolean
21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/admin_helper.rb', line 21 def sub_item_active?(sub_c_names = []) class_names = 'sidebar-item' if controller_name.in?(sub_c_names) class_names += ' active' end class_names end |