tramway-core 1.11.2.1 → 1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/forms/tramway/core/application_form.rb +4 -0
- data/app/forms/tramway/core/extendable_form.rb +19 -1
- data/app/views/tramway/core/shared/_input_extended.html.haml +3 -0
- data/lib/tramway/core.rb +1 -0
- data/lib/tramway/core/version.rb +1 -1
- data/lib/validators/presence_validator.rb +8 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12be55503084db2c64bbfaa0b6ee9be832fcd59e69c310e07eb3fbc0898232fa
|
4
|
+
data.tar.gz: f2747d3bb5a1b1f75faac71cb841da9a6c1ad4bcd446c1f4729d7934f10ae685
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4eb18d64363f2a6d67a47b957022944a9de037b83628ddb50fa01871adead0c3e6b69cbe1ad7673f60f3d1a27c01bd0edc12b12aa1bdabb122cf1e6b8f45bb7
|
7
|
+
data.tar.gz: 7cbda29bf51b732361615e14496629768a61be6e8af02dc52054cad30859643732e0e7d36ecee5ac68bd4752166ee8a6fd050a62fa55eda6751b2947d1e30f9c
|
@@ -10,6 +10,12 @@ class Tramway::Core::ExtendableForm
|
|
10
10
|
define_method 'submit' do |params|
|
11
11
|
model.values ||= {}
|
12
12
|
extended_params = params.except(*simple_properties.keys)
|
13
|
+
params.each do |key, value|
|
14
|
+
method_name = "#{key}="
|
15
|
+
if respond_to?(method_name)
|
16
|
+
send method_name, value
|
17
|
+
end
|
18
|
+
end
|
13
19
|
model.values = extended_params.permit!.to_h.reduce(model.values) do |hash, pair|
|
14
20
|
hash.merge! pair[0] => pair[1]
|
15
21
|
end
|
@@ -25,7 +31,7 @@ class Tramway::Core::ExtendableForm
|
|
25
31
|
end
|
26
32
|
more_properties.reduce(hash) do |h, property|
|
27
33
|
h.merge! property[0] => {
|
28
|
-
extended_form_property: property[1]
|
34
|
+
extended_form_property: property[1][:object]
|
29
35
|
}
|
30
36
|
end
|
31
37
|
end
|
@@ -34,6 +40,18 @@ class Tramway::Core::ExtendableForm
|
|
34
40
|
define_method property[0] do
|
35
41
|
model.values[property[0]] if model.values
|
36
42
|
end
|
43
|
+
|
44
|
+
if property[1][:validates].present?
|
45
|
+
define_method "#{property[0]}=" do |value|
|
46
|
+
property[1][:validates].each do |pair|
|
47
|
+
validator_object = "#{pair[0].camelize}Validator".constantize.new({ attributes: :not_blank })
|
48
|
+
if pair[1] == 'true' && !validator_object.send(:valid?, value)
|
49
|
+
model.errors.add property[0],
|
50
|
+
I18n.t("activerecord.errors.models.#{model.class.name.underscore}.attributes.#{property[0]}.#{pair[0]}", { value: value })
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
37
55
|
end
|
38
56
|
end)
|
39
57
|
end
|
@@ -17,3 +17,6 @@
|
|
17
17
|
= f.input field.title.to_sym, as: :select, input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }, selected: value
|
18
18
|
- else
|
19
19
|
= f.input field.title.to_sym, as: :select, input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }
|
20
|
+
- if params[:errors][field.title]&.first
|
21
|
+
.alert.alert-danger
|
22
|
+
= params[:errors][field.title]&.first
|
data/lib/tramway/core.rb
CHANGED
data/lib/tramway/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.12'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reform-rails
|
@@ -376,6 +376,7 @@ files:
|
|
376
376
|
- lib/tramway/core/version.rb
|
377
377
|
- lib/tramway/error.rb
|
378
378
|
- lib/tramway/helpers/class_name_helpers.rb
|
379
|
+
- lib/validators/presence_validator.rb
|
379
380
|
homepage: https://github.com/kalashnikovisme/tramway-core
|
380
381
|
licenses:
|
381
382
|
- MIT
|