formnestic 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 378acbe981c8058b6d6e6105a0009cf5f38f561cf8154b8b65b9bed52dca9f7d
4
- data.tar.gz: 322c9cebfec61e08bbac6d18cc84fe46bf0bfc0adcdbfae5e0b8f94edc8c1975
3
+ metadata.gz: e1621bcb434bcdbcba856cb23bc8be60ea07f1722ccc468abe0a80b2f3adbe28
4
+ data.tar.gz: 54fc1c385b28dda9f53090a7d092826d3f72c9a3fc208a3e7da258cd143964f6
5
5
  SHA512:
6
- metadata.gz: 5e7e6874272578eca36e0d82b6f3f0d01a33bfe0aae89505f5422234637ed411de8c9aa34be3ac554c70017c6c695b8881c02ec52100b78869aa80631da10763
7
- data.tar.gz: 22000bb8c88983a8852e946921644b4ec3a85eb544d01801e4486ca12c90789a52f30ff28f56ac04c3d16847e1ed2357c02f92fd15b63482d866899c4aff3e65
6
+ metadata.gz: dfca5c52f22b47c1c35b444c5b53ce6fa0803cb8796d6f6337ca4416cc2c7f29e907394b95d81365dd56eba78192d0252320a4a437f504fa6727a8b0e2a8b22f
7
+ data.tar.gz: 1fea05ff4909724c25da44289f6aae4d2a0e01d41d695713dd5b4bb1198fd5c6f9683bd74e191d38b9df649638bdbab1788c0c7006584bcf25e50208c95f6858
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.9
1
+ 1.0.11
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'formnestic'
8
- s.version = '1.0.10'
8
+ s.version = '1.0.11'
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ['James']
@@ -1,3 +1,4 @@
1
+ # rubocop:disable MethodLength, AbcSize, ModuleLength
1
2
  module Formnestic
2
3
  module Helpers
3
4
  module InputsHelper
@@ -13,18 +14,54 @@ module Formnestic
13
14
 
14
15
  # for listing form
15
16
  def formnestic_list_row_inputs(*args, &block)
16
- html_options = formnestic_prepare_html_options_for_wrapper(:list, *args)
17
- rows_counter = template.content_tag(:span, options[:parent_builder].rows_counter, class: 'formnestic-li-fieldset-for-order')
18
- content_div_content = [formnestic_legend_for_list_form, ' #'.html_safe, rows_counter].join.html_safe
19
- title_div = template.content_tag(:div, content_div_content, class: 'formnestic-li-fieldset-legend')
20
- template.content_tag(:fieldset, [title_div, (options[:row_removable] ? formnestic_row_removing_content_tag(:list) : ''), template.capture(&block)].join.html_safe, html_options)
17
+ html_options =
18
+ formnestic_prepare_html_options_for_wrapper(:list, *args)
19
+ rows_counter =
20
+ template.content_tag(
21
+ :span,
22
+ options[:parent_builder].rows_counter,
23
+ class: 'formnestic-li-fieldset-for-order'
24
+ )
25
+ content_div_content = [
26
+ formnestic_legend_for_list_form,
27
+ ' #'.html_safe,
28
+ rows_counter
29
+ ].join.html_safe
30
+ title_div = template.content_tag(
31
+ :div,
32
+ content_div_content,
33
+ class: 'formnestic-li-fieldset-legend'
34
+ )
35
+ template.content_tag(
36
+ :fieldset, [
37
+ title_div, (
38
+ if options[:row_removable]
39
+ formnestic_row_removing_content_tag(:list)
40
+ else
41
+ ''
42
+ end
43
+ ),
44
+ template.capture(&block)
45
+ ].join.html_safe,
46
+ html_options
47
+ )
21
48
  end
22
49
 
23
50
  # For table form
24
51
  def formnestic_table_row_inputs(*args, &block)
25
- html_options = formnestic_prepare_html_options_for_wrapper(:table, *args)
26
- template.content_tag(:tr, [template.capture(&block), (options[:row_removable] ?
27
- formnestic_row_removing_content_tag(:table) : '')].join.html_safe, html_options)
52
+ html_options =
53
+ formnestic_prepare_html_options_for_wrapper(:table, *args)
54
+ template.content_tag(
55
+ :tr, [
56
+ template.capture(&block), (
57
+ if options[:row_removable]
58
+ formnestic_row_removing_content_tag(:table)
59
+ else
60
+ ''
61
+ end
62
+ )
63
+ ].join.html_safe, html_options
64
+ )
28
65
  end
29
66
 
30
67
  def formnestic_legend_for_list_form
@@ -40,20 +77,55 @@ formnestic_row_removing_content_tag(:table) : '')].join.html_safe, html_options)
40
77
  .downcase
41
78
  .titleize
42
79
  end
43
- template.content_tag(:span, record_name, class: 'formnestic-li-fieldset-for')
80
+ template.content_tag(
81
+ :span,
82
+ record_name,
83
+ class: 'formnestic-li-fieldset-for'
84
+ )
44
85
  end
45
86
 
46
87
  def formnestic_row_removing_content_tag(form_type)
47
88
  contents = []
48
- contents.push(hidden_field(:_destroy, class: 'formnestic-destroy-input', value: false))
49
- contents.push(template.content_tag(:div, '', title: I18n.t('formnestic.labels.remove_this_entry'), class: "#{formnestic_row_removing_cell_div_class(form_type)} icon-cancel-circled", onclick: formnestic_row_removing_cell_js_call(form_type)))
50
- template.content_tag(form_type == :table ? :td : :div, contents.join.html_safe, class: formnestic_row_removing_cell_container_div_class(form_type))
89
+ contents.push(
90
+ hidden_field(
91
+ :_destroy,
92
+ class: 'formnestic-destroy-input',
93
+ value: object.marked_for_destruction?
94
+ )
95
+ )
96
+ contents.push(
97
+ template.content_tag(
98
+ :div,
99
+ '',
100
+ title: I18n.t('formnestic.labels.remove_this_entry'),
101
+ class: "#{formnestic_row_removing_cell_div_class(form_type)} \
102
+ icon-cancel-circled",
103
+ onclick: formnestic_row_removing_cell_js_call(form_type)
104
+ )
105
+ )
106
+ template.content_tag(
107
+ form_type == :table ? :td : :div,
108
+ contents.join.html_safe,
109
+ class: formnestic_row_removing_cell_container_div_class(form_type)
110
+ )
51
111
  end
52
112
 
53
113
  def formnestic_prepare_html_options_for_wrapper(form_type, *args)
54
114
  html_options = args.extract_options!
55
115
  html_options[:name] = field_set_title_from_args(*args)
56
- html_options[:class] = [html_options[:class] || 'inputs', formnestic_wrapper_class(form_type), formnestic_row_class_based_on_position(options[:parent_builder].rows_counter)].join(' ')
116
+ html_options[:class] = [
117
+ html_options[:class] || 'inputs',
118
+ formnestic_wrapper_class(form_type),
119
+ formnestic_row_class_based_on_position(
120
+ options[:parent_builder].rows_counter
121
+ )
122
+ ].join(' ')
123
+ if object.marked_for_destruction?
124
+ html_options[:style] = [
125
+ html_options[:style],
126
+ 'display: none'
127
+ ].compact.join(';')
128
+ end
57
129
  options[:parent_builder].increase_rows_counter
58
130
  html_options
59
131
  end
@@ -96,3 +168,4 @@ formnestic_row_removing_content_tag(:table) : '')].join.html_safe, html_options)
96
168
  end
97
169
  end
98
170
  end
171
+ # rubocop:enable all
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formnestic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - James
@@ -237,8 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  requirements: []
240
- rubyforge_project:
241
- rubygems_version: 2.7.6
240
+ rubygems_version: 3.0.3
242
241
  signing_key:
243
242
  specification_version: 3
244
243
  summary: An extension of formtastic form builder gem