Sha256: 3dc2cfbac74c8e30815406562a09f6725c45290a24635edb1211a6424ecb9b90

Contents?: true

Size: 1.33 KB

Versions: 28

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true
module Hyrax
  module BreadcrumbsForWorks
    extend ActiveSupport::Concern
    include Hyrax::Breadcrumbs

    class_methods do
      # We don't want the breadcrumb action to occur until after the concern has
      # been loaded and authorized
      def curation_concern_type=(curation_concern_type)
        super
        before_action :build_breadcrumbs, only: [:edit, :show, :new]
      end
    end

    private

    def build_breadcrumbs
      return super if action_name == 'show'
      # These breadcrumbs are for the edit/create actions
      add_breadcrumb t(:'hyrax.controls.home'), root_path
      add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
      add_breadcrumb_for_controller
      add_breadcrumb_for_action
    end

    def add_breadcrumb_for_controller
      add_breadcrumb I18n.t(:'hyrax.dashboard.my.works'), hyrax.my_works_path
    end

    def add_breadcrumb_for_action
      case action_name
      when 'edit'
        add_breadcrumb curation_concern.to_s, main_app.polymorphic_path(curation_concern)
        add_breadcrumb t(:'hyrax.works.edit.breadcrumb'), request.path
      when 'new'
        add_breadcrumb t(:'hyrax.works.create.breadcrumb'), request.path
      when 'show'
        add_breadcrumb presenter.to_s, main_app.polymorphic_path(presenter)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
hyrax-5.0.4 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-5.0.3 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-5.0.2 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-5.0.1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-5.0.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-5.0.0.rc3 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-5.0.0.rc2 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-5.0.0.rc1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-3.6.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-4.0.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-4.0.0.rc3 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-4.0.0.rc2 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-4.0.0.rc1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-3.5.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-4.0.0.beta2 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-3.4.2 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-4.0.0.beta1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-3.4.1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-3.4.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-3.3.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb