formnestic 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/Gemfile.lock +31 -28
- data/VERSION +1 -1
- data/formnestic.gemspec +1 -1
- data/lib/formnestic/form_builder/list_form_builder.rb +68 -11
- data/lib/formnestic/form_builder/table_form_builder.rb +23 -3
- data/lib/formnestic/helpers/inputs_helper.rb +40 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19dbc5857976dba8a545a7e706263e1ec6052ffbbb7b7aab12f53a30b079f473
|
4
|
+
data.tar.gz: 751b42184a4c9ddd77e76d5996ea08ce6784c3b3bcb26e0aed4079ab20468dcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 964bee3a47f68996bd88cfb03461da02a936ec507c5f109e1fecc50ca40665abfbc7d1904b42f4b908bf69309e3c9e95161de5e1650cbecb35b9aeb85bc480ea
|
7
|
+
data.tar.gz: ccc9d7e0bd8b7a372ca4051d287332fa0acd343d6989f5b35ddc1a119dac3ef760eb5adf621fe65c830c00d20a93433170352ee7d1fe02aec6091dc535a519cf
|
data/Gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'http://rubygems.org'
|
2
4
|
# Add dependencies required to use your gem here.
|
3
5
|
# Example:
|
@@ -16,6 +18,8 @@ group :development, :test do
|
|
16
18
|
gem 'spork'
|
17
19
|
gem 'tzinfo'
|
18
20
|
gem 'watchr'
|
21
|
+
|
22
|
+
gem 'nokogiri', '~> 1.10'
|
19
23
|
end
|
20
24
|
|
21
25
|
group :test do
|
data/Gemfile.lock
CHANGED
@@ -17,7 +17,8 @@ GEM
|
|
17
17
|
activesupport (3.2.18)
|
18
18
|
i18n (~> 0.6, >= 0.6.4)
|
19
19
|
multi_json (~> 1.0)
|
20
|
-
addressable (2.
|
20
|
+
addressable (2.7.0)
|
21
|
+
public_suffix (>= 2.0.2, < 5.0)
|
21
22
|
builder (3.0.4)
|
22
23
|
coveralls (0.7.0)
|
23
24
|
multi_json (~> 1.3)
|
@@ -30,21 +31,20 @@ GEM
|
|
30
31
|
diff-lcs (1.2.5)
|
31
32
|
docile (1.1.5)
|
32
33
|
erubis (2.7.0)
|
33
|
-
faraday (0.
|
34
|
+
faraday (0.17.3)
|
34
35
|
multipart-post (>= 1.2, < 3)
|
35
36
|
formtastic (2.2.1)
|
36
37
|
actionpack (>= 3.0)
|
37
|
-
git (1.
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
highline (1.6.21)
|
38
|
+
git (1.6.0)
|
39
|
+
rchardet (~> 1.8)
|
40
|
+
github_api (0.18.2)
|
41
|
+
addressable (~> 2.4)
|
42
|
+
descendants_tracker (~> 0.0.4)
|
43
|
+
faraday (~> 0.8)
|
44
|
+
hashie (~> 3.5, >= 3.5.2)
|
45
|
+
oauth2 (~> 1.0)
|
46
|
+
hashie (3.6.0)
|
47
|
+
highline (2.0.3)
|
48
48
|
hike (1.2.3)
|
49
49
|
i18n (0.6.9)
|
50
50
|
jeweler (2.0.1)
|
@@ -58,21 +58,22 @@ GEM
|
|
58
58
|
rdoc
|
59
59
|
journey (1.0.4)
|
60
60
|
json (1.8.6)
|
61
|
-
jwt (
|
61
|
+
jwt (2.2.1)
|
62
62
|
mime-types (2.3)
|
63
|
-
|
64
|
-
multi_json (1.
|
65
|
-
multi_xml (0.
|
66
|
-
multipart-post (2.
|
67
|
-
nokogiri (1.
|
68
|
-
|
69
|
-
oauth2 (
|
70
|
-
faraday (>= 0.8, < 0
|
71
|
-
jwt (
|
63
|
+
mini_portile2 (2.4.0)
|
64
|
+
multi_json (1.14.1)
|
65
|
+
multi_xml (0.6.0)
|
66
|
+
multipart-post (2.1.1)
|
67
|
+
nokogiri (1.10.9)
|
68
|
+
mini_portile2 (~> 2.4.0)
|
69
|
+
oauth2 (1.4.4)
|
70
|
+
faraday (>= 0.8, < 2.0)
|
71
|
+
jwt (>= 1.0, < 3.0)
|
72
72
|
multi_json (~> 1.3)
|
73
73
|
multi_xml (~> 0.5)
|
74
|
-
rack (
|
75
|
-
|
74
|
+
rack (>= 1.2, < 3)
|
75
|
+
public_suffix (4.0.3)
|
76
|
+
rack (1.4.7)
|
76
77
|
rack-cache (1.2)
|
77
78
|
rack (>= 0.4)
|
78
79
|
rack-ssl (1.3.4)
|
@@ -86,7 +87,8 @@ GEM
|
|
86
87
|
rake (>= 0.8.7)
|
87
88
|
rdoc (~> 3.4)
|
88
89
|
thor (>= 0.14.6, < 2.0)
|
89
|
-
rake (
|
90
|
+
rake (13.0.1)
|
91
|
+
rchardet (1.8.0)
|
90
92
|
rdoc (3.12.2)
|
91
93
|
json (~> 1.4)
|
92
94
|
rest-client (1.6.7)
|
@@ -126,7 +128,7 @@ GEM
|
|
126
128
|
term-ansicolor (1.3.0)
|
127
129
|
tins (~> 1.0)
|
128
130
|
thor (0.19.1)
|
129
|
-
thread_safe (0.3.
|
131
|
+
thread_safe (0.3.6)
|
130
132
|
tilt (1.4.1)
|
131
133
|
tins (1.3.0)
|
132
134
|
tzinfo (1.2.1)
|
@@ -143,6 +145,7 @@ DEPENDENCIES
|
|
143
145
|
formtastic (>= 2.2.1)
|
144
146
|
jeweler (~> 2.0.1)
|
145
147
|
json (>= 1.8.3)
|
148
|
+
nokogiri (~> 1.10)
|
146
149
|
rake
|
147
150
|
rdoc (~> 3.4)
|
148
151
|
rspec-rails (~> 2.14.0)
|
@@ -153,4 +156,4 @@ DEPENDENCIES
|
|
153
156
|
watchr
|
154
157
|
|
155
158
|
BUNDLED WITH
|
156
|
-
1.
|
159
|
+
1.17.2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.12
|
data/formnestic.gemspec
CHANGED
@@ -1,28 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Formnestic
|
2
4
|
module FormBuilder
|
3
5
|
module ListFormBuilder
|
4
6
|
include Formnestic::FormBuilder::BaseBuilder
|
5
|
-
def formnestic_list_semantic_fields_for(
|
7
|
+
def formnestic_list_semantic_fields_for(
|
8
|
+
record_or_name_or_array,
|
9
|
+
*args,
|
10
|
+
&block
|
11
|
+
)
|
6
12
|
options = args.dup.extract_options!
|
7
13
|
|
8
14
|
formnestic_add_rows_counter_related_attributes
|
9
|
-
existing_rows = formtastic_semantic_fields_for(
|
10
|
-
|
15
|
+
existing_rows = formtastic_semantic_fields_for(
|
16
|
+
record_or_name_or_array,
|
17
|
+
*args,
|
18
|
+
&block
|
19
|
+
)
|
20
|
+
contents = [
|
21
|
+
template.content_tag(
|
22
|
+
:div,
|
23
|
+
existing_rows,
|
24
|
+
class: 'formnestic-list-entries-container'
|
25
|
+
)
|
26
|
+
]
|
11
27
|
|
12
28
|
options[:min_entry] ||= -1
|
13
29
|
options[:max_entry] ||= -1
|
14
30
|
|
15
|
-
options[:min_entry_alert_message] =
|
16
|
-
|
17
|
-
|
31
|
+
options[:min_entry_alert_message] =
|
32
|
+
formnestic_min_entry_alert_message(
|
33
|
+
record_or_name_or_array, options[:min_entry]
|
34
|
+
)
|
35
|
+
if resolve_row_addable(options[:row_addable])
|
36
|
+
contents.push(
|
37
|
+
formnestic_add_new_record_button_row_for_list_form(
|
38
|
+
record_or_name_or_array, *args, &block
|
39
|
+
)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
options[:class] = [
|
43
|
+
options[:class],
|
44
|
+
'formnestic-nested-model-container'
|
45
|
+
].compact.join
|
46
|
+
|
47
|
+
template.content_tag(
|
48
|
+
:div,
|
49
|
+
contents.join.html_safe,
|
50
|
+
options.except(
|
51
|
+
:builder,
|
52
|
+
:parent,
|
53
|
+
:name,
|
54
|
+
:parent_builder,
|
55
|
+
:display_type,
|
56
|
+
:row_removable,
|
57
|
+
:new_record_link_label,
|
58
|
+
:child_index
|
59
|
+
)
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def resolve_row_addable(row_addable)
|
64
|
+
return row_addable if [true, false].index(row_addable)
|
65
|
+
return true if row_addable.nil?
|
66
|
+
|
67
|
+
return row_addable.call if row_addable.is_a?(Proc)
|
18
68
|
|
19
|
-
|
20
|
-
contents.join.html_safe,
|
21
|
-
options.except(:builder, :parent, :name, :parent_builder, :display_type, :row_removable, :new_record_link_label, :child_index))
|
69
|
+
true
|
22
70
|
end
|
23
71
|
|
24
|
-
def formnestic_add_new_record_button_row_for_list_form(
|
25
|
-
|
72
|
+
def formnestic_add_new_record_button_row_for_list_form(
|
73
|
+
record_or_name_or_array, *args, &block
|
74
|
+
)
|
75
|
+
template.content_tag(
|
76
|
+
:div,
|
77
|
+
formnestic_link_to_add_fields_with_content(
|
78
|
+
record_or_name_or_array,
|
79
|
+
*args,
|
80
|
+
&block
|
81
|
+
), class: 'formnestic-list-new-entry-link-container'
|
82
|
+
)
|
26
83
|
end
|
27
84
|
end
|
28
85
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# rubocop:disable MethodLength, Documentation, ModuleLength, AbcSize
|
2
4
|
module Formnestic
|
3
5
|
module FormBuilder
|
@@ -20,7 +22,7 @@ module Formnestic
|
|
20
22
|
}
|
21
23
|
)]
|
22
24
|
|
23
|
-
if options[:row_addable]
|
25
|
+
if resolve_row_addable(options[:row_addable])
|
24
26
|
contents.push(
|
25
27
|
formnestic_add_new_record_button_row_for_table(
|
26
28
|
record_or_name_or_array, *args, &block
|
@@ -58,7 +60,16 @@ module Formnestic
|
|
58
60
|
:row_removable,
|
59
61
|
:new_record_link_label,
|
60
62
|
:table_headers
|
61
|
-
|
63
|
+
))
|
64
|
+
end
|
65
|
+
|
66
|
+
def resolve_row_addable(row_addable)
|
67
|
+
return row_addable if [true, false].index(row_addable)
|
68
|
+
return true if row_addable.nil?
|
69
|
+
|
70
|
+
return row_addable.call if row_addable.is_a?(Proc)
|
71
|
+
|
72
|
+
true
|
62
73
|
end
|
63
74
|
|
64
75
|
def formnestic_add_table_headers_form_attributes
|
@@ -72,6 +83,7 @@ module Formnestic
|
|
72
83
|
return if @table_headers.detect do |x|
|
73
84
|
x[:attr] == column_name
|
74
85
|
end.present?
|
86
|
+
|
75
87
|
@table_headers.push(
|
76
88
|
attr: column_name,
|
77
89
|
class:
|
@@ -130,7 +142,7 @@ module Formnestic
|
|
130
142
|
)
|
131
143
|
)
|
132
144
|
end
|
133
|
-
if row_removable
|
145
|
+
if row_removable != false
|
134
146
|
tr_content_arr.push(
|
135
147
|
template.content_tag(
|
136
148
|
:th, '', class: 'formnestic-minus-thead'
|
@@ -190,5 +202,13 @@ module Formnestic
|
|
190
202
|
end
|
191
203
|
end
|
192
204
|
end
|
205
|
+
|
206
|
+
def resolve_row_removable(row_removable, record)
|
207
|
+
if row_removable.is_a?(Proc)
|
208
|
+
row_removable.call(record)
|
209
|
+
else
|
210
|
+
row_removable
|
211
|
+
end
|
212
|
+
end
|
193
213
|
end
|
194
214
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# rubocop:disable MethodLength, AbcSize, ModuleLength
|
2
4
|
module Formnestic
|
3
5
|
module Helpers
|
@@ -36,7 +38,20 @@ module Formnestic
|
|
36
38
|
:fieldset, [
|
37
39
|
title_div, (
|
38
40
|
if options[:row_removable]
|
39
|
-
|
41
|
+
row_removable_for_record =
|
42
|
+
resolve_row_removable(options[:row_removable], object)
|
43
|
+
if row_removable_for_record
|
44
|
+
formnestic_row_removing_content_tag(
|
45
|
+
:list
|
46
|
+
)
|
47
|
+
else
|
48
|
+
template.content_tag(
|
49
|
+
:div,
|
50
|
+
'',
|
51
|
+
class: \
|
52
|
+
formnestic_row_removing_cell_container_div_class(:list)
|
53
|
+
)
|
54
|
+
end
|
40
55
|
else
|
41
56
|
''
|
42
57
|
end
|
@@ -54,8 +69,22 @@ module Formnestic
|
|
54
69
|
template.content_tag(
|
55
70
|
:tr, [
|
56
71
|
template.capture(&block), (
|
57
|
-
if options[:row_removable]
|
58
|
-
|
72
|
+
if options[:row_removable] != false
|
73
|
+
row_removable_for_record =
|
74
|
+
resolve_row_removable(options[:row_removable], object)
|
75
|
+
|
76
|
+
if row_removable_for_record
|
77
|
+
formnestic_row_removing_content_tag(
|
78
|
+
:table
|
79
|
+
)
|
80
|
+
else
|
81
|
+
template.content_tag(
|
82
|
+
:td,
|
83
|
+
'',
|
84
|
+
class: \
|
85
|
+
formnestic_row_removing_cell_container_div_class(:table)
|
86
|
+
)
|
87
|
+
end
|
59
88
|
else
|
60
89
|
''
|
61
90
|
end
|
@@ -64,6 +93,14 @@ module Formnestic
|
|
64
93
|
)
|
65
94
|
end
|
66
95
|
|
96
|
+
def resolve_row_removable(row_removable, record)
|
97
|
+
return row_removable if [true, false].index(row_removable)
|
98
|
+
|
99
|
+
row_removable.call(record) if row_removable.is_a?(Proc)
|
100
|
+
|
101
|
+
false
|
102
|
+
end
|
103
|
+
|
67
104
|
def formnestic_legend_for_list_form
|
68
105
|
record_name = if options[:record_header].present?
|
69
106
|
options[:record_header]
|