Skip to content

Commit

Permalink
Add breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
ahukkanen committed Apr 18, 2024
1 parent 8d1d078 commit 4158dd4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/controllers/decidim/plans/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class PlansController < Decidim::Plans::ApplicationController
before_action :check_draft, only: [:new]
before_action :retrieve_plan, only: [:show, :edit, :update, :withdraw, :preview, :publish, :close, :destroy, :add_authors, :add_authors_confirm, :disjoin]
before_action :ensure_published!, only: [:show, :withdraw, :add_authors, :add_authors_confirm]
before_action :set_breadcrumbs, only: [:new, :show, :edit, :preview]

def index
enforce_permission_to :read, :plans
Expand Down Expand Up @@ -233,6 +234,21 @@ def disjoin

private

def set_breadcrumbs
return unless respond_to?(:add_breadcrumb, true)

add_breadcrumb(translated_attribute(current_component.name), plans_path)

case action_name
when "show"
add_breadcrumb(translated_attribute(@plan.title), plan_path(@plan))
when "new"
add_breadcrumb(t("decidim.plans.plans.new.title"), new_plan_path)
when "edit"
add_breadcrumb(t("decidim.plans.plans.edit.title"), edit_plan_path(@plan))
end
end

def trigger_feedback?
@trigger_feedback ||= session.delete("decidim-plans.published")
end
Expand Down

0 comments on commit 4158dd4

Please sign in to comment.