tramway-event 1.11.1 → 1.11.2

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: ea77a5e9957af8c76d807a94d3f1203b1085922f2c8a0c55fb44d5de40527977
4
- data.tar.gz: e489de38c330b4863c18c01eaf8fda08fa717d60163a340a76e5c9f3362af4e1
3
+ metadata.gz: ee9b98770fa7546d0b7c49c02f766217b562830ec0e1d53f6d21b13277ca3ed0
4
+ data.tar.gz: 542630d73692b2d556707204eb618b439af46b49c385161bbb84170d8b6ffc7d
5
5
  SHA512:
6
- metadata.gz: df6b5e3111bf46c7e8312a716255ace9e2320f365e6ebb9a027b08896d3d228d6f7d95a2ae2a37d3f65f6e90d5bd41556c9dbfe68f9fe59156eaa8059ac9248a
7
- data.tar.gz: f2475bafa4f3004d842a80c81ae465ceeae776eafb6a447c37b43d6a5408a61c949680abfc38c4828661473ec462e32179b6e08a8ec8795f1216948f5101b199
6
+ metadata.gz: f4d0e94e345e70cb67c92d63f2ee48822afecf082b536c95bca865c620ed5bd9aabb7dbf699c251613869e1350dda4e0da9d45b98bdac73dd3d3309d91019bbb
7
+ data.tar.gz: daae540aefa2f8dfa0a4b387137c6746f63d47949286577b908d3f05aff8569b46e1e3fc40131f96ef1f77935f095b70478a7aea63a27e759109bcb6f467ed14
@@ -6,7 +6,7 @@ class Tramway::Event::ParticipantExtendedFormCreator < Tramway::Core::FormCreato
6
6
  properties = event.participant_form_fields.inputs_list.reduce({}) do |hash, field|
7
7
  hash.merge! field.title.to_sym => {
8
8
  object: field,
9
- validates: (field.options == '' ? {} : field.options)&.dig('validations')
9
+ validates: build_validations(field)
10
10
  }
11
11
  end
12
12
  if simple_properties.keys.any?
@@ -15,4 +15,13 @@ class Tramway::Event::ParticipantExtendedFormCreator < Tramway::Core::FormCreato
15
15
  ::Tramway::Core::ExtendableForm.new(class_name, **properties)
16
16
  end
17
17
  end
18
+
19
+ def self.build_validations(field)
20
+ case field.field_type
21
+ when 'checkbox'
22
+ field.validations.except('presence').deep_merge! inclusion: { in: [ 'true' ] }
23
+ else
24
+ field.validations
25
+ end
26
+ end
18
27
  end
@@ -3,11 +3,15 @@
3
3
  class Tramway::Event::ParticipantFormField < ::Tramway::Event::ApplicationRecord
4
4
  belongs_to :event, class_name: 'Tramway::Event::Event'
5
5
 
6
- enumerize :field_type, in: %i[text string numeric date_picker select], default: :text
6
+ enumerize :field_type, in: %i[text string numeric date_picker select checkbox], default: :text
7
7
 
8
8
  scope :inputs_list, -> { active.order(position: :asc) }
9
9
 
10
10
  def required
11
11
  options.present? && options.dig('validations', 'presence') == 'true'
12
12
  end
13
+
14
+ def validations
15
+ (options == '' ? {} : options)&.dig('validations')
16
+ end
13
17
  end
@@ -90,6 +90,7 @@ ru:
90
90
  attributes:
91
91
  default:
92
92
  presence: не может быть пустым
93
+ inclusion: этот пункт должен быть отмечен
93
94
  cases:
94
95
  tramway/event/event:
95
96
  plural: мероприятия
@@ -136,3 +137,4 @@ ru:
136
137
  numeric: Число
137
138
  date_picker: Дата
138
139
  select: Выпадающий список (да/нет)
140
+ checkbox: Галочка
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Event
5
- VERSION = '1.11.1'
5
+ VERSION = '1.11.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-event
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-08 00:00:00.000000000 Z
11
+ date: 2020-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: configus