Module: Decidim::DecidimAwesome::MapHelper
- Includes:
- MapHelper
- Included in:
- ContentBlocks::MapCell
- Defined in:
- app/helpers/decidim/decidim_awesome/map_helper.rb
Instance Method Summary collapse
- #api_ready? ⇒ Boolean
-
#awesome_map_for(components) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity:.
- #current_categories(categories) ⇒ Object
- #global_settings ⇒ Object
- #settings_source ⇒ Object
-
#step_settings ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity:.
Instance Method Details
#api_ready? ⇒ Boolean
8 9 10 |
# File 'app/helpers/decidim/decidim_awesome/map_helper.rb', line 8 def api_ready? Decidim::Api::Schema.max_complexity >= 1300 end |
#awesome_map_for(components) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity:
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/decidim/decidim_awesome/map_helper.rb', line 14 def awesome_map_for(components, &) return unless map_utility_dynamic map = awesome_builder.map_element({ class: "dynamic-map", id: "awesome-map-container" }, &) help = content_tag(:div, class: "map__skip-container") do content_tag(:p, t("screen_reader_explanation", scope: "decidim.map.dynamic"), class: "sr-only") end = { "class" => "awesome-map", "id" => "awesome-map", "data-components" => components.map do |component| { id: component.id, type: component.manifest.name, name: translated_attribute(component.name), url: Decidim::EngineRouter.main_proxy(component).root_path, amendments: component.manifest.name == :proposals ? Decidim::Proposals::Proposal.where(component:).only_emendations.count : 0 } end.to_json, "data-hide-controls" => settings_source.try(:hide_controls), "data-collapsed" => global_settings.collapse, "data-truncate" => global_settings.truncate || 255, "data-map-center" => global_settings.map_center, "data-map-zoom" => global_settings.map_zoom || 8, "data-menu-merge-components" => global_settings., "data-menu-amendments" => global_settings., "data-menu-meetings" => global_settings., "data-menu-categories" => global_settings., "data-menu-hashtags" => global_settings., "data-show-not-answered" => step_settings&.show_not_answered, "data-show-accepted" => step_settings&.show_accepted, "data-show-withdrawn" => step_settings&.show_withdrawn, "data-show-evaluating" => step_settings&.show_evaluating, "data-show-rejected" => step_settings&.show_rejected } content_tag(:div, ) do content_tag :div, class: "w-full" do help + map end end end |
#current_categories(categories) ⇒ Object
[View source]
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/helpers/decidim/decidim_awesome/map_helper.rb', line 72 def current_categories(categories) return @current_categories if @current_categories @golden_ratio_conjugate = 0.618033988749895 # @h = rand # use random start value @h = 0.41 @current_categories = [] categories.first_class.each do |category| append_category category category.subcategories.each do |subcat| append_category subcat end end @current_categories end |
#global_settings ⇒ Object
[View source]
64 65 66 |
# File 'app/helpers/decidim/decidim_awesome/map_helper.rb', line 64 def global_settings settings_source.try(:settings) end |
#settings_source ⇒ Object
[View source]
68 69 70 |
# File 'app/helpers/decidim/decidim_awesome/map_helper.rb', line 68 def settings_source try(:current_component) || self end |
#step_settings ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity:
60 61 62 |
# File 'app/helpers/decidim/decidim_awesome/map_helper.rb', line 60 def step_settings settings_source.try(:current_settings) end |