Module: Adminpanel::ApplicationHelper

Includes:
BreadcrumbsHelper, SessionsHelper, SharedPagesHelper
Included in:
Ability, AdminpanelFormBuilder, Permission, SessionsController
Defined in:
app/helpers/adminpanel/application_helper.rb

Instance Method Summary collapse

Methods included from SharedPagesHelper

#active_tab, #belong_to_object_name, #class_name_downcase, #demodulize_class, #field_value, #get_oauth_link, #is_customized_field?, #pluralize_model, #relationship_ids, #table_type

Methods included from BreadcrumbsHelper

#breadcrumb_add, #render_breadcrumb

Methods included from SessionsHelper

#current_user, #current_user=, #sign_in, #sign_out, #signed_in?

Instance Method Details

#adminpanel_form_for(name, *args, &block) ⇒ Object



7
8
9
10
11
12
# File 'app/helpers/adminpanel/application_helper.rb', line 7

def adminpanel_form_for(name, *args, &block)
  options = args.extract_options!
  options.reverse_merge! builder: Adminpanel::AdminpanelFormBuilder, html: { class: "form-horizontal" }

  form_for(name, *(args << options), &block)
end

#full_title(page_title) ⇒ Object



14
15
16
17
18
19
20
21
# File 'app/helpers/adminpanel/application_helper.rb', line 14

def full_title(page_title)
  base_title = t("Panel title")
  if page_title.empty?
    base_title
  else
    "#{page_title} | #{base_title}"
  end
end

#is_current_section?(display_name) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/helpers/adminpanel/application_helper.rb', line 23

def is_current_section?(display_name)
  display_name == params[:controller].classify.constantize.display_name ? 'active' : nil
end


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/helpers/adminpanel/application_helper.rb', line 27

def link_to_add_fields(name, f, association, hidden='not-hidden')
  new_object = f.object.send(association).klass.new
  id = new_object.object_id
  fields = f.fields_for(association, new_object, child_index: id) do |builder|
    render('adminpanel/shared/image_fields', f: builder)
  end
  add_another_image_button = (:div, id: 'new-image-button') do
    (:button, class: 'btn btn-success btn-mini') do
      (:h6, name)
    end
  end
  link_to(
    add_another_image_button,
    '#',
    class: "add-fields #{hidden}",
    id: 'add-image-link',
    data: {
      id: id,
      fields: fields.gsub("\n", "")
    }
  )
end

#main_root_pathObject



58
59
60
61
62
63
64
# File 'app/helpers/adminpanel/application_helper.rb', line 58

def main_root_path
  if main_app.respond_to?(root_path)
    main_app.root_path
  else
    "/"
  end
end

#route_symbol(model_name) ⇒ Object



50
51
52
# File 'app/helpers/adminpanel/application_helper.rb', line 50

def route_symbol(model_name)
  model_name.pluralize.downcase
end

#symbol_class(symbol_model) ⇒ Object



54
55
56
# File 'app/helpers/adminpanel/application_helper.rb', line 54

def symbol_class(symbol_model)
  "adminpanel/#{symbol_model.to_s.singularize}".classify.constantize
end