Module: ApplicationHelper

Defined in:
app/helpers/admin_helper.rb

Instance Method Summary collapse

Instance Method Details

#body_classObject



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_controllerObject



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_idObject



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


31
32
33
34
35
36
37
38
39
40
41
# File 'app/helpers/admin_helper.rb', line 31

def sidebar_item_classes(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


43
44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/admin_helper.rb', line 43

def sidebar_item_link_classes(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

Returns:

  • (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