Module: Decidim::DecidimAwesome::MapHelper
- Includes:
- MapHelper
- Defined in:
- app/helpers/decidim/decidim_awesome/map_helper.rb
Instance Method Summary collapse
- #awesome_map_for(components, &block) ⇒ Object
-
#current_categories ⇒ Object
rubocop:disable Rails/HelperInstanceVariable.
-
#legacy_map_for(components) ⇒ Object
TODO: remove when 0.22 support is diched.
Instance Method Details
#awesome_map_for(components, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/decidim/decidim_awesome/map_helper.rb', line 8 def awesome_map_for(components, &block) return legacy_map_for(components, &block) unless defined?(Decidim::Map) map = dynamic_map_for({}, {}, &block) return unless map = { "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: component).only_emendations.count : 0 } end.to_json, "data-collapsed" => current_component.settings.collapse, "data-show-not-answered" => current_component.current_settings.show_not_answered, "data-show-accepted" => current_component.current_settings.show_accepted, "data-show-withdrawn" => current_component.current_settings.show_withdrawn, "data-show-evaluating" => current_component.current_settings.show_evaluating # "data-show-rejected" => current_component.current_settings.show_rejected } content_tag(:div, map, ) end |
#current_categories ⇒ Object
rubocop:disable Rails/HelperInstanceVariable
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/helpers/decidim/decidim_awesome/map_helper.rb', line 81 def current_categories return @current_categories if @current_categories @golden_ratio_conjugate = 0.618033988749895 # @h = rand # use random start value @h = 0.4 @current_categories = [] current_participatory_space.categories.first_class.each do |category| append_category category category.subcategories.each do |subcat| append_category subcat end end @current_categories end |
#legacy_map_for(components) ⇒ Object
TODO: remove when 0.22 support is diched
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/helpers/decidim/decidim_awesome/map_helper.rb', line 37 def legacy_map_for(components) return if Decidim.geocoder.blank? = { class: "google-map", id: "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: component).only_emendations.count : 0 } end.to_json, "data-collapsed" => current_component.settings.collapse, "data-show-not-answered" => current_component.current_settings.show_not_answered, "data-show-accepted" => current_component.current_settings.show_accepted, "data-show-withdrawn" => current_component.current_settings.show_withdrawn, "data-show-evaluating" => current_component.current_settings.show_evaluating, # "data-show-rejected" => current_component.current_settings.show_rejected, "data-markers-data" => [].to_json } if Decidim.geocoder[:here_api_key] ["data-here-api-key"] = Decidim.geocoder[:here_api_key] else # Compatibility mode for old api_id/app_code configurations ["data-here-app-id"] = Decidim.geocoder[:here_app_id] ["data-here-app-code"] = Decidim.geocoder[:here_app_code] end content = capture { yield }.html_safe help = content_tag(:div, class: "map__help") do content_tag(:p, I18n.t("screen_reader_explanation", scope: "decidim.map.dynamic"), class: "show-for-sr") end content_tag :div, class: "awesome-map" do map = content_tag(:div, "", ) help + map + content end end |