Sha256: 1b4b93c84dd73020ef9f3beef94c287cda02af478ddbcab250ceaa8cbfdb538e

Contents?: true

Size: 800 Bytes

Versions: 28

Compression:

Stored size: 800 Bytes

Contents

module Releaf::ActionController::Breadcrumbs
  extend ActiveSupport::Concern

  included do
    before_action :build_breadcrumbs
  end

  def build_breadcrumbs
    @breadcrumbs = [controller_breadcrumb].compact
  end

  def controller_breadcrumb
    {name: definition.localized_name, url: definition.path} if definition
  end

  def add_resource_breadcrumb(resource, url = nil)
    if resource.new_record?
      name=  I18n.t('New record', scope: 'admin.breadcrumbs')
      url = url_for(action: :new, only_path: true) if url.nil?
    else
      url_action = feature_available?(:show) ? :show : :edit
      name = Releaf::ResourceBase.title(resource)
      url = url_for(action: url_action, id: resource.id, only_path: true) if url.nil?
    end
    @breadcrumbs << { name: name, url: url }
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
releaf-core-3.1.0 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-3.0.3 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-3.0.2 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-3.0.1 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-3.0.0 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-2.2.1 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-2.2.0 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-2.1.2 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-2.1.1 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-2.1.0 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-2.0.1 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-2.0.0 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-1.1.22 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-1.1.21 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-1.1.20 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-1.1.19 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-1.1.18 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-1.1.17 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-1.1.16 app/lib/releaf/action_controller/breadcrumbs.rb
releaf-core-1.1.15 app/lib/releaf/action_controller/breadcrumbs.rb