Module: Adminpanel::ApplicationHelper

Includes:
BreadcrumbsHelper, SessionsHelper, SharedPagesHelper
Defined in:
app/helpers/adminpanel/application_helper.rb

Instance Method Summary collapse

Methods included from SharedPagesHelper

#class_name_downcase, #demodulize_class, #parent_object_name, #pluralize_model, #relationship_ids

Methods included from BreadcrumbsHelper

#breadcrumb_add, #initialize_breadcrumb, #render_breadcrumb

Methods included from SessionsHelper

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

Instance Method Details

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



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

def custom_form_for(name, *args, &block)
  options = args.extract_options!
  options.reverse_merge! :builder => Adminpanel::CustomFormBuilder, :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?(controller_name) ⇒ Boolean

Returns:

  • (Boolean)


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

def is_current_section?(controller_name)
  "adminpanel/#{controller_name.downcase.pluralize}".include?(params[:controller]) ? 'active' : nil
end


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

def link_to_add_fields(name, f, association, model_name)
  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("shared/" + association.to_s.singularize + "_fields", :f => builder, :model_name => model_name)
  end
  link_to((:div, (:button,
        (:h6, name, :id => "add-image-button"),
         :class => "btn btn-success btn-mini"), :class => "mws-form-row"),
  '#', :class => "add_fields", :data => {:id => id, :fields => fields.gsub("\n", "")})
end

#main_root_pathObject



47
48
49
50
51
52
53
# File 'app/helpers/adminpanel/application_helper.rb', line 47

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

#route_symbol(model_name) ⇒ Object



43
44
45
# File 'app/helpers/adminpanel/application_helper.rb', line 43

def route_symbol(model_name)
  model_name.downcase.pluralize.downcase
end

#section_is_login(section_name) ⇒ Object



27
28
29
# File 'app/helpers/adminpanel/application_helper.rb', line 27

def (section_name)
  section_name.downcase == 'login'
end