Module: Decidim::ComponentPathHelper
- Defined in:
- app/helpers/decidim/component_path_helper.rb
Overview
A helper to get the root path for a component.
Instance Method Summary collapse
-
#can_be_managed?(component) ⇒ Boolean
Returns whether the component can be managed or not by checking if it has an admin engine.
-
#main_component_path(component, desired_params = {}) ⇒ Object
Returns the defined root path for a given component.
-
#main_component_url(component, desired_params = {}) ⇒ Object
Returns the defined root url for a given component.
-
#manage_component_path(component) ⇒ Object
Returns the defined admin root path for a given component.
Instance Method Details
#can_be_managed?(component) ⇒ Boolean
Returns whether the component can be managed or not by checking if it has an admin engine.
component - the Component we want to find if it is manageable or not.
Returns a boolean matching the question.
47 48 49 |
# File 'app/helpers/decidim/component_path_helper.rb', line 47 def can_be_managed?(component) component.manifest.admin_engine.present? end |
#main_component_path(component, desired_params = {}) ⇒ Object
Returns the defined root path for a given component.
component - the Component we want to find the root path for.
Returns a relative url.
11 12 13 14 15 16 17 |
# File 'app/helpers/decidim/component_path_helper.rb', line 11 def main_component_path(component, desired_params = {}) current_params = try(:params) || {} current_params = current_params.merge(locale: I18n.locale) .merge(desired_params) EngineRouter.main_proxy(component).root_path(locale: current_params[:locale]) end |
#main_component_url(component, desired_params = {}) ⇒ Object
Returns the defined root url for a given component.
component - the Component we want to find the root path for.
Returns an absolute url.
24 25 26 27 28 29 30 |
# File 'app/helpers/decidim/component_path_helper.rb', line 24 def main_component_url(component, desired_params = {}) current_params = try(:params) || {} current_params = current_params.merge(locale: I18n.locale) .merge(desired_params) EngineRouter.main_proxy(component).root_url(locale: current_params[:locale]) end |
#manage_component_path(component) ⇒ Object
Returns the defined admin root path for a given component.
component - the Component we want to find the root path for.
Returns a relative url.
37 38 39 |
# File 'app/helpers/decidim/component_path_helper.rb', line 37 def manage_component_path(component) EngineRouter.admin_proxy(component).root_path end |