set breadcrump helper
This commit is contained in:
parent
9293ed66bd
commit
48898840d3
@ -49,6 +49,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
end
|
||||
end
|
||||
set_breadcrumb
|
||||
end
|
||||
|
||||
|
||||
@ -539,5 +540,15 @@ class ApplicationController < ActionController::Base
|
||||
@dropdown_title = "Parametrage"
|
||||
end
|
||||
|
||||
def set_breadcrumb
|
||||
@result = {}
|
||||
if @qi_menu_active.present?
|
||||
current_menu = @qi_menus[@qi_menu_active]
|
||||
current_controller = controller_name.to_sym
|
||||
@result[:first] = {name: current_menu[:name], link: current_menu[:link]}
|
||||
@result[:second] = current_menu[:elements][current_controller]
|
||||
@title = @result[:first][:name].to_s + '/' + @result[:second][:name].to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
35
app/helpers/breadcrumb_helper.rb
Normal file
35
app/helpers/breadcrumb_helper.rb
Normal file
@ -0,0 +1,35 @@
|
||||
module BreadcrumbHelper
|
||||
def breadcrumb(*custom_last_item)
|
||||
if custom_last_item.present?
|
||||
first_title_length = @result[:first][:name].to_s.length + 1
|
||||
@title.slice!(0, first_title_length)
|
||||
@title << "/" + custom_last_item[0]
|
||||
end
|
||||
if @result.present?
|
||||
capture_haml do
|
||||
haml_tag :h1 do
|
||||
haml_concat(link_to @result[:first][:name], @result[:first][:link])
|
||||
haml_tag :span do
|
||||
haml_concat(link_to @result[:second][:name], @result[:second][:link])
|
||||
if custom_last_item.present?
|
||||
haml_tag :span do
|
||||
haml_concat(custom_last_item[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
capture_haml do
|
||||
haml_tag :h1 do
|
||||
haml_concat "Erreur dans le BreadcrumbHelper"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def breadcrumb_title
|
||||
@result[:first][:name] + "/" + result[:second][:name]
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user