From 4158dd4fdab3de98aa456c956024d155d35ef048 Mon Sep 17 00:00:00 2001 From: Antti Hukkanen Date: Thu, 18 Apr 2024 17:23:10 +0300 Subject: [PATCH] Add breadcrumbs --- .../decidim/plans/plans_controller.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/controllers/decidim/plans/plans_controller.rb b/app/controllers/decidim/plans/plans_controller.rb index 04a76b55..c83ec735 100644 --- a/app/controllers/decidim/plans/plans_controller.rb +++ b/app/controllers/decidim/plans/plans_controller.rb @@ -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 @@ -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