para 0.11.0 → 0.11.2

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: c76f7d6a88963d8cc0a3cbdf1214aceadc51b1e92d5affd0f1dc92e97286c0b7
4
- data.tar.gz: 063fac75f6067c5386c3d285bc46f91c29ac19f86581e7b7a4f81c17721ae659
3
+ metadata.gz: 6f6fa00155104b2a8b6557c6ec04c3c64ae456eaeea26605757f0b4fef347fcc
4
+ data.tar.gz: 91243a2554514c1acbffec0d730276ffe5db4063b21723b91f0ed842b9ccb228
5
5
  SHA512:
6
- metadata.gz: 64b31416475e321d7efc81cb37ec1a942d722458758c12e73f99deda94a1e32ff3864443f9923d2bae8fc5cf588091500219bf05f30182a70d266a84570b5860
7
- data.tar.gz: e44dc74e75bdf99038c340c7e26f41c66166c60c121e29ae581a4a8851378d9ed7dcca96935ee2fcd829acacb7293eef7652d1ce8cb96796cf1288430d5956eb
6
+ metadata.gz: 6842f6aa0f5ed769519fe0ce471ea9cb5bde60458974debc956ba094f93eb799dfbb4d0f9d6a0728e2131c3376088ecf7cd904130a228345b9d204664fdf8a7b
7
+ data.tar.gz: 9de0c468a9e29066ca22a2cd0f2d5f600c0d4d7397b63034ab8a9a53784aa255901f1ea95e3f9759103a2a411d3f163c3a3bdb763b6e02e1c76008f90e29c2d3
@@ -17,8 +17,15 @@ class Para.NestedManyField
17
17
  onUpdate: $.proxy(@handleOrderingUpdated, this)
18
18
 
19
19
  handleOrderingUpdated: ->
20
- @$fieldsList.find('.form-fields:visible').each (i, el) ->
21
- $(el).find('.resource-position-field').val(i)
20
+ formFields = []
21
+
22
+ @$fieldsList.find('.form-fields:visible').each (_i, el) ->
23
+ isNestedField = $parent.find(el).length for $parent in formFields
24
+ return if isNestedField
25
+
26
+ $el = $(el)
27
+ $el.find('.resource-position-field:eq(0)').val(formFields.length)
28
+ formFields.push($el)
22
29
 
23
30
  initializeCocoon: ->
24
31
  @$fieldsList.on 'cocoon:after-insert', @stoppingPropagation(@afterInsertField)
@@ -30,7 +37,6 @@ class Para.NestedManyField
30
37
  e.stopPropagation()
31
38
  callback(e, args...)
32
39
 
33
-
34
40
  afterInsertField: (e, $element) =>
35
41
  if ($collapsible = $element.find('[data-open-on-insert="true"]')).length
36
42
  @openInsertedField($collapsible)
@@ -1,14 +1,14 @@
1
1
  module Para
2
2
  module Inputs
3
3
  class NestedBaseInput < SimpleForm::Inputs::Base
4
- GLOBAL_NESTED_FIELD_KEY = "para.nested_field.parent"
4
+ GLOBAL_NESTED_FIELD_KEY = 'para.nested_field.parent'
5
5
 
6
6
  private
7
7
 
8
8
  def dom_identifier
9
9
  @dom_identifier ||= begin
10
10
  name = attribute_name
11
- id = @builder.object.id || "_new_#{ parent_nested_field&.attribute_name }_"
11
+ id = @builder.object.id || "_new_#{parent_nested_field&.attribute_name}_"
12
12
  time = (Time.now.to_f * 1000).to_i
13
13
  random = (rand * 1000).to_i
14
14
  [name, id, time, random].join('-')
@@ -22,7 +22,7 @@ module Para
22
22
  def subclasses
23
23
  options.fetch(:subclasses, [])
24
24
  end
25
-
25
+
26
26
  def add_button_label
27
27
  options.fetch(:add_button_label) { I18n.t('para.form.nested.add') }
28
28
  end
@@ -39,13 +39,13 @@ module Para
39
39
  @parent_nested_field = RequestStore.store[GLOBAL_NESTED_FIELD_KEY]
40
40
  RequestStore.store[GLOBAL_NESTED_FIELD_KEY] = self
41
41
 
42
- block.call.tap do
43
- RequestStore.store[GLOBAL_NESTED_FIELD_KEY] = @parent_nested_field
44
- end
42
+ block.call
43
+ ensure
44
+ RequestStore.store[GLOBAL_NESTED_FIELD_KEY] = @parent_nested_field
45
45
  end
46
46
 
47
- def parent_nested_field
48
- @parent_nested_field || RequestStore.store[GLOBAL_NESTED_FIELD_KEY]
47
+ def parent_nested_field(fallback_to_self: true)
48
+ @parent_nested_field || (RequestStore.store[GLOBAL_NESTED_FIELD_KEY] if fallback_to_self)
49
49
  end
50
50
  end
51
51
  end
@@ -4,7 +4,7 @@ module Para
4
4
  attr_reader :resource
5
5
 
6
6
  def input(_wrapper_options = nil)
7
- input_html_options[:class] << "nested-many"
7
+ input_html_options[:class] << 'nested-many'
8
8
 
9
9
  orderable = options.fetch(:orderable, model.orderable?)
10
10
  add_button = options.fetch(:add_button, true)
@@ -40,6 +40,15 @@ module Para
40
40
  end
41
41
  end
42
42
 
43
+ protected
44
+
45
+ def render_partial?
46
+ options[:render_partial] ||
47
+ object.errors.any? ||
48
+ (object.persisted? && uncollapsed?) ||
49
+ parent_nested_field(fallback_to_self: false)&.render_partial?
50
+ end
51
+
43
52
  private
44
53
 
45
54
  def parent_model
@@ -58,10 +67,6 @@ module Para
58
67
  inset? && Para.config.uncollapse_inset_nested_fields
59
68
  end
60
69
 
61
- def render_partial?
62
- options[:render_partial] || object.errors.any? || (object.persisted? && uncollapsed?)
63
- end
64
-
65
70
  def remote_partial_params
66
71
  @remote_partial_params ||= options.fetch(:remote_partial_params, {}).merge(
67
72
  namespace: :nested_form
data/lib/para/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Para
4
- VERSION = '0.11.0'
4
+ VERSION = '0.11.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: para
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentin Ballestrino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-06 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_decorator
@@ -862,7 +862,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
862
862
  - !ruby/object:Gem::Version
863
863
  version: '0'
864
864
  requirements: []
865
- rubygems_version: 3.4.2
865
+ rubygems_version: 3.4.4
866
866
  signing_key:
867
867
  specification_version: 4
868
868
  summary: Rails admin engine