module BreadcrumbHelper

  def ensure_breadcrumb
      @breadcrumb ||= [ { :title => t("views.right_panel.button.home"), :url => dashboard_path } ]
  end

  def back
    @back ||= []
  end

  def breadcrumb_add(title, url, back_url, act_name = nil)
    ensure_breadcrumb << { :title => title, :url => url }
    ensure_breadcrumb << { :title => act_name, :url => '' } if act_name.present?

    back << {url: back_url} if back_url.present?
  end

  def render_breadcrumb
    render :partial => 'shared/breadcrumb', :locals => { :nav => ensure_breadcrumb, :back => back }
  end
end