egov_utils 1.5.0.alpha3 → 1.5.0.alpha5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/egov_utils/towns_controller.rb +11 -0
- data/app/models/egov_utils/address.rb +10 -0
- data/app/services/egov_utils/iszr/addresses/fetch_for_natural_person.rb +2 -2
- data/app/services/egov_utils/iszr/client.rb +23 -0
- data/app/services/egov_utils/iszr/find_result_by_aifo.rb +86 -0
- data/app/services/egov_utils/iszr/natural_people/create_request.rb +69 -26
- data/app/services/egov_utils/iszr/natural_people/search.rb +2 -2
- data/app/services/egov_utils/iszr/request.rb +20 -2
- data/app/views/egov_utils/people/_new_form.html.haml +51 -15
- data/app/views/egov_utils/users/index.html.haml +1 -0
- data/config/obec.json +46097 -0
- data/config/routes.rb +2 -0
- data/lib/egov_utils/version.rb +1 -1
- data/lib/egov_utils.rb +1 -0
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 046c5759eba0d80446d93f8a3c3b8ce4dc18a83aa7fd5c562a5f5cb4dcac7359
|
4
|
+
data.tar.gz: b8b0bbb2f87977252bca9a46a14d62149ecd9bee5d153b54e4fd6aae3dbbcda3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80a826cb596f3add692963cc1b6b3924138c48409b0c3e91a0459ecd6712573de12f8ca22f2969c54828a89e69889ba9dc8f8bcd8a09fbfa064d96d7fae2e97f
|
7
|
+
data.tar.gz: 44ce23500051b01ac765299531ff15f9fed61ea7fd11c04056939a5fa0419103d0fb8902e3fc25783880737b9e222ac91a709768142412936512c9002c31483e
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module EgovUtils
|
2
|
+
class TownsController < ApplicationController
|
3
|
+
def index
|
4
|
+
selected = EgovUtils::Address.towns.lazy.select do |town|
|
5
|
+
/\A#{params[:term]}/i.match?(town.name)
|
6
|
+
end.first(10)
|
7
|
+
|
8
|
+
render json: { towns: selected.map(&:to_h) }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -18,6 +18,7 @@ module EgovUtils
|
|
18
18
|
District = Struct.new(:id, :name, :region_id)
|
19
19
|
Region = Struct.new(:id, :name)
|
20
20
|
Country = Struct.new(:iso_id, :code2, :code3, :name)
|
21
|
+
Town = Struct.new(:id, :name, :district_name)
|
21
22
|
|
22
23
|
CZ_ISO_CODE = '203'
|
23
24
|
|
@@ -51,6 +52,15 @@ module EgovUtils
|
|
51
52
|
@regions
|
52
53
|
end
|
53
54
|
|
55
|
+
def self.towns
|
56
|
+
@towns ||= begin
|
57
|
+
towns = File.read(EgovUtils::Engine.root.join('config', 'obec.json'))
|
58
|
+
JSON.parse(towns).map do |town|
|
59
|
+
Town.new(*town.slice('code', 'name', 'district_name').values)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
54
64
|
def self.region_for_district(district_name)
|
55
65
|
district = districts.detect{|d| d[:name] == district_name }
|
56
66
|
regions.detect{|r| r[:id] == district[:region_id] } if district
|
@@ -10,9 +10,9 @@ module EgovUtils
|
|
10
10
|
strategy_class.run!(remote_id:)
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def fetch_result
|
14
14
|
if Rails.env.production?
|
15
|
-
EgovUtils::Iszr::
|
15
|
+
EgovUtils::Iszr::FindResultByAifo
|
16
16
|
else
|
17
17
|
EgovUtils::Iszr::Addresses::FetchForNaturalPerson::FromSampleData
|
18
18
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EgovUtils
|
4
|
+
module Iszr
|
5
|
+
class Client
|
6
|
+
def initialize(message)
|
7
|
+
@client = Savon.client(wsdl: EgovUtils::Settings['iszr']['endpoint'], log: true, log_level: :info, ssl_verify_mode: :none)
|
8
|
+
@message = message
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
client.call(
|
13
|
+
:get_data,
|
14
|
+
message: { 'tns:inputXml' => message }
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :client, :message
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EgovUtils
|
4
|
+
module Iszr
|
5
|
+
class FindResultByAifo < Request
|
6
|
+
string :remote_id
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def handle_response!
|
11
|
+
EgovUtils::Address.new(
|
12
|
+
street: response_body.xpath('//UliceNazev').text,
|
13
|
+
house_number: response_body.xpath('//CisloDomovni').text,
|
14
|
+
orientation_number: response_body.xpath('//CisloOrientacni').text,
|
15
|
+
city: response_body.xpath('//ObecNazev').text,
|
16
|
+
postcode: response_body.xpath('//PostaKod').text,
|
17
|
+
egov_identifier: response_body.xpath('//AdresniMistoKod').text,
|
18
|
+
country: 203,
|
19
|
+
district: district.name,
|
20
|
+
region: region.name
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def district
|
25
|
+
@district ||= begin
|
26
|
+
district =
|
27
|
+
EgovUtils::Address.towns.find do
|
28
|
+
_1.id == response_body.xpath('//ObecKod').text
|
29
|
+
end.district_name
|
30
|
+
|
31
|
+
EgovUtils::Address.districts.find { _1.name == district }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def region
|
36
|
+
@region ||=
|
37
|
+
EgovUtils::Address.regions.find { _1.id == district.region_id }
|
38
|
+
end
|
39
|
+
|
40
|
+
def body
|
41
|
+
Nokogiri::XML::Builder.new do |xml|
|
42
|
+
xml[service_id].RobCtiAifo2(
|
43
|
+
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
44
|
+
'xsi:schemaLocation' => 'urn:cz:isvs:iszr:schemas:IszrRobCtiAifo2:v1 IszrRobCtiAifo2.xsd',
|
45
|
+
'xmlns:abs' => 'urn:cz:isvs:iszr:schemas:IszrAbstract:v1',
|
46
|
+
'xmlns:E276' => 'urn:cz:isvs:iszr:schemas:IszrRobCtiAifo2:v1',
|
47
|
+
'xmlns:reg' => 'urn:cz:isvs:reg:schemas:RegTypy:v1',
|
48
|
+
'xmlns:rod' => 'urn:cz:isvs:rob:schemas:RobDotazyData:v1',
|
49
|
+
'xmlns:rob' => 'urn:cz:isvs:rob:schemas:RobTypy:v1'
|
50
|
+
) {
|
51
|
+
xml['abs'].ZadostInfo {
|
52
|
+
xml['reg'].CasZadosti Time.current.iso8601
|
53
|
+
xml['reg'].Agenda EgovUtils::Settings['iszr']['agenda']
|
54
|
+
xml['reg'].AgendovaRole EgovUtils::Settings['iszr']['agendova_role']
|
55
|
+
xml['reg'].Ovm '00025429'
|
56
|
+
xml['reg'].Ais EgovUtils::Settings['iszr']['ais']
|
57
|
+
xml['reg'].Subjekt '00025429'
|
58
|
+
xml['reg'].Uzivatel 'Administrator'
|
59
|
+
xml['reg'].DuvodUcel 'ztotozneni'
|
60
|
+
xml['reg'].AgendaZadostId SecureRandom.uuid
|
61
|
+
}
|
62
|
+
xml['abs'].AutorizaceInfo {
|
63
|
+
xml['abs'].SeznamUdaju 'Aifo Prijmeni Jmeno DatumNarozeni RUIANCti AdresaPobytu MistoNarozeni'
|
64
|
+
}
|
65
|
+
xml['abs'].MapaAifo(nacistData: true) {
|
66
|
+
xml['reg'].PrevodAifo {
|
67
|
+
xml['reg'].LokalniAifo 1
|
68
|
+
xml['reg'].GlobalniAifo remote_id
|
69
|
+
}
|
70
|
+
}
|
71
|
+
xml[service_id].Zadost {
|
72
|
+
xml[service_id].RobCtiAifo2Data {
|
73
|
+
xml['rod'].Aifo 1
|
74
|
+
xml['rod'].VyuzitiPoskytnuti 'poskytnuti'
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def service_id
|
82
|
+
'E276'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -19,31 +19,70 @@ module EgovUtils
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def response_error_code
|
23
|
+
@response_error_code ||=
|
24
|
+
response_body.xpath('//VysledekSubKod').last&.text&.presence
|
25
|
+
end
|
26
|
+
|
27
|
+
def internal_error_code
|
28
|
+
return unless response_error_code
|
29
|
+
|
30
|
+
code = if response_error_code == 'ZAZNAM NENALEZEN'
|
31
|
+
"not_found"
|
32
|
+
elsif response_error_code == 'PREKROCEN POCET'
|
33
|
+
"multiple_records_found"
|
34
|
+
end
|
35
|
+
|
36
|
+
if birth_place.present?
|
37
|
+
"extended_search_#{code}"
|
38
|
+
else
|
39
|
+
code
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def handle_response!
|
44
|
+
if internal_error_code
|
45
|
+
errors.add(:base, internal_error_code)
|
46
|
+
return
|
47
|
+
end
|
48
|
+
|
49
|
+
EgovUtils::Services::Iszr::NaturalPeople.new(
|
50
|
+
firstname: response_body.xpath('//Jmeno').text.capitalize,
|
51
|
+
lastname: response_body.xpath('//Prijmeni').text.capitalize,
|
52
|
+
birth_date: response_body.xpath('//DatumNarozeni').text,
|
53
|
+
birth_place: response_body.xpath('//Lokalita/Nazev').text,
|
54
|
+
remote_id: response_body.xpath('//GlobalniAifo').text
|
55
|
+
)
|
56
|
+
|
57
|
+
end
|
58
|
+
|
22
59
|
def search_stage_one
|
23
60
|
Nokogiri::XML::Builder.new do |xml|
|
24
|
-
xml[
|
61
|
+
xml[service_id].RobCtiPodleUdaju2(
|
25
62
|
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
26
|
-
'xsi:schemaLocation' => 'urn:cz:isvs:iszr:schemas:
|
63
|
+
'xsi:schemaLocation' => 'urn:cz:isvs:iszr:schemas:IszrRobCtiPodleUdaju2:v1 IszrRobCtiPodleUdaju2.xsd',
|
27
64
|
'xmlns:abs' => 'urn:cz:isvs:iszr:schemas:IszrAbstract:v1',
|
28
|
-
'xmlns:
|
65
|
+
'xmlns:E278' => 'urn:cz:isvs:iszr:schemas:IszrRobCtiPodleUdaju2:v1',
|
29
66
|
'xmlns:reg' => 'urn:cz:isvs:reg:schemas:RegTypy:v1',
|
30
67
|
'xmlns:rod' => 'urn:cz:isvs:rob:schemas:RobDotazyData:v1',
|
31
68
|
'xmlns:rob' => 'urn:cz:isvs:rob:schemas:RobTypy:v1'
|
32
69
|
) {
|
33
70
|
xml['abs'].ZadostInfo {
|
34
|
-
xml['reg'].CasZadosti Time.current
|
35
|
-
xml['reg'].Agenda '
|
36
|
-
xml['reg'].AgendovaRole '
|
71
|
+
xml['reg'].CasZadosti Time.current.iso8601
|
72
|
+
xml['reg'].Agenda EgovUtils::Settings['iszr']['agenda']
|
73
|
+
xml['reg'].AgendovaRole EgovUtils::Settings['iszr']['agendova_role']
|
37
74
|
xml['reg'].Ovm '00025429'
|
38
|
-
xml['reg'].Ais '
|
39
|
-
xml['reg'].
|
40
|
-
xml['reg'].
|
75
|
+
xml['reg'].Ais EgovUtils::Settings['iszr']['ais']
|
76
|
+
xml['reg'].Subjekt '00025429'
|
77
|
+
xml['reg'].Uzivatel 'Administrator'
|
78
|
+
xml['reg'].DuvodUcel 'ztotozneni'
|
79
|
+
xml['reg'].AgendaZadostId SecureRandom.uuid
|
41
80
|
}
|
42
81
|
xml['abs'].AutorizaceInfo {
|
43
|
-
xml['abs'].SeznamUdaju 'Aifo Prijmeni Jmeno
|
82
|
+
xml['abs'].SeznamUdaju 'Aifo Prijmeni Jmeno DatumNarozeni RUIANCti AdresaPobytu MistoNarozeni'
|
44
83
|
}
|
45
|
-
xml[
|
46
|
-
xml[
|
84
|
+
xml[service_id].Zadost {
|
85
|
+
xml[service_id].RobCtiPodleUdaju2Data {
|
47
86
|
xml['rod'].DatumNarozeni birth_date
|
48
87
|
xml['rod'].Jmeno firstname
|
49
88
|
xml['rod'].Prijmeni lastname
|
@@ -55,32 +94,36 @@ module EgovUtils
|
|
55
94
|
|
56
95
|
def search_stage_two
|
57
96
|
Nokogiri::XML::Builder.new do |xml|
|
58
|
-
xml[
|
97
|
+
xml[service_id].RobCtiPodleUdaju2(
|
59
98
|
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
60
|
-
'xsi:schemaLocation' => 'urn:cz:isvs:iszr:schemas:
|
99
|
+
'xsi:schemaLocation' => 'urn:cz:isvs:iszr:schemas:IszrRobCtiPodleUdaju2:v1 IszrRobCtiPodleUdaju2.xsd',
|
61
100
|
'xmlns:abs' => 'urn:cz:isvs:iszr:schemas:IszrAbstract:v1',
|
62
|
-
'xmlns:
|
101
|
+
'xmlns:E278' => 'urn:cz:isvs:iszr:schemas:IszrRobCtiPodleUdaju2:v1',
|
63
102
|
'xmlns:reg' => 'urn:cz:isvs:reg:schemas:RegTypy:v1',
|
64
103
|
'xmlns:rod' => 'urn:cz:isvs:rob:schemas:RobDotazyData:v1',
|
65
104
|
'xmlns:rob' => 'urn:cz:isvs:rob:schemas:RobTypy:v1'
|
66
105
|
) {
|
67
106
|
xml['abs'].ZadostInfo {
|
68
|
-
xml['reg'].CasZadosti Time.current
|
69
|
-
xml['reg'].Agenda '
|
70
|
-
xml['reg'].AgendovaRole '
|
107
|
+
xml['reg'].CasZadosti Time.current.iso8601
|
108
|
+
xml['reg'].Agenda EgovUtils::Settings['iszr']['agenda']
|
109
|
+
xml['reg'].AgendovaRole EgovUtils::Settings['iszr']['agendova_role']
|
71
110
|
xml['reg'].Ovm '00025429'
|
72
|
-
xml['reg'].Ais '
|
73
|
-
xml['reg'].
|
74
|
-
xml['reg'].
|
111
|
+
xml['reg'].Ais EgovUtils::Settings['iszr']['ais']
|
112
|
+
xml['reg'].Subjekt '00025429'
|
113
|
+
xml['reg'].Uzivatel 'Administrator'
|
114
|
+
xml['reg'].DuvodUcel 'ztotozneni'
|
115
|
+
xml['reg'].AgendaZadostId SecureRandom.uuid
|
75
116
|
}
|
76
117
|
xml['abs'].AutorizaceInfo {
|
77
|
-
xml['abs'].SeznamUdaju 'Aifo Prijmeni Jmeno
|
118
|
+
xml['abs'].SeznamUdaju 'Aifo Prijmeni Jmeno DatumNarozeni RUIANCti AdresaPobytu MistoNarozeni'
|
78
119
|
}
|
79
|
-
xml[
|
80
|
-
xml[
|
81
|
-
xml['rod'].MistoNarozeni birth_place
|
120
|
+
xml[service_id].Zadost {
|
121
|
+
xml[service_id].RobCtiPodleUdaju2Data {
|
82
122
|
xml['rod'].DatumNarozeni birth_date
|
83
123
|
xml['rod'].Jmeno firstname
|
124
|
+
xml['rod'].MistoNarozeni {
|
125
|
+
xml['rob'].NarozeniCr birth_place
|
126
|
+
}
|
84
127
|
xml['rod'].Prijmeni lastname
|
85
128
|
}
|
86
129
|
}
|
@@ -89,7 +132,7 @@ module EgovUtils
|
|
89
132
|
end
|
90
133
|
|
91
134
|
def service_id
|
92
|
-
'
|
135
|
+
'E278'
|
93
136
|
end
|
94
137
|
end
|
95
138
|
end
|
@@ -4,7 +4,7 @@ module EgovUtils
|
|
4
4
|
class Search < ActiveInteraction::Base
|
5
5
|
string :firstname
|
6
6
|
string :lastname
|
7
|
-
|
7
|
+
string :birth_date
|
8
8
|
string :birth_place, default: nil
|
9
9
|
|
10
10
|
validates :firstname, :lastname, :birth_date, presence: true
|
@@ -20,7 +20,7 @@ module EgovUtils
|
|
20
20
|
|
21
21
|
def find_person_service
|
22
22
|
if Rails.env.production?
|
23
|
-
EgovUtils::Iszr::NaturalPeople::
|
23
|
+
EgovUtils::Iszr::NaturalPeople::CreateRequest
|
24
24
|
else
|
25
25
|
EgovUtils::Iszr::NaturalPeople::DevSearch
|
26
26
|
end
|
@@ -2,7 +2,7 @@ module EgovUtils
|
|
2
2
|
module Iszr
|
3
3
|
class Request < ActiveInteraction::Base
|
4
4
|
def execute
|
5
|
-
|
5
|
+
handle_response!
|
6
6
|
end
|
7
7
|
|
8
8
|
private
|
@@ -19,7 +19,7 @@ module EgovUtils
|
|
19
19
|
}
|
20
20
|
xml.SenderDetails {
|
21
21
|
xml.Authentication(type: 'clear') {
|
22
|
-
xml.ISId '
|
22
|
+
xml.ISId EgovUtils::Settings['iszr']['ais']
|
23
23
|
}
|
24
24
|
}
|
25
25
|
}
|
@@ -31,6 +31,24 @@ module EgovUtils
|
|
31
31
|
def encoded_body(body)
|
32
32
|
Base64.encode64(body.to_xml)
|
33
33
|
end
|
34
|
+
|
35
|
+
def response
|
36
|
+
@response ||= Client.new(envelope.to_xml).call
|
37
|
+
end
|
38
|
+
|
39
|
+
def response_body
|
40
|
+
@response_body ||= begin
|
41
|
+
body = Nokogiri::XML(
|
42
|
+
response.body[:get_data_response][:get_data_result]
|
43
|
+
).xpath("//Body").text
|
44
|
+
|
45
|
+
Nokogiri::XML(Base64.decode64(body)).remove_namespaces!
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def handle_response!
|
50
|
+
response_body
|
51
|
+
end
|
34
52
|
end
|
35
53
|
end
|
36
54
|
end
|
@@ -18,16 +18,27 @@
|
|
18
18
|
= label_tag 'birth_date', 'Datum narození'
|
19
19
|
= date_field_tag :birth_date, {}, class: 'form-control'
|
20
20
|
= link_to 'Vyhledat', {}, class: 'btn btn-primary'
|
21
|
-
.
|
22
|
-
.
|
23
|
-
.
|
24
|
-
.
|
25
|
-
.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
21
|
+
.legal_person
|
22
|
+
.row
|
23
|
+
= form.fields_for(:legal_person, person.legal_person || EgovUtils::LegalPerson.new) do |fields|
|
24
|
+
.col-12= fields.text_field(:name)
|
25
|
+
.col-12.col-sm-6= fields.text_field(:ico)
|
26
|
+
.col-12.col-sm-6= fields.select2 :legal_form, list_values_for_select(azahara_attribute_for(EgovUtils::LegalPerson, 'legal_form'))
|
27
|
+
.row
|
28
|
+
.col-12
|
29
|
+
= form.fields_for(:residence, person.residence || EgovUtils::Address.new) do |fields|
|
30
|
+
= render 'egov_utils/addresses/form', form: fields, address: fields.object
|
31
|
+
|
32
|
+
-# .legal-person-row.identification-form.legal_person.row
|
33
|
+
-# .col-12
|
34
|
+
-# .card
|
35
|
+
-# .card-header Ztotožnění právnické osoby
|
36
|
+
-# .card-body
|
37
|
+
-# .form
|
38
|
+
-# .form-group
|
39
|
+
-# = label_tag 'ico', 'IČO'
|
40
|
+
-# = text_field_tag :ico, {}, class: 'form-control'
|
41
|
+
-# = link_to 'Vyhledat', nil, class: 'btn btn-primary'
|
31
42
|
= form.hidden_field :remote_id
|
32
43
|
|
33
44
|
:javascript
|
@@ -41,9 +52,11 @@
|
|
41
52
|
firstname: $npr.find('input[name=firstname]').val(),
|
42
53
|
lastname: $npr.find('input[name=lastname]').val(),
|
43
54
|
birth_date: $npr.find('input[name=birth_date]').val(),
|
44
|
-
birth_place: $npr.find('
|
55
|
+
birth_place: $npr.find('select[name=birth_place]').val()
|
45
56
|
}
|
46
57
|
|
58
|
+
selected_birth_place = $npr.find('select[name=birth_place] option:selected').text().split('(')[0].trim();
|
59
|
+
|
47
60
|
$.ajax({
|
48
61
|
url: '/internals/iszr/search',
|
49
62
|
data: {
|
@@ -82,21 +95,44 @@
|
|
82
95
|
// Fill in the form with the data
|
83
96
|
$old_person_form.find("input[name*='[firstname]']").val(form_data.firstname);
|
84
97
|
$old_person_form.find("input[name*='[lastname]']").val(form_data.lastname);
|
85
|
-
$old_person_form.find("input[name*='[birth_place]']").val(
|
98
|
+
$old_person_form.find("input[name*='[birth_place]']").val(selected_birth_place);
|
86
99
|
$old_person_form.find("input[name*='[birth_date]']").val(form_data.birth_date);
|
87
100
|
}
|
88
101
|
else if(error_kind == 'multiple_results_found') {
|
89
102
|
$form_group = $('<div>').addClass('form-group');
|
90
103
|
$label = $('<label>').attr('for', 'birth_place').text('Místo narození');
|
91
|
-
$input = $('<
|
104
|
+
$input = $('<select>').attr('name', 'birth_place').addClass('form-control');
|
92
105
|
$form_group.append($label).append($input);
|
106
|
+
$input.select2({
|
107
|
+
ajax: {
|
108
|
+
url: '/internals/towns',
|
109
|
+
data: function (params) {
|
110
|
+
var query = {
|
111
|
+
term: params.term
|
112
|
+
}
|
113
|
+
|
114
|
+
return query;
|
115
|
+
},
|
116
|
+
processResults: function(data) {
|
117
|
+
return {
|
118
|
+
results: data.towns.map(function(val) {
|
119
|
+
return {
|
120
|
+
id: val.id,
|
121
|
+
text: `${val.name} (okr. ${val.district_name})`
|
122
|
+
}
|
123
|
+
})
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
});
|
128
|
+
|
93
129
|
$npr.find('.card-body .form .btn').before($form_group);
|
94
130
|
|
95
131
|
$icon = $('<i>').addClass('fa').addClass('fa-times');
|
96
132
|
$error_div = $('<div>').addClass('alert').addClass('alert-danger').append($icon).append(' Nalezeno více osob, zadejte místo narození');
|
97
133
|
$npr.find('.card-body').prepend($error_div);
|
98
134
|
}
|
99
|
-
else if(error_kind == 'extended_search_multiple_records_found') {
|
135
|
+
else if(error_kind == 'extended_search_multiple_records_found' || error_kind == 'extended_search_not_found') {
|
100
136
|
$icon = $('<i>').addClass('fa').addClass('fa-times');
|
101
137
|
$error_div = $('<div>').addClass('alert').addClass('alert-danger').append($icon).append(' Nalezeno více osob, pokračujte, prosím, ručním zadáním údajů');
|
102
138
|
|
@@ -108,7 +144,7 @@
|
|
108
144
|
// Fill in the form with the data
|
109
145
|
$('.old-person-form').find("input[name*='[firstname]']").val(form_data.firstname);
|
110
146
|
$('.old-person-form').find("input[name*='[lastname]']").val(form_data.lastname);
|
111
|
-
$('.old-person-form').find("input[name*='[birth_place]']").val(
|
147
|
+
$('.old-person-form').find("input[name*='[birth_place]']").val(selected_birth_place);
|
112
148
|
$('.old-person-form').find("input[name*='[birth_date]']").val(form_data.birth_date);
|
113
149
|
}
|
114
150
|
}
|
@@ -3,6 +3,7 @@
|
|
3
3
|
= bootstrap_form_tag(url: egov_utils.users_path, method: :get, layout: :inline) do |f|
|
4
4
|
.form-group
|
5
5
|
= f.text_field :search, value: params[:search], label: false, placeholder: t('label_search'), skip_label: true
|
6
|
+
= f.hidden_field :default_scope, value: params[:default_scope]
|
6
7
|
= f.submit 'Vyhledat', class: 'btn btn-primary btn-sm'
|
7
8
|
|
8
9
|
%table.table.table-striped
|