Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

html -> haml

  • Loading branch information...
commit 719eace9a017910c7ff400dc882adcccab756d4e 1 parent 0611447
@carboes authored
View
2  app/controllers/admin/map_locations_controller.rb
@@ -1,5 +1,5 @@
class Admin::MapLocationsController < Admin::BaseController
- crudify :map_location, :order => "city"
+ crudify :map_location , :order => "title"
end
View
2  app/controllers/map_locations_controller.rb
@@ -10,7 +10,7 @@ def find_locations
coords = Geocode.find_address(params[:q])
@map_locations = MapLocation.nearest_to(coords.latitude, coords.longitude, 50)
else
- @map_locations = MapLocation.all
+ @map_locations = MapLocation.where(branches.length > 0)
end
end
View
12 app/models/map_location.rb
@@ -4,13 +4,17 @@ class MapLocation < ActiveRecord::Base
has_friendly_id :title, :use_slug => true
- acts_as_indexed :fields => [:title, :address, :city, :postcode]
+ acts_as_indexed :fields => [:title, :address, :city, :postcode, :area]
has_many :branches
-
- default_scope :order => "city, title"
+
+ belongs_to :photo, :class_name => 'Image'
+
+ default_scope :order => "title"
before_save :set_lat_and_lng
+
+ Areas = ['Central', 'North', 'West', 'Herts', 'Bucks']
# for will_paginate
def self.per_page
@@ -47,7 +51,7 @@ def full_address
def set_lat_and_lng
- if address_changed? || city_changed? || state_changed? || zipcode_changed?
+ if address_changed? || city_changed? || postcode_changed?
Geocode.find_address(self.full_address).tap do |coordinate|
self.lat = coordinate.latitude
self.lng = coordinate.longitude
View
47 app/views/admin/map_locations/_form.haml
@@ -0,0 +1,47 @@
+- form_for [:admin, @map_location] do |f|
+ = f.error_messages
+
+ .hemisquare
+ .field
+ = f.label :title
+ = f.text_field :title, :class => "larger widest"
+
+ .field
+ = f.label :venue
+ = f.text_field :venue
+
+ .field
+ = f.label :details
+ = f.text_field :details
+
+ .field
+ = f.label :address
+ = f.text_field :address
+
+ .field
+ = f.label :city
+ = f.text_field :city
+
+ .field
+ = f.label :postcode
+ = f.text_field :postcode
+
+ .field
+ = f.label :main_centre
+ = f.check_box :main_centre
+
+ .field
+ = f.label :photo
+ = render :partial => "/shared/admin/image_picker", :locals => { :f => f, :field => :photo_id, :image => @map_location.photo, :toggle_image_display => false }
+
+ .field
+ = f.label 'Area', :for => 'weekly_class_area'
+ = select "map_location", "area", MapLocation::Areas, {:selected => @map_location.area}
+
+ .hemisquare.right_side
+ <br/><br/><br/><br/><br/><br/><br/>
+ = image_tag "http://maps.google.com/maps/api/staticmap?size=400x400&markers=#{@map_location.full_address.parameterize('+')}&zoom=14&sensor=false", :class => "location_map"
+
+ .clearfix
+
+ = render :partial => "/shared/admin/form_actions", :locals => { :f => f, :continue_editing => false }
View
9 app/views/admin/map_locations/_form.html.erb → app/views/admin/map_locations/_form.html.erb.old
@@ -31,7 +31,16 @@
<%= f.label :postcode %>
<%= f.text_field :postcode %>
</div>
+
+ <div class='field'>
+ <%= f.label :main_centre %>
+ <%= f.check_box :main_centre %>
+ </div>
+ <div class='field'>
+ <%= f.label :photo %>
+ <%= render :partial => "/shared/admin/image_picker", :locals => { :f => f, :field => :photo_id, :image => @map_location.photo, :toggle_image_display => false } %>
+ </div>
</div>
<div class='hemisquare right_side'>
View
25 app/views/map_locations/_locations.haml
@@ -0,0 +1,25 @@
+#map-side-bar
+ %ul
+ - @map_locations.each do |loc|
+ %li.map-location{:'data-id' => loc.id, :'data-jmapping' => "{id: #{loc.id}, point: {lat: #{loc.lat}, lng: #{loc.lng}}, category: '#{loc.main_centre == 1 ? 'centre' : 'default'}', bounded: #{(selected_branch == nil) or (selected_branch and selected_branch.map_location.id == loc.id)}}"}
+ %a.map-link{href:"#"}
+ = loc.title
+ .info-box
+ %strong
+ = loc.title
+ %br
+ = loc.venue
+ %em
+ = loc.details
+ %br
+ = loc.address
+ %br
+ = "#{loc.city}, #{loc.postcode}"
+ %br
+ - loc.branches.each do |branch|
+ = link_to branch.day_and_time, branch_path(branch), :'onclick' => "javascript:showBranch(event,#{branch.id});"
+ / #%a{:'onclick' => }
+ / = branch.day_and_time
+ / / = link_to branch.day_and_time, branch_path(branch), :'data-id' => , :'onclick' => "showBranch(#{branch.id})"
+ %br
+
View
4 app/views/map_locations/_locations.html.erb → app/views/map_locations/_locations.html.erb.old
@@ -15,10 +15,8 @@
<ul>
<% loc.branches.each do |branch| %>
<li>
- <!-- <%= branch.title %>
+ <%= branch.title %>
<%= branch.day %>
- <%= branch.start_at %>
- <%= branch.end_at %> -->
<p>
<%= image_fu branch.photo, "80x80#c" %>
</p>
View
6 app/views/map_locations/_map.haml
@@ -0,0 +1,6 @@
+.postcode
+ = label_tag 'postocode', 'Your postcode:'
+ = text_field_tag 'postcode', '', {:type => "search", :placeholder => "Enter postcode..." }
+ = submit_tag 'Go'
+#googlemap
+
View
14 app/views/map_locations/_map.html.erb
@@ -1,14 +0,0 @@
-<div id="googlemap" style="width:<%= width %>px; height:<%= height %>px;"></div>
-
-<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" %>
-<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=<%= RefinerySetting.find_or_set(:google_maps_api_key, '') %>"></script>
-<%= javascript_include_tag "mapiconmaker.js" %>
-<%= javascript_include_tag "markermanager.js" %>
-<%= javascript_include_tag "jquery.metadata.js" %>
-<%= javascript_include_tag "jquery.jmapping.min.js" %>
-
-<script type="text/javascript">
- $(document).ready(function(){
- $('#googlemap').jMapping();
- });
-</script>
View
3  app/views/map_locations/_map_single.html.erb
@@ -13,6 +13,7 @@
</p>
</section>
+
<section class="map">
- <iframe width="400" height="200" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?q=<%= CGI::escape(map_location.address+' '+map_location.city+' '+map_location.postcode) %>&amp;z=14&amp;output=embed"></iframe>
+ <iframe width="400" height="200" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?q=<%= CGI::escape(map_location.address+' '+map_location.city+' '+map_location.postcode) %>&amp;z=14&amp;output=embed"></iframe>
</section>
Please sign in to comment.
Something went wrong with that request. Please try again.