From dfbc3f958a4252a11fd42e6844cd42d74242ecfb Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Thu, 27 Mar 2014 16:43:34 -0600 Subject: [PATCH] mapa arreglado, falta checar bugs en los markers, inicia forma de #9 --- app/assets/javascripts/preguntas.js.coffee | 3 +++ app/assets/javascripts/static_pages.js | 16 +++++++++++++++- app/assets/stylesheets/preguntas.css.scss | 3 +++ app/controllers/preguntas_controller.rb | 10 ++++++++++ app/helpers/preguntas_helper.rb | 2 ++ app/views/static_pages/index.html.haml | 8 ++++++++ config/routes.rb | 2 ++ spec/controllers/preguntas_controller_spec.rb | 5 +++++ spec/helpers/preguntas_helper_spec.rb | 15 +++++++++++++++ 9 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/preguntas.js.coffee create mode 100644 app/assets/stylesheets/preguntas.css.scss create mode 100644 app/controllers/preguntas_controller.rb create mode 100644 app/helpers/preguntas_helper.rb create mode 100644 spec/controllers/preguntas_controller_spec.rb create mode 100644 spec/helpers/preguntas_helper_spec.rb diff --git a/app/assets/javascripts/preguntas.js.coffee b/app/assets/javascripts/preguntas.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/preguntas.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/static_pages.js b/app/assets/javascripts/static_pages.js index 2ca4704..123b18f 100644 --- a/app/assets/javascripts/static_pages.js +++ b/app/assets/javascripts/static_pages.js @@ -33,6 +33,7 @@ function getCentros(lat, lng, busqueda) { } else { API_ENDPOINT = "/hospitales.json" } + console.log(API_ENDPOINT); var prom = $.ajax({ url: API + API_ENDPOINT, cache: false, @@ -93,6 +94,9 @@ function getCentros(lat, lng, busqueda) { //*********/ $(document).ready(function() { getCentros(); + submit_ajax_form(); + + $('.vendor-heading').click(function() { toggleVendor($(this)); }); @@ -123,12 +127,22 @@ $(document).ready(function() { }); +function submit_ajax_form() { + $('#preguntas').bind('ajax:success', function(e,data,status,xhr) { + console.log(xhr.responseText) + }).bind("ajax:error", function(e,xhr, status, error) { + console.log(error) + }); +} + + mapa.on('dragend', function(e) { console.log(e.distance); console.log(mapa.getBounds().getCenter().lat) console.log(mapa.getBounds().getCenter().lng) - if (mapa.getZoom() == 14){ + console.log(mapa.getZoom()) + if (mapa.getZoom() >= 14){ getCentros(mapa.getBounds().getCenter().lat,mapa.getBounds().getCenter().lng) showDataAtZoom(markers.getGeoJSON()); } else { diff --git a/app/assets/stylesheets/preguntas.css.scss b/app/assets/stylesheets/preguntas.css.scss new file mode 100644 index 0000000..d1b80ab --- /dev/null +++ b/app/assets/stylesheets/preguntas.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Preguntas controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/preguntas_controller.rb b/app/controllers/preguntas_controller.rb new file mode 100644 index 0000000..b06de0d --- /dev/null +++ b/app/controllers/preguntas_controller.rb @@ -0,0 +1,10 @@ +class PreguntasController < ApplicationController + + def preguntar + pregunta = params[:pregunta] + respond_to do |format| + format.json { render json: {response: "wololo", forma: {valor: pregunta}}} + end + end + +end diff --git a/app/helpers/preguntas_helper.rb b/app/helpers/preguntas_helper.rb new file mode 100644 index 0000000..ac03ebb --- /dev/null +++ b/app/helpers/preguntas_helper.rb @@ -0,0 +1,2 @@ +module PreguntasHelper +end diff --git a/app/views/static_pages/index.html.haml b/app/views/static_pages/index.html.haml index 3ea109e..ccdd004 100644 --- a/app/views/static_pages/index.html.haml +++ b/app/views/static_pages/index.html.haml @@ -6,6 +6,14 @@ %p De la Secretaría de Salud, SEDESA .vendor-data + #vendor-head-later.vendor-heading + ¿Qué necesitas? + #vendor-info-now.vendor-entries + = form_tag '/preguntas.json', id: "preguntas", method: 'post', remote: true do + = field_set_tag do + = label_tag :pregunta, "Pregunta" + = text_field_tag :pregunta + = submit_tag 'OK' #vendor-head-now.vendor-heading Cerca de aquí #vendor-info-now.vendor-entries{style: "display: none"} diff --git a/config/routes.rb b/config/routes.rb index be07d9f..1ac244a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,8 @@ get 'mapa' => 'static_pages#index', as: :mapa + post '/preguntas' => 'preguntas#preguntar', as: :preguntar + resources :places diff --git a/spec/controllers/preguntas_controller_spec.rb b/spec/controllers/preguntas_controller_spec.rb new file mode 100644 index 0000000..6252c0a --- /dev/null +++ b/spec/controllers/preguntas_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe PreguntasController do + +end diff --git a/spec/helpers/preguntas_helper_spec.rb b/spec/helpers/preguntas_helper_spec.rb new file mode 100644 index 0000000..26a6d14 --- /dev/null +++ b/spec/helpers/preguntas_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the PreguntasHelper. For example: +# +# describe PreguntasHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe PreguntasHelper do + pending "add some examples to (or delete) #{__FILE__}" +end