This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.
phone_app/app/helpers/breadcrumb_helper.rb
2021-09-27 16:56:10 +02:00

32 lines
1.2 KiB
Ruby

module BreadcrumbHelper
def breadcrumb(options = {})
options = {action: @action}.merge options
capture_haml do
haml_tag :h1 do
unless @result.present?
haml_concat "Erreur dans le BreadcrumbHelper"
else
if options[:custom_last_item].present?
haml_concat(link_to @result[:first][:name], @result[:first][:link])
haml_tag(:span) { haml_concat(link_to @result[:second][:name], @result[:second][:link]) } if @result[:second].present?
case options[:action]
when :new
haml_tag(:span) {haml_concat("Création #{@result[:first][:name].singularize.downcase}")}
when :edit
haml_tag(:span) {haml_concat('Modification')}
when :index
haml_tag(:span) {haml_concat('Liste')}
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