From 065e1582c2317862d15e22a28797928002fa54e5 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Wed, 6 Jun 2018 12:44:52 -0500 Subject: [PATCH] Add support for Google Maps API keys since they're required now. Closes #64 --- app/views/layouts/_app_data.html.erb | 1 + app/views/nonprofits/_overview_media.html.erb | 12 +++++++++++- app/views/ticket_mailer/followup.html.erb | 2 +- client/js/components/maps/cc_map.js | 6 +++++- config/environment.rb | 5 +++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/_app_data.html.erb b/app/views/layouts/_app_data.html.erb index bc14272d..87bde97b 100644 --- a/app/views/layouts/_app_data.html.erb +++ b/app/views/layouts/_app_data.html.erb @@ -19,6 +19,7 @@ var app = { , autocomplete: <%= @nonprofit ? @nonprofit.autocomplete_supporter_address : 'undefined'%> , facebook_app_id: "<%= ENV['FACEBOOK_APP_ID'] %>" , map_provider: "<%= Settings.maps&.provider %>" + , map_provider_options: <%= Settings.maps&.options ? raw(Settings.maps.options.to_json) : {} %> , editor: "<%= Settings.page_editor.editor%>" <% if Settings&.page_editor&.editor == 'froala' and Settings&.page_editor&.editor_options&.froala_key %>, froala_key: "<%= Settings.page_editor.editor_options.froala_key %>"<% end %> }; diff --git a/app/views/nonprofits/_overview_media.html.erb b/app/views/nonprofits/_overview_media.html.erb index 86654e95..9c55079f 100644 --- a/app/views/nonprofits/_overview_media.html.erb +++ b/app/views/nonprofits/_overview_media.html.erb @@ -10,7 +10,17 @@ <% elsif Format::Address.full_address(@nonprofit.address, @nonprofit.city, @nonprofit.state_code) %> - + <% npo_full_address = Format::Address.full_address(@nonprofit.address, @nonprofit.city, @nonprofit.state_code, @nonprofit.zip_code) %>
diff --git a/app/views/ticket_mailer/followup.html.erb b/app/views/ticket_mailer/followup.html.erb index b11d8a45..7a581035 100644 --- a/app/views/ticket_mailer/followup.html.erb +++ b/app/views/ticket_mailer/followup.html.erb @@ -49,7 +49,7 @@

<%= @event.address %>

<%= @event.city %>, <%= @event.state_code %> <%= @event.zip_code %>

-

Map link

+

Map link

<% if !@event.directions.blank? %> diff --git a/client/js/components/maps/cc_map.js b/client/js/components/maps/cc_map.js index 86f5b9bd..e3bbf4bf 100644 --- a/client/js/components/maps/cc_map.js +++ b/client/js/components/maps/cc_map.js @@ -19,7 +19,11 @@ cc_map.init = function(endpoint, options_obj, query) { var script = document.createElement('script') script.type = 'text/javascript' script.id = 'google_maps' - script.src = 'https://maps.googleapis.com/maps/api/js?sensor=false&callback=draw_map' + let key = "" + if (app.map_provider_options && app.map_provider_options.key) { + key = `api_key=${app.map_provider_options.key}&` + } + script.src = `https://maps.googleapis.com/maps/api/js?${key}sensor=false&callback=draw_map` document.body.appendChild(script) set_extra_options(options_obj) } else { diff --git a/config/environment.rb b/config/environment.rb index ab220457..ce60a5ce 100755 --- a/config/environment.rb +++ b/config/environment.rb @@ -120,6 +120,11 @@ Config.schema do # the map provider to use. Currently that's just Google Maps or nothing # Default is nil optional(:provider).value(included_in?:['google', nil]) + + optional(:options).schema do + #key for your google maps instance + optional(:key).filled(:str?) + end end required(:page_editor).schema do