Class: Decidim::Admin::Components::BaseController
Overview
This controller is the abstract class from which all component controllers in their admin engines should inherit from.
Instance Method Summary
collapse
#user_has_no_permission_path, #user_not_authorized_path
Instance Method Details
#current_component ⇒ Object
50
51
52
|
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 50
def current_component
request.env["decidim.current_component"]
end
|
#current_participatory_space ⇒ Object
54
55
56
|
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 54
def current_participatory_space
current_component.participatory_space
end
|
#enforce_component_permissions ⇒ Object
66
67
68
69
70
71
72
73
|
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 66
def enforce_component_permissions
case action_name.to_sym
when :index, :show
enforce_permission_to :read, :component, component: current_component
else
enforce_permission_to :manage, :component, component: current_component unless skip_manage_component_permission
end
end
|
#parent_path ⇒ Object
58
59
60
|
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 58
def parent_path
@parent_path ||= ::Decidim::EngineRouter.admin_proxy(current_participatory_space).components_path
end
|
#permission_class_chain ⇒ Object
38
39
40
41
42
43
44
|
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 38
def permission_class_chain
[
current_component.manifest.permissions_class,
current_participatory_space.manifest.permissions_class,
Decidim::Admin::Permissions
]
end
|
#permission_scope ⇒ Object
46
47
48
|
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 46
def permission_scope
:admin
end
|
#permissions_context ⇒ Object
31
32
33
34
35
36
|
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 31
def permissions_context
super.merge(
current_participatory_space:,
participatory_space: current_participatory_space
)
end
|
#set_breadcrumb_items ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 75
def set_breadcrumb_items
context_breadcrumb_items << {
label: t("components", scope: "decidim.admin.menu"),
url: parent_path,
active: false
}
context_breadcrumb_items << {
label: translated_attribute(current_component.name),
url: ::Decidim::EngineRouter.admin_proxy(current_component).root_path,
active: true
}
end
|
#skip_manage_component_permission ⇒ Object
62
63
64
|
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 62
def skip_manage_component_permission
false
end
|