Module: Decidim::DecidimAwesome::AwesomeHelpers
- Included in:
- AdminEngine, Engine, Proposals::ProposalVotesControllerOverride
- Defined in:
- lib/decidim/decidim_awesome/awesome_helpers.rb
Instance Method Summary collapse
- #awesome_config ⇒ Object
-
#awesome_config_instance ⇒ Object
Returns the normalized config for an Organization and the current url.
-
#awesome_custom_styles ⇒ Object
Collects all CSS that is applied in the current URL context.
-
#awesome_proposal_custom_fields ⇒ Object
Collects all proposal custom fields that is applied in the current URL context.
- #awesome_proposal_private_custom_fields ⇒ Object
-
#awesome_scoped_admins ⇒ Object
Collects all proposal custom fields that is applied in the current URL context.
- #awesome_version ⇒ Object
-
#awesome_voting_manifest_for(component) ⇒ Object
this will check if the current component has been configured to use a custom voting manifest.
- #javascript_config_vars ⇒ Object
- #organization_awesome_config ⇒ Object
- #show_public_intergram? ⇒ Boolean
- #unfiltered_awesome_config ⇒ Object
- #version_prefix ⇒ Object
Instance Method Details
#awesome_config ⇒ Object
22 23 24 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 22 def awesome_config @awesome_config ||= awesome_config_instance.config end |
#awesome_config_instance ⇒ Object
Returns the normalized config for an Organization and the current url
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 10 def awesome_config_instance return @awesome_config_instance if @awesome_config_instance # if already created in the middleware, reuse it as it might have additional constraints @awesome_config_instance = request.env["decidim_awesome.current_config"] unless @awesome_config_instance.is_a? Config @awesome_config_instance = Config.new request.env["decidim.current_organization"] @awesome_config_instance.context_from_request request end @awesome_config_instance end |
#awesome_custom_styles ⇒ Object
Collects all CSS that is applied in the current URL context
50 51 52 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 50 def awesome_custom_styles @awesome_custom_styles ||= awesome_config_instance.collect_sub_configs_values("scoped_style") end |
#awesome_proposal_custom_fields ⇒ Object
Collects all proposal custom fields that is applied in the current URL context
60 61 62 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 60 def awesome_proposal_custom_fields @awesome_proposal_custom_fields ||= awesome_config_instance.collect_sub_configs_values("proposal_custom_field") end |
#awesome_proposal_private_custom_fields ⇒ Object
64 65 66 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 64 def awesome_proposal_private_custom_fields @awesome_proposal_private_custom_fields ||= awesome_config_instance.collect_sub_configs_values("proposal_private_custom_field") end |
#awesome_scoped_admins ⇒ Object
Collects all proposal custom fields that is applied in the current URL context
55 56 57 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 55 def awesome_scoped_admins @awesome_scoped_admins ||= awesome_config_instance.collect_sub_configs_values("scoped_admin") end |
#awesome_version ⇒ Object
45 46 47 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 45 def awesome_version ::Decidim::DecidimAwesome::VERSION end |
#awesome_voting_manifest_for(component) ⇒ Object
this will check if the current component has been configured to use a custom voting manifest
69 70 71 72 73 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 69 def awesome_voting_manifest_for(component) return nil unless component.settings.respond_to? :awesome_voting_manifest DecidimAwesome.voting_registry.find(component.settings.awesome_voting_manifest) end |
#javascript_config_vars ⇒ Object
26 27 28 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 26 def javascript_config_vars awesome_config.except(:scoped_styles, :proposal_custom_fields, :proposal_private_custom_fields, :scoped_admins).to_json.html_safe end |
#organization_awesome_config ⇒ Object
41 42 43 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 41 def organization_awesome_config @organization_awesome_config ||= awesome_config_instance.organization_config end |
#show_public_intergram? ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 30 def show_public_intergram? return false unless awesome_config[:intergram_for_public] return true unless awesome_config[:intergram_for_public_settings][:require_login] user_signed_in? end |
#unfiltered_awesome_config ⇒ Object
37 38 39 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 37 def unfiltered_awesome_config @unfiltered_awesome_config ||= awesome_config_instance.unfiltered_config end |
#version_prefix ⇒ Object
75 76 77 |
# File 'lib/decidim/decidim_awesome/awesome_helpers.rb', line 75 def version_prefix "v#{Decidim.version[0..3]}" end |