Class: Decidim::Admin::Components::BaseController

Inherits:
ApplicationController show all
Includes:
ParticipatorySpaceAdminContext, NeedsPermission, Settings
Defined in:
app/controllers/decidim/admin/components/base_controller.rb

Overview

This controller is the abstract class from which all component controllers in their admin engines should inherit from.

Instance Method Summary collapse

Methods inherited from ApplicationController

#user_has_no_permission_path, #user_not_authorized_path

Instance Method Details

#current_componentObject



55
56
57
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 55

def current_component
  request.env["decidim.current_component"]
end

#current_participatory_spaceObject



59
60
61
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 59

def current_participatory_space
  current_component.participatory_space
end

#parent_pathObject



63
64
65
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 63

def parent_path
  @parent_path ||= ::Decidim::EngineRouter.admin_proxy(current_participatory_space).components_path
end

#permission_class_chainObject



43
44
45
46
47
48
49
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 43

def permission_class_chain
  [
    current_component.manifest.permissions_class,
    current_participatory_space.manifest.permissions_class,
    Decidim::Admin::Permissions
  ]
end

#permission_scopeObject



51
52
53
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 51

def permission_scope
  :admin
end

#permissions_contextObject



36
37
38
39
40
41
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 36

def permissions_context
  super.merge(
    current_participatory_space:,
    participatory_space: current_participatory_space
  )
end

#set_component_breadcrumb_itemObject



71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 71

def set_component_breadcrumb_item
  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_permissionObject



67
68
69
# File 'app/controllers/decidim/admin/components/base_controller.rb', line 67

def skip_manage_component_permission
  false
end