tramway-core 1.6.4 → 1.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d7036cd15efb8465dd098b71750d1b38767611545fe8a58796030a7670db1f2
|
4
|
+
data.tar.gz: 1f12dad57781d6604b1c28f78a9ba9612561f0ca16154a2ade685f60f4ff42c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34cb3bab7fbcc827765b97f944484212a2a3706d5abdac64dcd4cf14425478af4fefd24ff239685b466eac760379ae9a8c641a176151878c15161a985544e507
|
7
|
+
data.tar.gz: f266e1d01de459a2e73e9025daff5540c961bcec2911458006c4595c8f1360cee29bed82e3e7ea497eb7aa8abdc6eb4d217a1011fd40e1117f0be925b2c00dd2
|
@@ -1,21 +1,30 @@
|
|
1
1
|
class Tramway::Core::ExtendableForm
|
2
2
|
class << self
|
3
|
-
def new(name, **more_properties)
|
3
|
+
def new(name, simple_properties: {}, **more_properties)
|
4
4
|
if Object.const_defined? name
|
5
5
|
name.constantize
|
6
6
|
else
|
7
7
|
Object.const_set(name, Class.new(::Tramway::Core::ApplicationForm) do
|
8
|
+
properties(*simple_properties.keys) if simple_properties.keys.any?
|
9
|
+
|
8
10
|
define_method 'submit' do |params|
|
9
11
|
model.values ||= {}
|
10
|
-
|
12
|
+
extended_params = params.except(*simple_properties.keys)
|
13
|
+
model.values = extended_params.permit!.to_h.reduce(model.values) do |hash, pair|
|
11
14
|
hash.merge! pair[0] => pair[1]
|
12
15
|
end
|
13
16
|
super params
|
14
17
|
end
|
15
18
|
|
16
19
|
define_method 'properties' do
|
17
|
-
|
18
|
-
|
20
|
+
hash = simple_properties.reduce({}) do |h, property|
|
21
|
+
unless model.class.state_machines.keys.include?(property[0])
|
22
|
+
h.merge! property[0] => property[1]
|
23
|
+
end
|
24
|
+
h
|
25
|
+
end
|
26
|
+
more_properties.reduce(hash) do |h, property|
|
27
|
+
h.merge! property[0] => {
|
19
28
|
extended_form_property: property[1]
|
20
29
|
}
|
21
30
|
end
|
@@ -6,8 +6,8 @@
|
|
6
6
|
- else
|
7
7
|
= f.input field.title.to_sym, as: field.field_type, input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }
|
8
8
|
- when 'select'
|
9
|
-
- parsed_json = JSON.parse(field.options) unless field.options == ''
|
10
|
-
- if parsed_json && parsed_json
|
9
|
+
- parsed_json = field.options.is_a?(Hash) ? field.options : (JSON.parse(field.options) unless field.options == '')
|
10
|
+
- if parsed_json && parsed_json.dig('collection', 'name')
|
11
11
|
- if value.present?
|
12
12
|
= f.input field.title.to_sym, as: :select, collection: collection_list_by(name: parsed_json['collection']['name']), input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }, selected: value
|
13
13
|
- else
|
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.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reform-rails
|