Sha256: e7944762780438c1e75fa451a6329361215e99353bdfe9c7b16ffe005a4d09d1

Contents?: true

Size: 1.37 KB

Versions: 48

Compression:

Stored size: 1.37 KB

Contents

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'.freeze
          add_breadcrumb curation_concern.to_s, main_app.polymorphic_path(curation_concern)
          add_breadcrumb t(:'hyrax.works.edit.breadcrumb'), request.path
        when 'new'.freeze
          add_breadcrumb t(:'hyrax.works.create.breadcrumb'), request.path
        when 'show'.freeze
          add_breadcrumb presenter.to_s, main_app.polymorphic_path(presenter)
        end
      end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.9.5 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.9.4 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.9.3 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.9.2 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.9.1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.9.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.8.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.7.2 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.7.1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.7.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.6.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-3.0.0.pre.rc1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-3.0.0.pre.beta3 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.5.1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.5.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-3.0.0.pre.beta2 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.4.1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-3.0.0.pre.beta1 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb
hyrax-2.4.0 app/controllers/concerns/hyrax/breadcrumbs_for_works.rb