From 5ed2ebe910a5b004e9ef3984c6906bde8949e998 Mon Sep 17 00:00:00 2001 From: Abhinand-p Date: Wed, 5 Apr 2017 03:27:54 -0700 Subject: [PATCH 1/6] Update venue.rb definition of full_address and geocode has been added --- app/models/venue.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/venue.rb b/app/models/venue.rb index 76d7de5e..ebccda8d 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -13,8 +13,11 @@ class Venue < ActiveRecord::Base before_save :send_mail_notification - def address - "#{street}, #{city}, #{country_name}" + geocoded_by :full_address + after_validation :geocode + + def full_address + "#{street}, #{city}, #{country}" end def country_name @@ -35,7 +38,7 @@ class Venue < ActiveRecord::Base def notify_on_venue_changed? return false unless conference.try(:email_settings).try(:send_on_venue_updated) # do not notify unless the address changed - return false unless name_changed? || street_changed? || city_changed? || country_changed? + return false unless self.name_changed? || self.street_changed? || self.city_changed? || self.country_changed? # do not notify unless the mail content is set up (!conference.email_settings.venue_updated_subject.blank? && !conference.email_settings.venue_updated_body.blank?) end From 1470976e401aee7dd7fcab819fcc2dd3ed06fe12 Mon Sep 17 00:00:00 2001 From: Abhinand-p Date: Wed, 5 Apr 2017 03:31:53 -0700 Subject: [PATCH 2/6] Add files via upload latitude and longitude entries have been removed and geocode is invoked for selction of venue location. --- app/views/admin/venues/_form.html.haml | 2 +- app/views/admin/venues/_venue_map.html.haml | 34 +++++++++++++++++++++ app/views/admin/venues/show.html.haml | 2 ++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 app/views/admin/venues/_venue_map.html.haml diff --git a/app/views/admin/venues/_form.html.haml b/app/views/admin/venues/_form.html.haml index 7dd08a2c..8e021e3e 100644 --- a/app/views/admin/venues/_form.html.haml +++ b/app/views/admin/venues/_form.html.haml @@ -15,7 +15,7 @@ = semantic_form_for(@venue, url: admin_conference_venue_path(@conference.short_title)) do |f| = f.inputs :name, :website = f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint - = f.inputs :street, :postalcode, :city, :country, :latitude, :longitude + = f.inputs :street, :postalcode, :city, :country = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } #commercials-content.tab-pane diff --git a/app/views/admin/venues/_venue_map.html.haml b/app/views/admin/venues/_venue_map.html.haml new file mode 100644 index 00000000..b58b3053 --- /dev/null +++ b/app/views/admin/venues/_venue_map.html.haml @@ -0,0 +1,34 @@ +#map{style: "height: 500px;" } +- popup = "

#{@conference.venue.name}


#{@conference.venue.street}
#{@conference.venue.city}
#{@conference.venue.country_name}" +- content_for(:script_body) do + :javascript + // create a map in the "map" div, set the view to a given place and zoom + var map = L.map('map', { scrollWheelZoom: false }).setView([#{@conference.venue.latitude}, #{@conference.venue.longitude}], 11); + // add an OpenStreetMap tile layer + L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', + maxZoom: 18 + }).addTo(map); + // add a marker in the given location, attach some popup content to it and open the popup + L.marker([#{@conference.venue.latitude}, #{@conference.venue.longitude}]).addTo(map) + .bindPopup("#{popup}") + .openPopup(); + // Turn scrollwheel on when user clicks + map.on('focus', function(e) { + map.scrollWheelZoom.enable(); + }); + // Turn scrollwheel off once the map isn't in the viewport anymore + $('#map').waypoint({ + handler: function(direction) { + map.scrollWheelZoom.disable(); + //alert('map'); + }, + offset: '90%' + }); + $('#map').waypoint({ + handler: function(direction) { + map.scrollWheelZoom.disable(); + //alert('map'); + }, + offset: '10%' + }); diff --git a/app/views/admin/venues/show.html.haml b/app/views/admin/venues/show.html.haml index b50c10da..5e25f52a 100644 --- a/app/views/admin/venues/show.html.haml +++ b/app/views/admin/venues/show.html.haml @@ -41,3 +41,5 @@ .col-md-12.text-right = link_to(new_admin_conference_venue_path(@conference.short_title), class: 'btn btn-primary') do Create Venue + + From 2c888eda040a5fb86537bafa0881928e33a4f8b3 Mon Sep 17 00:00:00 2001 From: Abhinand-p Date: Wed, 5 Apr 2017 03:34:26 -0700 Subject: [PATCH 3/6] Update Gemfile gem 'geocoder' has been included in this file --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index b1c5764f..1a8e3c40 100644 --- a/Gemfile +++ b/Gemfile @@ -239,3 +239,5 @@ group :development, :test do # as debugger gem 'byebug' end + +gem 'geocoder' From 6188896372985f64ce145a45db265f5818f2c06a Mon Sep 17 00:00:00 2001 From: Abhinand-p Date: Wed, 5 Apr 2017 16:55:55 +0530 Subject: [PATCH 4/6] Update Gemfile --- Gemfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 1a8e3c40..1a489f66 100644 --- a/Gemfile +++ b/Gemfile @@ -84,6 +84,9 @@ gem 'jquery-ui-rails', '~> 4.2.1' # for languages validation gem 'iso-639' +# geocoder +gem 'geocoder' + # frontend javascripts source 'https://rails-assets.org' do # for placeholder images @@ -239,5 +242,3 @@ group :development, :test do # as debugger gem 'byebug' end - -gem 'geocoder' From fbd628c7e55f85e278e6c8e04bec9b745b9cc894 Mon Sep 17 00:00:00 2001 From: Abhinand-p Date: Wed, 5 Apr 2017 17:06:53 +0530 Subject: [PATCH 5/6] Update Gemfile # gem 'geocoder' ##execute gem install geocoder serverside and uncomment the above line --- Gemfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1a489f66..9f82373b 100644 --- a/Gemfile +++ b/Gemfile @@ -85,7 +85,9 @@ gem 'jquery-ui-rails', '~> 4.2.1' gem 'iso-639' # geocoder -gem 'geocoder' +# gem 'geocoder' +##execute gem install geocoder serverside and uncomment the above line + # frontend javascripts source 'https://rails-assets.org' do From d499f88217b73e6d9defbd25be37024526cbb208 Mon Sep 17 00:00:00 2001 From: Abhinand-p Date: Wed, 5 Apr 2017 17:18:57 +0530 Subject: [PATCH 6/6] Add files via upload --- Gemfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Gemfile b/Gemfile index 9f82373b..b1c5764f 100644 --- a/Gemfile +++ b/Gemfile @@ -84,11 +84,6 @@ gem 'jquery-ui-rails', '~> 4.2.1' # for languages validation gem 'iso-639' -# geocoder -# gem 'geocoder' -##execute gem install geocoder serverside and uncomment the above line - - # frontend javascripts source 'https://rails-assets.org' do # for placeholder images