inline_forms 1.2.9 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/app/controllers/geo_code_curacao_controller.rb +2 -5
- data/lib/app/helpers/form_elements/geo_code_curacao.rb +2 -2
- data/lib/app/models/geo_code_curacao.rb +7 -10
- data/lib/app/views/geo_code_curacao/list_streets.html.erb +1 -0
- data/lib/app/views/geo_code_curacao/list_streets.js.erb +1 -0
- data/lib/inline_forms/version.rb +1 -1
- metadata +7 -5
@@ -1,12 +1,9 @@
|
|
1
1
|
# Used in autocomplete
|
2
2
|
#
|
3
3
|
class GeoCodeCuracaoController < ApplicationController
|
4
|
-
def
|
4
|
+
def list_streets
|
5
5
|
@term = params[:term]
|
6
|
-
|
7
|
-
format.html { render 'inline_forms/_list', :layout => 'inline_forms' } unless @Klass.not_accessible_through_html?
|
8
|
-
format.js { render :list }
|
9
|
-
end
|
6
|
+
@streets = GeoCodeCuracao.lookup('%' + @term + '%')
|
10
7
|
end
|
11
8
|
|
12
9
|
end
|
@@ -10,7 +10,7 @@ def geo_code_curacao_edit(object, attribute)
|
|
10
10
|
out = text_field_tag attribute, attribute_value
|
11
11
|
out << '<script>
|
12
12
|
$( "#geo_code_curacao" ).autocomplete({
|
13
|
-
source: "/
|
13
|
+
source: "/geo_code_curacao",
|
14
14
|
minLength: 2,
|
15
15
|
});
|
16
16
|
</script>'.html_safe
|
@@ -18,7 +18,7 @@ end
|
|
18
18
|
|
19
19
|
def geo_code_curacao_update(object, attribute)
|
20
20
|
# extract the geocode
|
21
|
-
geo_code = params[attribute
|
21
|
+
geo_code = params[attribute].scan(/\d\d\d\d\d\d/).to_s || nil
|
22
22
|
object[attribute.to_sym] = GeoCodeCuracao.new(geo_code).valid? ? geo_code : nil
|
23
23
|
end
|
24
24
|
|
@@ -22,7 +22,6 @@ class GeoCodeCuracao
|
|
22
22
|
zone_code = decoded[0]
|
23
23
|
neighbourhood_code = decoded[1]
|
24
24
|
street_code = decoded[2]
|
25
|
-
#Hash[*['zone','neighbourhood','street'].zip(gecode.to_s.scan(/\d\d/).map(&:to_i)).flatten]
|
26
25
|
self.street = Street.find_by_ZONECODE_and_NBRHCODE_and_STREETCODE(zone_code,neighbourhood_code,street_code)
|
27
26
|
self.neighbourhood = Neighbourhood.find_by_ZONECODE_and_NBRHCODE(zone_code,neighbourhood_code) if self.street
|
28
27
|
self.zone = Zone.find_by_ZONECODE(zone_code) if self.street
|
@@ -36,13 +35,9 @@ class GeoCodeCuracao
|
|
36
35
|
"#{street.name}, #{zone.name}"
|
37
36
|
end
|
38
37
|
|
39
|
-
def self.
|
40
|
-
|
41
|
-
|
42
|
-
# ActiveRecord::Base.sanitize_sql_for_conditions can not be called from here. Why?
|
43
|
-
# http://www.ruby-forum.com/topic/80357, active_record/connection_adapter/Quoting.rb
|
44
|
-
street = find_options[:conditions][1].gsub(/\\/, '\&\&').gsub(/'/, "''")
|
45
|
-
sql = "select CONCAT( CONCAT_WS( ', ', S.NAME, B.NAME, Z.NAME), ' (', LPAD( S.ZONECODE, 2, '0' ), LPAD( S.NBRHCODE, 2, '0' ), LPAD( S.STREETCODE, 2, '0' ), ')' ) AS street
|
38
|
+
def self.lookup(term)
|
39
|
+
street = term.gsub(/\\/, '\&\&').gsub(/'/, "''")
|
40
|
+
sql = "select CONCAT( CONCAT_WS( ', ', S.NAME, B.NAME, Z.NAME), ' (', LPAD( S.ZONECODE, 2, '0' ), LPAD( S.NBRHCODE, 2, '0' ), LPAD( S.STREETCODE, 2, '0' ), ')' )
|
46
41
|
FROM Straatcode S, Buurten B, Zones Z
|
47
42
|
WHERE
|
48
43
|
B.RECORDTYPE='NBRHOOD'
|
@@ -52,8 +47,10 @@ class GeoCodeCuracao
|
|
52
47
|
AND S.NBRHCODE = B.NBRHCODE
|
53
48
|
AND S.NAME LIKE '#{street}'
|
54
49
|
ORDER BY S.NAME"
|
55
|
-
|
50
|
+
q = []
|
51
|
+
ActiveRecord::Base.connection.execute(sql).to_a.each do |r|
|
52
|
+
q << { :label => r[0] }
|
56
53
|
end
|
54
|
+
q.to_json.html_safe
|
57
55
|
end
|
58
|
-
|
59
56
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @streets.each { |s| puts s} %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @streets %>
|
data/lib/inline_forms/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inline_forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 1.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ace Suares
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-02-
|
18
|
+
date: 2012-02-07 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec-rails
|
@@ -182,6 +182,8 @@ files:
|
|
182
182
|
- lib/app/views/devise/sessions/new.html.erb
|
183
183
|
- lib/app/views/devise/shared/_links.erb
|
184
184
|
- lib/app/views/devise/unlocks/new.html.erb
|
185
|
+
- lib/app/views/geo_code_curacao/list_streets.html.erb
|
186
|
+
- lib/app/views/geo_code_curacao/list_streets.js.erb
|
185
187
|
- lib/app/views/inline_forms/_close.html.erb
|
186
188
|
- lib/app/views/inline_forms/_edit.html.erb
|
187
189
|
- lib/app/views/inline_forms/_header.html.erb
|