egov_utils 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/egov_utils/address.rb +11 -1
- data/app/views/egov_utils/addresses/_form.html.haml +1 -1
- data/lib/egov_utils/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b4f8d1e7b832f1e39353978e0227fe9fe46c337
|
4
|
+
data.tar.gz: f196d70f9d135cd16c39dbc26d95348f35892868
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d49271e7e63b551bc7ea734aca1051f53dd4927b9924bd02714a01b9b3f5b4cbab5b97b15bde02db068c544ccc6c17a13577f8d681057a3ec02533728dcfeab1
|
7
|
+
data.tar.gz: dba5631a2185d2a7b26f9acbec86a57a1ecc74ba55a88ce734ecc71d1e91d83db1471d69f78957406d03782e6edb35e3913b2067cd898a9443b3a259c870dc41
|
@@ -5,6 +5,8 @@ module EgovUtils
|
|
5
5
|
|
6
6
|
validates :street, :city, length: 3..255
|
7
7
|
validates :postcode, numericality: { only_integer: true }
|
8
|
+
validates :district, inclusion: { in: :district_names }
|
9
|
+
validates :region, inclusion: { in: :region_names }
|
8
10
|
|
9
11
|
District = Struct.new(:id, :name, :region_id)
|
10
12
|
Region = Struct.new(:id, :name)
|
@@ -34,8 +36,16 @@ module EgovUtils
|
|
34
36
|
regions.detect{|r| r[:id] == district[:region_id] } if district
|
35
37
|
end
|
36
38
|
|
39
|
+
def district_names
|
40
|
+
self.class.districts.collect{|r| r[:name]}
|
41
|
+
end
|
42
|
+
def region_names
|
43
|
+
self.class.regions.collect{|r| r[:name]}
|
44
|
+
end
|
45
|
+
|
46
|
+
|
37
47
|
def district=(value)
|
38
|
-
self.region = self.class.region_for_district(value)[:name
|
48
|
+
self.region = self.class.region_for_district(value).try(:[], :name)
|
39
49
|
super
|
40
50
|
end
|
41
51
|
|
@@ -9,7 +9,7 @@
|
|
9
9
|
.col-12
|
10
10
|
= form.text_field :city
|
11
11
|
= form.text_field :postcode
|
12
|
-
= form.
|
12
|
+
= form.select :district, EgovUtils::Address.districts.collect{|r| [r[:name],r[:name]]}
|
13
13
|
= form.select :region, EgovUtils::Address.regions.collect{|r| [r[:name],r[:name]]}
|
14
14
|
-# form.text_field :country
|
15
15
|
%div.validation-button
|
data/lib/egov_utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egov_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -329,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
329
329
|
version: '0'
|
330
330
|
requirements: []
|
331
331
|
rubyforge_project:
|
332
|
-
rubygems_version: 2.
|
332
|
+
rubygems_version: 2.6.13
|
333
333
|
signing_key:
|
334
334
|
specification_version: 4
|
335
335
|
summary: The eGoverment utilities is set of functionalities to support basic eGoverment
|