para 0.8.13 → 0.9.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/para/inputs/nested_many.coffee +14 -8
- data/app/controllers/para/admin/exports_controller.rb +1 -1
- data/app/controllers/para/admin/nested_forms_controller.rb +1 -0
- data/app/helpers/para/admin/components_helper.rb +10 -2
- data/app/helpers/para/tag_helper.rb +6 -2
- data/app/views/para/admin/nested_forms/show.html.haml +10 -1
- data/app/views/para/admin/resources/_remote_nested_form.html.haml +1 -1
- data/app/views/para/admin/shared/_navigation.html.haml +1 -1
- data/app/views/para/inputs/_nested_many.html.haml +1 -0
- data/app/views/para/inputs/_nested_one.html.haml +2 -2
- data/app/views/para/inputs/nested_many/_container.html.haml +1 -1
- data/app/views/para/inputs/nested_one/_container.html.haml +1 -1
- data/lib/para/form_builder/nested_form.rb +8 -0
- data/lib/para/inputs/nested_many_input.rb +3 -1
- data/lib/para/version.rb +1 -1
- metadata +22 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39e971f0c36fc8256afd9883b9865af8be4628934c8aad4d998aa0efc47173a5
|
4
|
+
data.tar.gz: d0cb9cc08791c12f92ad514714d05782d643fa167511215ac53ddb765c030b50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdb7af1bcc3fa32b75acc7e0212f02d612037f90ef06c6b7c988002e376582cd620099ffc3267c49e70488b33c6da36d80b5bb75d0557c870a98d59490e5d40a
|
7
|
+
data.tar.gz: bddb7765e1d09f4bce763884fffbd1d9815c346cb028dc227f26287060724f9ba5ad4ed9d0bdbc682fa79b8aa07952dec5c1ec45234a902631fbe50729d17531
|
@@ -5,7 +5,7 @@ class Para.NestedManyField
|
|
5
5
|
@initializeOrderable()
|
6
6
|
@initializeCocoon()
|
7
7
|
|
8
|
-
@$field.on 'shown.bs.collapse',
|
8
|
+
@$field.on 'shown.bs.collapse', @stoppingPropagation(@collapseShown)
|
9
9
|
|
10
10
|
initializeOrderable: ->
|
11
11
|
@orderable = @$field.hasClass('orderable')
|
@@ -21,11 +21,17 @@ class Para.NestedManyField
|
|
21
21
|
$(el).find('.resource-position-field').val(i)
|
22
22
|
|
23
23
|
initializeCocoon: ->
|
24
|
-
@$fieldsList.on 'cocoon:after-insert',
|
25
|
-
@$fieldsList.on 'cocoon:before-remove',
|
26
|
-
@$fieldsList.on 'cocoon:after-remove',
|
24
|
+
@$fieldsList.on 'cocoon:after-insert', @afterInsertField
|
25
|
+
@$fieldsList.on 'cocoon:before-remove', @beforeRemoveField
|
26
|
+
@$fieldsList.on 'cocoon:after-remove', @afterRemoveField
|
27
27
|
|
28
|
-
|
28
|
+
stoppingPropagation: (callback) =>
|
29
|
+
(e, args...) =>
|
30
|
+
e.stopPropagation()
|
31
|
+
callback(e, args...)
|
32
|
+
|
33
|
+
|
34
|
+
afterInsertField: (e, $element) =>
|
29
35
|
if ($collapsible = $element.find('[data-open-on-insert="true"]')).length
|
30
36
|
@openInsertedField($collapsible)
|
31
37
|
|
@@ -36,21 +42,21 @@ class Para.NestedManyField
|
|
36
42
|
|
37
43
|
$element.simpleForm()
|
38
44
|
|
39
|
-
beforeRemoveField: (e, $element)
|
45
|
+
beforeRemoveField: (e, $element) =>
|
40
46
|
$nextEl = $element.next()
|
41
47
|
# Remove attributes mappings field for new records since it will try to
|
42
48
|
# create an empty nested resource otherwise
|
43
49
|
$nextEl.remove() if $nextEl.is('[data-attributes-mappings]') and not $element.is('[data-persisted]')
|
44
50
|
|
45
51
|
# When a sub field is removed, update every sub field position
|
46
|
-
afterRemoveField:
|
52
|
+
afterRemoveField: =>
|
47
53
|
@handleOrderingUpdated();
|
48
54
|
|
49
55
|
openInsertedField: ($field) ->
|
50
56
|
$target = $($field.attr('href'))
|
51
57
|
$target.collapse('show')
|
52
58
|
|
53
|
-
collapseShown: (e)
|
59
|
+
collapseShown: (e) =>
|
54
60
|
$target = $(e.target)
|
55
61
|
|
56
62
|
if $target.is("[data-rendered]") or $target.data("rendered")
|
@@ -5,8 +5,10 @@ module Para
|
|
5
5
|
#
|
6
6
|
def admin_component_sections
|
7
7
|
@admin_component_sections ||= begin
|
8
|
-
Para::ComponentSection.ordered.includes(:components)
|
9
|
-
|
8
|
+
sections = Para::ComponentSection.ordered.includes(:components, :parent_component)
|
9
|
+
|
10
|
+
sections.tap do |loaded_sections|
|
11
|
+
loaded_sections.flat_map(&:components).each(&method(:decorate))
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
@@ -23,5 +25,11 @@ module Para
|
|
23
25
|
config = Para.components.component_configuration_for(component.identifier)
|
24
26
|
!config.shown_if || instance_exec(&config.shown_if)
|
25
27
|
end
|
28
|
+
|
29
|
+
def current_component_or_parent?(component)
|
30
|
+
return false unless @component
|
31
|
+
|
32
|
+
@component == component || @component.parent_component == component
|
33
|
+
end
|
26
34
|
end
|
27
35
|
end
|
@@ -19,9 +19,13 @@ module Para
|
|
19
19
|
attributes = model_field_mappings(model).fields
|
20
20
|
relation = options.fetch(:relation, model.name.to_s.underscore.pluralize)
|
21
21
|
allow_adding_resource = options.fetch(:addable, true)
|
22
|
+
force_list = options.fetch(:force_list, false)
|
22
23
|
|
23
|
-
partial = :
|
24
|
-
|
24
|
+
partial = if !force_list && model.respond_to?(:roots) && can?(:tree, model)
|
25
|
+
:tree
|
26
|
+
else
|
27
|
+
:list
|
28
|
+
end
|
25
29
|
|
26
30
|
render(
|
27
31
|
partial: find_partial_for(relation, partial),
|
@@ -1,6 +1,15 @@
|
|
1
1
|
- nested_form = nil
|
2
2
|
|
3
|
-
|
3
|
+
-# Initialize an unredered form builder that will only be used to create the nested fields
|
4
|
+
-# by using the yielded block form builder argument.
|
5
|
+
-#
|
6
|
+
-# The form's object name is set through the provided :object_name param to ensure that
|
7
|
+
-# the form inputs are named correctly in the loading form.
|
8
|
+
-#
|
9
|
+
-# Builder options allow to customize the options passed to the form builder to customize
|
10
|
+
-# the rendered partials.
|
11
|
+
-#
|
12
|
+
- para_form_for(@object, @builder_options.merge(url: "")) do |form|
|
4
13
|
- form.object_name = @object_name
|
5
14
|
- nested_form = capture do
|
6
15
|
= render(partial: find_partial_for(@model, :remote_nested_form), locals: { form: form, model: @model, object: @object, object_name: @object_name })
|
@@ -1 +1 @@
|
|
1
|
-
= render partial: find_partial_for(model,
|
1
|
+
= render partial: find_partial_for(model, form.nested_fields_partial_name), locals: { form: form }
|
@@ -15,7 +15,7 @@
|
|
15
15
|
%ul.component-section-list-items.collapse.in{ id: "collapse-section-#{index}" }
|
16
16
|
- component_section.components.each do |component|
|
17
17
|
- if can?(:manage, component) && show_component?(component)
|
18
|
-
%li.component-item{ class: (
|
18
|
+
%li.component-item{ class: ('active' if current_component_or_parent?(component)) }
|
19
19
|
= link_to component.main_navigation_name, component.path
|
20
20
|
|
21
21
|
- else
|
@@ -2,6 +2,7 @@
|
|
2
2
|
.fields-list{ id: dom_identifier }
|
3
3
|
= form.simple_fields_for attribute_name, resources, nested_attribute_name: attribute_name, orderable: orderable, track_attribute_mappings: render_partial do |nested_form|
|
4
4
|
= render partial: find_partial_for(model, 'nested_many/container', partial_dir: 'inputs'), locals: { form: nested_form, model: nested_form.object.class, subclass: subclass, nested_locals: nested_locals, inset: inset, uncollapsed: uncollapsed, render_partial: render_partial, remote_partial_params: remote_partial_params }
|
5
|
+
|
5
6
|
-# Add button
|
6
7
|
- if add_button
|
7
8
|
- if subclass
|
@@ -6,7 +6,7 @@
|
|
6
6
|
= render partial: find_partial_for(model, 'nested_one/container', partial_dir: 'inputs'), locals: { nested_form: nested_form, form: form, model: nested_form.object.class, subclass: subclass, nested_locals: nested_locals }
|
7
7
|
|
8
8
|
- else
|
9
|
-
= render partial: find_partial_for(model,
|
9
|
+
= render partial: find_partial_for(model, form.nested_fields_partial_name), locals: { form: nested_form, parent: form.object }.merge(nested_locals)
|
10
10
|
|
11
11
|
- if defined?(subclass) && subclass
|
12
|
-
= render partial: 'para/inputs/nested_one/add_with_subclasses', locals: { form: form, model: model, dom_identifier: dom_identifier, nested_locals: nested_locals, attribute_name: attribute_name, subclasses: subclasses, add_button_label: add_button_label, add_button_class: add_button_class, subclass: subclass }
|
12
|
+
= render partial: 'para/inputs/nested_one/add_with_subclasses', locals: { form: form, model: model, dom_identifier: dom_identifier, nested_locals: nested_locals, attribute_name: attribute_name, subclasses: subclasses, add_button_label: add_button_label, add_button_class: add_button_class, subclass: subclass }
|
@@ -14,7 +14,7 @@
|
|
14
14
|
.panel-collapse.form-inputs.collapse{ id: form.nested_resource_dom_id, class: ('in' if uncollapsed && form.object.persisted?), data: { rendered: render_partial, render_path: @component.path(remote_partial_params), id: form.object.id, :"object-name" => form.object_name, :"model-name" => model.name } }
|
15
15
|
.panel-body{ data: { :"nested-form-container" => true } }
|
16
16
|
- if render_partial
|
17
|
-
= render partial: find_partial_for(model,
|
17
|
+
= render partial: find_partial_for(model, form.nested_fields_partial_name), locals: { form: form }.merge(nested_locals)
|
18
18
|
- else
|
19
19
|
= fa_icon "spinner spin"
|
20
20
|
|
@@ -6,4 +6,4 @@
|
|
6
6
|
%i.fa.fa-angle-up
|
7
7
|
|
8
8
|
.panel-body.panel-collapse.form-inputs.collapse{ id: nested_form.nested_resource_dom_id }
|
9
|
-
= render partial: find_partial_for(model,
|
9
|
+
= render partial: find_partial_for(model, form.nested_fields_partial_name), locals: { form: nested_form, parent: nested_form.object }.merge(nested_locals)
|
@@ -76,6 +76,14 @@ module Para
|
|
76
76
|
nested? && options[:parent_builder].object
|
77
77
|
end
|
78
78
|
|
79
|
+
# Returns the partial name to be looked up for rendering used inside the nested
|
80
|
+
# fields partials, for the nested fields container and the remote nested fields
|
81
|
+
# partial.
|
82
|
+
#
|
83
|
+
def nested_fields_partial_name
|
84
|
+
:fields
|
85
|
+
end
|
86
|
+
|
79
87
|
private
|
80
88
|
|
81
89
|
def default_resource_name
|
@@ -3,7 +3,7 @@ module Para
|
|
3
3
|
class NestedManyInput < NestedBaseInput
|
4
4
|
attr_reader :resource
|
5
5
|
|
6
|
-
def input(
|
6
|
+
def input(_wrapper_options = nil)
|
7
7
|
input_html_options[:class] << "nested-many"
|
8
8
|
|
9
9
|
orderable = options.fetch(:orderable, model.orderable?)
|
@@ -40,6 +40,8 @@ module Para
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
private
|
44
|
+
|
43
45
|
def parent_model
|
44
46
|
@parent_model ||= @builder.object.class
|
45
47
|
end
|
data/lib/para/version.rb
CHANGED
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.
|
4
|
+
version: 0.9.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valentin Ballestrino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '4.0'
|
20
20
|
- - "<="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '4.0'
|
30
30
|
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rails-i18n
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,16 +152,22 @@ dependencies:
|
|
152
152
|
name: paperclip
|
153
153
|
requirement: !ruby/object:Gem::Requirement
|
154
154
|
requirements:
|
155
|
-
- - "
|
155
|
+
- - ">="
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '4.2'
|
158
|
+
- - "<"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '7.0'
|
158
161
|
type: :runtime
|
159
162
|
prerelease: false
|
160
163
|
version_requirements: !ruby/object:Gem::Requirement
|
161
164
|
requirements:
|
162
|
-
- - "
|
165
|
+
- - ">="
|
163
166
|
- !ruby/object:Gem::Version
|
164
167
|
version: '4.2'
|
168
|
+
- - "<"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '7.0'
|
165
171
|
- !ruby/object:Gem::Dependency
|
166
172
|
name: cancancan
|
167
173
|
requirement: !ruby/object:Gem::Requirement
|
@@ -334,16 +340,22 @@ dependencies:
|
|
334
340
|
name: bootstrap-sass
|
335
341
|
requirement: !ruby/object:Gem::Requirement
|
336
342
|
requirements:
|
337
|
-
- - "
|
343
|
+
- - ">="
|
344
|
+
- !ruby/object:Gem::Version
|
345
|
+
version: '3.3'
|
346
|
+
- - "<"
|
338
347
|
- !ruby/object:Gem::Version
|
339
|
-
version: 3.
|
348
|
+
version: '3.5'
|
340
349
|
type: :runtime
|
341
350
|
prerelease: false
|
342
351
|
version_requirements: !ruby/object:Gem::Requirement
|
343
352
|
requirements:
|
344
|
-
- - "
|
353
|
+
- - ">="
|
354
|
+
- !ruby/object:Gem::Version
|
355
|
+
version: '3.3'
|
356
|
+
- - "<"
|
345
357
|
- !ruby/object:Gem::Version
|
346
|
-
version: 3.
|
358
|
+
version: '3.5'
|
347
359
|
- !ruby/object:Gem::Dependency
|
348
360
|
name: font-awesome-rails
|
349
361
|
requirement: !ruby/object:Gem::Requirement
|