refacto breadcrump
This commit is contained in:
parent
48898840d3
commit
5d1d1ee163
@ -545,9 +545,13 @@ class ApplicationController < ActionController::Base
|
|||||||
if @qi_menu_active.present?
|
if @qi_menu_active.present?
|
||||||
current_menu = @qi_menus[@qi_menu_active]
|
current_menu = @qi_menus[@qi_menu_active]
|
||||||
current_controller = controller_name.to_sym
|
current_controller = controller_name.to_sym
|
||||||
|
@action = action_name.to_sym
|
||||||
|
|
||||||
@result[:first] = {name: current_menu[:name], link: current_menu[:link]}
|
@result[:first] = {name: current_menu[:name], link: current_menu[:link]}
|
||||||
@result[:second] = current_menu[:elements][current_controller]
|
@result[:second] = current_menu[:elements][current_controller]
|
||||||
@title = @result[:first][:name].to_s + '/' + @result[:second][:name].to_s
|
if @result[:first][:name] == @result[:second][:name]
|
||||||
|
@result[:second] = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,35 +1,31 @@
|
|||||||
module BreadcrumbHelper
|
module BreadcrumbHelper
|
||||||
def breadcrumb(*custom_last_item)
|
def breadcrumb(options = {})
|
||||||
if custom_last_item.present?
|
options = {action: @action}.merge options
|
||||||
first_title_length = @result[:first][:name].to_s.length + 1
|
|
||||||
@title.slice!(0, first_title_length)
|
capture_haml do
|
||||||
@title << "/" + custom_last_item[0]
|
haml_tag :h1 do
|
||||||
end
|
unless @result.present?
|
||||||
if @result.present?
|
haml_concat "Erreur dans le BreadcrumbHelper"
|
||||||
capture_haml do
|
else
|
||||||
haml_tag :h1 do
|
if options[:custom_last_item].present?
|
||||||
haml_concat(link_to @result[:first][:name], @result[:first][:link])
|
haml_concat(link_to @result[:first][:name], @result[:first][:link])
|
||||||
haml_tag :span do
|
haml_tag(:span) { haml_concat(link_to @result[:second][:name], @result[:second][:link]) } if @result[:second].present?
|
||||||
haml_concat(link_to @result[:second][:name], @result[:second][:link])
|
case options[:action]
|
||||||
if custom_last_item.present?
|
when :new
|
||||||
haml_tag :span do
|
haml_tag(:span) {haml_concat("Création #{@result[:first][:name].singularize.downcase}")}
|
||||||
haml_concat(custom_last_item[0])
|
when :edit
|
||||||
end
|
haml_tag(:span) {haml_concat('Modification')}
|
||||||
|
when :index
|
||||||
|
haml_tag(:span) {haml_concat('Liste')}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
haml_tag(:span) {haml_concat(options[:custom_last_item])}
|
||||||
|
else
|
||||||
|
@result[:second].present? ? haml_concat(link_to @result[:first][:name], @result[:first][:link]) : haml_concat( @result[:first][:name])
|
||||||
|
haml_tag(:span) { haml_concat( @result[:second][:name]) } if @result[:second].present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
capture_haml do
|
|
||||||
haml_tag :h1 do
|
|
||||||
haml_concat "Erreur dans le BreadcrumbHelper"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def breadcrumb_title
|
|
||||||
@result[:first][:name] + "/" + result[:second][:name]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
=link_to "< Retour aux demandes de commande", admin_p_customer_sheets_path
|
=link_to "< Retour aux demandes de commande", admin_p_customer_sheets_path
|
||||||
|
|
||||||
%h1
|
%h1
|
||||||
Clients
|
=breadcrumb
|
||||||
|
=hello
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user