egov_utils 1.5.0.alpha2 → 1.5.0.alpha3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d41aad5c6d41d126b0bf8c535c3ee7b93ae029fb941aaf56a2fa50122e81c86f
4
- data.tar.gz: 85b31bd2904bf438a71671b591bd163c15fc5c40901f32760b3631aa138d77ba
3
+ metadata.gz: 00ea00706e2722fb8728d9c844bd50438b452a8de9445ef23390fb995b989db9
4
+ data.tar.gz: 9e678b274e4aa700191e2973675d94442a3545ed4c829ba5f2cc7e87015a5fbc
5
5
  SHA512:
6
- metadata.gz: ce7a35bd5dce15d5b01e16ba0c9c55af05885572339881fed1c81cb170c8e0af73d3c368f9fd78ae20ef8f743f22bf7cfb8ed28a0436681cb82d2e02a85a7f91
7
- data.tar.gz: b6e660e7e2fca843d0e06887b18c8659cdb0c316d59982b75cf5f0637fee5dd30a140c605664e054163392e850f20d4a3fea19d3c5a9aa7c29b5ac0db7a677c5
6
+ metadata.gz: 1ee1188c124f50fa5fc766c6438eb4883902972a75706ba9dd8ffc169396a3d91a0faca955c6aa8da70660a1b9da18febd9ffc89ed7b664842e70a64057363c9
7
+ data.tar.gz: 1b8233de8f1b144cf788e1d2b3bce95407dfeb54a01c9db26e1b6ecc22912e39407b5dd0191f8f176e6fec6022490874e176c77b0f2f0a5d0ba0cb3c697e1bde
@@ -11,14 +11,12 @@ module EgovUtils
11
11
  enum person_type: { natural: 1, legal: 16 }
12
12
 
13
13
  validates :person_entity, presence: true
14
- before_validation :set_residence_from_remote_id
14
+ before_validation :set_person_from_remote_id
15
15
 
16
16
  accepts_nested_attributes_for :residence, :natural_person, :legal_person
17
17
 
18
18
  delegate :fullname, :fullname=, to: :person_entity
19
19
 
20
- attr_accessor :remote_id
21
-
22
20
  def initialize(attributes = {})
23
21
  if attributes&.fetch(:remote_id, nil).present?
24
22
  super(attributes.slice(:remote_id, :person_type))
@@ -61,10 +59,9 @@ module EgovUtils
61
59
 
62
60
  private
63
61
 
64
- def set_residence_from_remote_id
62
+ def set_person_from_remote_id
65
63
  return unless remote_id.present?
66
64
 
67
- # binding.pry
68
65
  attributes =
69
66
  if person_type == 'natural'
70
67
  Iszr::NaturalPeople::SearchByRemoteId.run!(remote_id:)
@@ -1,6 +1,4 @@
1
1
  .person-form
2
- .row
3
- .col-12= form.select :person_type, enum_values_for_select(person.class, :person_type), {}, class: 'person-type-toggle'
4
2
  .natural_person.row
5
3
  = form.fields_for(:natural_person, person.natural_person || EgovUtils::NaturalPerson.new) do |fields|
6
4
  .col-12.col-md-2= fields.text_field(:title)
@@ -9,11 +7,11 @@
9
7
  .col-12.col-md-2= fields.text_field(:higher_title)
10
8
  .col-12.col-md-6= fields.date_field(:birth_date, min: Date.new(1920, 1, 1), max: Date.today, data: {'date-view-mode' => 'decades', 'date-use-current' => false, 'date-view-date' => Date.new(1950, 1, 1).to_s })
11
9
  .col-12.col-sm-6= fields.text_field(:birth_place)
12
- .legal_person.row
13
- = form.fields_for(:legal_person, person.legal_person || EgovUtils::LegalPerson.new) do |fields|
14
- .col-12= fields.text_field(:name)
15
- .col-12.col-sm-6= fields.text_field(:ico)
16
- .col-12.col-sm-6= fields.select2 :legal_form, list_values_for_select(azahara_attribute_for(EgovUtils::LegalPerson, 'legal_form'))
10
+ -# .legal_person.row
11
+ -# = form.fields_for(:legal_person, person.legal_person || EgovUtils::LegalPerson.new) do |fields|
12
+ -# .col-12= fields.text_field(:name)
13
+ -# .col-12.col-sm-6= fields.text_field(:ico)
14
+ -# .col-12.col-sm-6= fields.select2 :legal_form, list_values_for_select(azahara_attribute_for(EgovUtils::LegalPerson, 'legal_form'))
17
15
  .row
18
16
  .col-12
19
17
  = form.fields_for(:residence, person.residence || EgovUtils::Address.new) do |fields|
@@ -1,36 +1,38 @@
1
- .person-form
2
- .row
3
- .col-12= form.select :person_type, enum_values_for_select(person.class, :person_type), {}, class: 'person-type-toggle'
4
- .natural-person-row.identification-form.natural_person.row
5
- .col-12
6
- .card
7
- .card-header Ztotožnění fyzické osoby
8
- .card-body
9
- .form
10
- .form-group
11
- = label_tag 'firstname', 'Jméno'
12
- = text_field_tag :firstname, {}, class: 'form-control'
13
- .form-group
14
- = label_tag 'lastname', 'Příjmení'
15
- = text_field_tag :lastname, {}, class: 'form-control'
16
- .form-group
17
- = label_tag 'birth_date', 'Datum narození'
18
- = date_field_tag :birth_date, {}, class: 'form-control'
19
- = link_to 'Vyhledat', {}, class: 'btn btn-primary'
20
- .legal-person-row.identification-form.legal_person.row
21
- .col-12
22
- .card
23
- .card-header Ztotožnění právnické osoby
24
- .card-body
25
- .form
26
- .form-group
27
- = label_tag 'ico', 'IČO'
28
- = text_field_tag :ico, {}, class: 'form-control'
29
- = link_to 'Vyhledat', nil, class: 'btn btn-primary'
30
- = form.hidden_field :remote_id
1
+ %div{id: key}
2
+ .person-form
3
+ .row
4
+ .col-12= form.select :person_type, enum_values_for_select(person.class, :person_type), {}, class: 'person-type-toggle'
5
+ .natural-person-row.identification-form.natural_person.row
6
+ .col-12
7
+ .card
8
+ .card-header Ztotožnění fyzické osoby
9
+ .card-body
10
+ .form
11
+ .form-group
12
+ = label_tag 'firstname', 'Jméno'
13
+ = text_field_tag :firstname, {}, class: 'form-control'
14
+ .form-group
15
+ = label_tag 'lastname', 'Příjmení'
16
+ = text_field_tag :lastname, {}, class: 'form-control'
17
+ .form-group
18
+ = label_tag 'birth_date', 'Datum narození'
19
+ = date_field_tag :birth_date, {}, class: 'form-control'
20
+ = link_to 'Vyhledat', {}, class: 'btn btn-primary'
21
+ .legal-person-row.identification-form.legal_person.row
22
+ .col-12
23
+ .card
24
+ .card-header Ztotožnění právnické osoby
25
+ .card-body
26
+ .form
27
+ .form-group
28
+ = label_tag 'ico', 'IČO'
29
+ = text_field_tag :ico, {}, class: 'form-control'
30
+ = link_to 'Vyhledat', nil, class: 'btn btn-primary'
31
+ = form.hidden_field :remote_id
31
32
 
32
33
  :javascript
33
- $('.natural-person-row a').on('click', function(e) {
34
+ var key = "#{key}";
35
+ $('body').on('click', `\#${key} .natural-person-row a`, function(e) {
34
36
  e.preventDefault();
35
37
  $this = $(this);
36
38
  $npr = $this.closest('.natural-person-row');
@@ -66,8 +68,22 @@
66
68
 
67
69
  if(error_kind == 'not_found') {
68
70
  $icon = $('<i>').addClass('fa').addClass('fa-times');
69
- $error_div = $('<div>').addClass('alert').addClass('alert-danger').append($icon).append(' Nenalezeno');
70
- $this.closest('.card-body').prepend($error_div);
71
+ $error_div = $('<div>').addClass('alert').addClass('alert-danger').append($icon).append(' Dle zadaných údajů nebyla nalezena žádná osoba, pokračujte, prosím, ručním zadáním údajů');
72
+
73
+ $new_person_form = $this.closest('.new-person-form');
74
+ $old_person_form = $new_person_form.siblings('.old-person-form');
75
+
76
+ $old_person_form.prepend($error_div);
77
+ $new_person_form.addClass('hidden').hide();
78
+ $old_person_form.removeClass('hidden').show();
79
+
80
+ eGovUtilities.initPeople($old_person_form);
81
+
82
+ // Fill in the form with the data
83
+ $old_person_form.find("input[name*='[firstname]']").val(form_data.firstname);
84
+ $old_person_form.find("input[name*='[lastname]']").val(form_data.lastname);
85
+ $old_person_form.find("input[name*='[birth_place]']").val(form_data.birth_place);
86
+ $old_person_form.find("input[name*='[birth_date]']").val(form_data.birth_date);
71
87
  }
72
88
  else if(error_kind == 'multiple_results_found') {
73
89
  $form_group = $('<div>').addClass('form-group');
@@ -98,7 +114,7 @@
98
114
  }
99
115
  });
100
116
  });
101
- $('.legal-person-row a').on('click', function(e) {
117
+ $('body').on('click', '.legal-person-row a', function(e) {
102
118
  e.preventDefault();
103
119
  $this = $(this);
104
120
  $lpr = $this.closest('.legal-person-row');
@@ -0,0 +1,5 @@
1
+ class AddRemoteIdToPeople < ActiveRecord::Migration[7.1]
2
+ def change
3
+ add_column :egov_utils_people, :remote_id, :string
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module EgovUtils
2
- VERSION = '1.5.0.alpha2'
2
+ VERSION = '1.5.0.alpha3'
3
3
  end
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: 1.5.0.alpha2
4
+ version: 1.5.0.alpha3
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: 2024-07-10 00:00:00.000000000 Z
11
+ date: 2024-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -757,6 +757,7 @@ files:
757
757
  - db/migrate/20230412063325_add_days_before_archive_to_egov_utils_users.rb
758
758
  - db/migrate/20230427091407_add_fields_to_registration_requests.rb
759
759
  - db/migrate/20231006131159_add_supervisor_assignment_to_registration_requests.rb
760
+ - db/migrate/20240711130901_add_remote_id_to_people.rb
760
761
  - lib/azahara_schema_currency.rb
761
762
  - lib/azahara_schema_currency/aggregation_attribute_patch.rb
762
763
  - lib/azahara_schema_currency/association_attribute_patch.rb