formwandler 0.4.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/formwandler/field.rb +4 -0
- data/lib/formwandler/field_definition.rb +3 -2
- data/lib/formwandler/form.rb +10 -2
- data/lib/formwandler/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4d04197f5a3301a80069f8b0200228445e13ed4d0acfe967db3785d2a62197b8
|
4
|
+
data.tar.gz: 00e39bc2876b1aa9e782a28d4dd61b898b465618cd3bbc3e7a2332f0c3d6f3ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 102eb373dc65dc92b07fb6f495bd265f72713c4a8193628911dd5299a083fc4e2b2da8fa5d6286a2ead2acf097c3a08a9c63be7c0e86ea60e1a69eaab217b5f7
|
7
|
+
data.tar.gz: 2e049c3cc06cc1e55dd7411e716ab87a15ef179ed16704700912e42bd7e75d6d8d31a6aadf60f4c9b617e10477f163a3457ae4441ef9d53a4c36d06ca96e4a43
|
data/lib/formwandler/field.rb
CHANGED
@@ -4,9 +4,9 @@ require_relative 'field_value_transformer'
|
|
4
4
|
|
5
5
|
module Formwandler
|
6
6
|
class FieldDefinition
|
7
|
-
attr_reader :name, :hidden, :disabled, :default, :delocalize, :model, :source, :options
|
7
|
+
attr_reader :name, :hidden, :disabled, :default, :delocalize, :model, :source, :options, :array
|
8
8
|
|
9
|
-
def initialize(name, hidden: false, disabled: false, default: nil, delocalize: nil, model: nil, source: nil, options: nil)
|
9
|
+
def initialize(name, hidden: false, disabled: false, default: nil, delocalize: nil, model: nil, source: nil, options: nil, array: false)
|
10
10
|
@name = name
|
11
11
|
@hidden = hidden
|
12
12
|
@disabled = disabled
|
@@ -15,6 +15,7 @@ module Formwandler
|
|
15
15
|
@model = model
|
16
16
|
@source = source || name
|
17
17
|
@options = options
|
18
|
+
@array = array
|
18
19
|
end
|
19
20
|
|
20
21
|
def hide_option(name, value = true)
|
data/lib/formwandler/form.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'field_definition'
|
4
4
|
require_relative 'field'
|
5
|
+
require 'delocalize'
|
5
6
|
|
6
7
|
module Formwandler
|
7
8
|
class Form
|
@@ -95,7 +96,9 @@ module Formwandler
|
|
95
96
|
|
96
97
|
def submit
|
97
98
|
if valid? && models_valid?
|
98
|
-
|
99
|
+
ActiveRecord::Base.transaction do
|
100
|
+
save_models!
|
101
|
+
end
|
99
102
|
load_results
|
100
103
|
else
|
101
104
|
false
|
@@ -134,10 +137,15 @@ module Formwandler
|
|
134
137
|
end
|
135
138
|
|
136
139
|
def permitted_params
|
137
|
-
visible_fields = fields.reject(&:hidden?).map(&:name)
|
138
140
|
controller.params.require(model_name.param_key).permit(*visible_fields).delocalize(delocalizations)
|
139
141
|
end
|
140
142
|
|
143
|
+
def visible_fields
|
144
|
+
fields.reject(&:hidden?).map do |field|
|
145
|
+
field.array? ? {field.name => []} : field.name
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
141
149
|
def delocalizations
|
142
150
|
fields.reduce({}) do |memo, field|
|
143
151
|
memo[field.name] = field.delocalize
|
data/lib/formwandler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formwandler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Bilharz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
145
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.6
|
146
|
+
rubygems_version: 2.7.6
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
149
|
summary: Form objects for rails
|