para 0.8.5 → 0.8.7

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
  SHA1:
3
- metadata.gz: 46dd04d9d028f48edd61932e381aba77607696e2
4
- data.tar.gz: 7b3c9b9fa4a6d1440879c2cec9561c9ddb36fe8b
3
+ metadata.gz: 8f7d2729a7b4605f42e736da01ed85636b39232c
4
+ data.tar.gz: 42a119d77586ef8db3eee57231c3a46154141e1c
5
5
  SHA512:
6
- metadata.gz: 21fc22237a68f50fdac07a4fbb8916928735c2d4db73f70aa99debc31992312727ccb0d8cb07991869222795be844148674a50bddebb49af17af0418a7a010b7
7
- data.tar.gz: 12a8f6e72b4f33d1c2a0c0ebaefb58bb0a59ad698e60a3afb4575799550fb5dee72ea6308977dbb98d3c269864930ac5464ddc77b8bd62a4cc9f5ef2a17eeb10
6
+ metadata.gz: 44f44a2d7340fa890359d5f259f90b591f2436609399028bb77a54237f1e49b95d81435a807c452234cc58904a2a7773bd469be58b373d4074244a540a325442
7
+ data.tar.gz: 25280f88dd481faf6882df01416d85b31cc0a3fcc7204487ad53d7837bd7220463b0280141e1cdc203c577960ac103977abbd7d560ca9570fb00dd76325ec166
@@ -18,20 +18,20 @@ class Para.NestedManyField
18
18
  @$fieldsList.on('sortupdate', $.proxy(@sortUpdate, this))
19
19
 
20
20
  sortUpdate: ->
21
- @$fieldsList.find('.form-fields').each (i, el) ->
21
+ @$fieldsList.find('.form-fields:visible').each (i, el) ->
22
22
  $(el).find('.resource-position-field').val(i)
23
23
 
24
24
  initializeCocoon: ->
25
25
  @$fieldsList.on 'cocoon:after-insert', $.proxy(@afterInsertField, this)
26
26
  @$fieldsList.on 'cocoon:before-remove', $.proxy(@beforeRemoveField, this)
27
+ @$fieldsList.on 'cocoon:after-remove', $.proxy(@afterRemoveField, this)
27
28
 
28
29
  afterInsertField: (e, $element) ->
29
30
  if ($collapsible = $element.find('[data-open-on-insert="true"]')).length
30
31
  @openInsertedField($collapsible)
31
32
 
32
33
  if @orderable
33
- @$fieldsList.sortable('destroy')
34
- @initializeOrderable()
34
+ @$fieldsList.sortable('reload')
35
35
  @sortUpdate()
36
36
 
37
37
  $element.simpleForm()
@@ -42,6 +42,10 @@ class Para.NestedManyField
42
42
  # create an empty nested resource otherwise
43
43
  $nextEl.remove() if $nextEl.is('[data-attributes-mappings]') and not $element.is('[data-persisted]')
44
44
 
45
+ # When a sub field is removed, update every sub field position
46
+ afterRemoveField: ->
47
+ @sortUpdate();
48
+
45
49
  openInsertedField: ($field) ->
46
50
  $target = $($field.attr('href'))
47
51
  $target.collapse('show')
@@ -4,6 +4,10 @@
4
4
  = render partial: find_partial_for(relation, :actions), locals: { relation: relation, component: component, model: model, allow_adding_resource: allow_adding_resource }
5
5
 
6
6
  - if resources.length > 0
7
+ - if resources.total_count > 100
8
+ .page-entries-info
9
+ = page_entries(resources)
10
+
7
11
  %ul.tree.root-tree{ data: { url: component.relation_path(model.model_name.route_key, action: :tree), :"max-depth" => max_depth_for(model) } }
8
12
  = render partial: find_partial_for(model, 'tree_item'), collection: resources.roots, as: :root, locals: { model: model}
9
13
 
@@ -1,10 +1,10 @@
1
1
  .nested-many-field{ class: [('orderable' if orderable), ('nested-many-field-inset' if inset)] }
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
- = 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, render_partial: render_partial, remote_partial_params: remote_partial_params }
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
  -# Add button
6
6
  - if add_button
7
7
  - if subclass
8
- = render partial: 'para/inputs/nested_many/add_with_subclasses', locals: { form: form, model: model, dom_identifier: dom_identifier, nested_locals: nested_locals, attribute_name: attribute_name, orderable: orderable, subclasses: subclasses, inset: inset, add_button_label: add_button_label, add_button_class: add_button_class, render_partial: render_partial, remote_partial_params: remote_partial_params }
8
+ = render partial: 'para/inputs/nested_many/add_with_subclasses', locals: { form: form, model: model, dom_identifier: dom_identifier, nested_locals: nested_locals, attribute_name: attribute_name, orderable: orderable, subclasses: subclasses, inset: inset, uncollapsed: uncollapsed, add_button_label: add_button_label, add_button_class: add_button_class, render_partial: render_partial, remote_partial_params: remote_partial_params }
9
9
  - else
10
- = render partial: 'para/inputs/nested_many/add', locals: { form: form, model: model, dom_identifier: dom_identifier, nested_locals: nested_locals, attribute_name: attribute_name, orderable: orderable, inset: inset, add_button_label: add_button_label, add_button_class: add_button_class, render_partial: render_partial, remote_partial_params: remote_partial_params }
10
+ = render partial: 'para/inputs/nested_many/add', locals: { form: form, model: model, dom_identifier: dom_identifier, nested_locals: nested_locals, attribute_name: attribute_name, orderable: orderable, inset: inset, uncollapsed: uncollapsed, add_button_label: add_button_label, add_button_class: add_button_class, render_partial: render_partial, remote_partial_params: remote_partial_params }
@@ -1,2 +1,2 @@
1
- = link_to_add_association form, attribute_name, partial: find_partial_for(model, 'nested_many/container', partial_dir: 'inputs'), form_name: 'form', class: "btn btn-shadow add-button nested-many-inset-add-button #{add_button_class}", data: { :'association-insertion-node' => "##{ dom_identifier }", :'association-insertion-method' => 'append' }, render_options: { nested_attribute_name: attribute_name, orderable: orderable, locals: { model: model, nested_locals: nested_locals, inset: inset, render_partial: render_partial, remote_partial_params: remote_partial_params } } do
1
+ = link_to_add_association form, attribute_name, partial: find_partial_for(model, 'nested_many/container', partial_dir: 'inputs'), form_name: 'form', class: "btn btn-shadow add-button nested-many-inset-add-button #{add_button_class}", data: { :'association-insertion-node' => "##{ dom_identifier }", :'association-insertion-method' => 'append' }, render_options: { nested_attribute_name: attribute_name, orderable: orderable, locals: { model: model, nested_locals: nested_locals, inset: inset, uncollapsed: uncollapsed, render_partial: render_partial, remote_partial_params: remote_partial_params } } do
2
2
  = add_button_label
@@ -5,5 +5,5 @@
5
5
  %ul.dropdown-menu
6
6
  - subclasses.each do |submodel|
7
7
  %li
8
- = link_to_add_association form, attribute_name, wrap_object: proc { submodel.new }, partial: find_partial_for(submodel, 'nested_many/container', partial_dir: 'inputs'), form_name: 'form', class: 'dropdown-link', data: { :'association-insertion-node' => "##{ dom_identifier }", :'association-insertion-method' => 'append' }, render_options: { nested_attribute_name: attribute_name, orderable: orderable, locals: { model: submodel, nested_locals: nested_locals, inset: inset, render_partial: render_partial, remote_partial_params: remote_partial_params } } do
8
+ = link_to_add_association form, attribute_name, wrap_object: proc { submodel.new }, partial: find_partial_for(submodel, 'nested_many/container', partial_dir: 'inputs'), form_name: 'form', class: 'dropdown-link', data: { :'association-insertion-node' => "##{ dom_identifier }", :'association-insertion-method' => 'append' }, render_options: { nested_attribute_name: attribute_name, orderable: orderable, locals: { model: submodel, nested_locals: nested_locals, inset: inset, uncollapsed: uncollapsed, render_partial: render_partial, remote_partial_params: remote_partial_params } } do
9
9
  = submodel.model_name.human
@@ -11,7 +11,7 @@
11
11
 
12
12
  = form.remove_association_button
13
13
 
14
- .panel-collapse.form-inputs.collapse{ id: form.nested_resource_dom_id, class: ('in' if inset && 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 } }
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
17
  = render partial: find_partial_for(model, :fields), locals: { form: form }.merge(nested_locals)
@@ -27,9 +27,17 @@ Para.config do |config|
27
27
  # config.resource_name_methods += [:full_name]
28
28
 
29
29
  # Configure the theme navigation bar color not gray but blue darker
30
- #
30
+ #
31
31
  # config.dark_theme = true
32
32
 
33
+ # Do not uncollapse by default "inset" nested fields, which makes all such nested field
34
+ # blocks get collapsed on page load, and can be easier to read for big blocks.
35
+ #
36
+ # This also speeds up page loading when used in conjunction to remote partial loading
37
+ # for nested fields
38
+ #
39
+ # config.uncollapse_inset_nested_fields = false
40
+
33
41
  # Set if the Para::Breadcrumb::Controller module should be included into the
34
42
  # app, allowing easy breadcrumbs management in the app.
35
43
  #
@@ -42,6 +42,9 @@ module Para
42
42
  mattr_accessor :dark_theme
43
43
  @@dark_theme = false
44
44
 
45
+ mattr_accessor :uncollapse_inset_nested_fields
46
+ @@uncollapse_inset_nested_fields = true
47
+
45
48
  # Allows changing default cache store used by Para to store jobs through
46
49
  # the ActiveJob::Status gem
47
50
  #
@@ -32,6 +32,7 @@ module Para
32
32
  add_button_label: add_button_label,
33
33
  add_button_class: add_button_class,
34
34
  inset: inset?,
35
+ uncollapsed: uncollapsed?,
35
36
  render_partial: render_partial?,
36
37
  remote_partial_params: remote_partial_params
37
38
  }
@@ -50,9 +51,13 @@ module Para
50
51
  def inset?
51
52
  options.fetch(:inset, false)
52
53
  end
53
-
54
+
55
+ def uncollapsed?
56
+ inset? && Para.config.uncollapse_inset_nested_fields
57
+ end
58
+
54
59
  def render_partial?
55
- options[:render_partial] || object.errors.any? || (object.persisted? && inset?)
60
+ options[:render_partial] || object.errors.any? || (object.persisted? && uncollapsed?)
56
61
  end
57
62
 
58
63
  def remote_partial_params
@@ -1,3 +1,3 @@
1
1
  module Para
2
- VERSION = '0.8.5'
2
+ VERSION = '0.8.7'
3
3
  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.8.5
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentin Ballestrino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-24 00:00:00.000000000 Z
11
+ date: 2020-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails