composite_content 2.0.0 → 2.1.1

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: 680f59341660c804a27f25a26c3f7446431f3fbd3757a5eaa5b3604ef46beb06
4
- data.tar.gz: c2ea06855dd833d72e66a2f62ce78f58fde9418c81d8c23c8c5415c37e984896
3
+ metadata.gz: 3745b218d85539ed9073b1d873a089cb105ad42a55626605e2efeaaaa4099229
4
+ data.tar.gz: eeeb112da951023401f8966f306cf9b9fbb353576c448b5b3ea515da390fc076
5
5
  SHA512:
6
- metadata.gz: c2e7259176997a992fe3d415140e23fc4d5f9dbee1a7cf14b5fdf589b3a966fb4e5b54257f59dc7c76741b0e352522ce3cff1baefda77df2fa4f05b55fa8f5b9
7
- data.tar.gz: c31419a9fd5cac3cf1d784523603b22ab7afebe068ecae2a0477a7203e2c503d49ba8e484c904237df33e78ab6b85ddd080f2beecf2c7de4e862540bfba9f2ee
6
+ metadata.gz: 91e67d3559f79d0c5d6aa82c22b6735389f22fbc8ea08b8e20a3657b915b7b91bdfeb6be08981fdcf99bdebf99672b44875d3f36184cad41c308c8095525e566
7
+ data.tar.gz: c235b84b318b7218a9cc545ef333cfaaae3339e673f495404f73046fc6706488c52599167c5b7cd669fb398001ecc56a0318e09248d01b245752a6acaebafb5f
data/CHANGELOG.md CHANGED
@@ -6,6 +6,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## Version 2.1.1 (2024-02-10)
10
+
11
+ ### Changed
12
+
13
+ * Compatibility with Cocooned 2.1 (#15)
14
+ * Compatibility with Rails 7.1 (#14)
15
+ * Update test matrix (#14)
16
+ Add Ruby 3.3. Drop Ruby 2.6 and Ruby 2.7
17
+
18
+ ## Version 2.1.0 (2023-08-29)
19
+
20
+ ### Added
21
+
22
+ * Allow to customize strong parameters names on a block class with `.strong_parameters_names` (#11)
23
+ * Allow to change composite_content views base path with `CompositeContent::Engine.config.views_path` (#10)
24
+
25
+ ### Fixed
26
+
27
+ * Typo in french translations
28
+
9
29
  ## Version 2.0.0 (2023-03-07)
10
30
 
11
31
  ### Breaking changes
data/README.md CHANGED
@@ -97,7 +97,7 @@ In your forms, make composite content editable with:
97
97
 
98
98
  ```erbruby
99
99
  <%= form.fields_for :composite_content do |composite_content_form| %>
100
- <%= render 'composite_content/slot/form', form: composite_content_form %>
100
+ <%= render "#{CompositeContent::Engine.config.views_path}/slot/form", form: composite_content_form %>
101
101
  <% end %>
102
102
  ```
103
103
 
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  spec.add_dependency 'active_model_validations_reflection'
38
38
  spec.add_dependency 'acts_as_list', '>= 1.0.4'
39
- spec.add_dependency 'cocooned', '~> 2.0.0'
39
+ spec.add_dependency 'cocooned', '~> 2.0'
40
40
  spec.add_dependency 'rails', '>= 6.1.0'
41
41
 
42
42
  # Development tools
@@ -7,4 +7,4 @@ fr:
7
7
  quote:
8
8
  add: Ajouter une citation
9
9
  text:
10
- add: Ajouter un text
10
+ add: Ajouter un texte
@@ -6,7 +6,7 @@ module CompositeContent
6
6
  # Render the content of a CompositeContent::Slot.
7
7
  def composite_content_render(slot)
8
8
  renders = slot.blocks.collect do |block|
9
- render "composite_content/blocks/#{block.blockable.block_type}/show", block: block
9
+ render "#{CompositeContent::Engine.config.views_path}/blocks/#{block.blockable.block_type}/show", block: block
10
10
  end
11
11
 
12
12
  safe_join(renders)
@@ -49,7 +49,7 @@ module CompositeContent
49
49
  label ||= composite_content_default_label(block_type)
50
50
  opts = (options || {}).except(:count, :form_name, :force_non_association_create)
51
51
  .merge!(form_name: :form,
52
- partial: 'composite_content/block/form',
52
+ partial: "#{CompositeContent::Engine.config.views_path}/block/form",
53
53
  wrap_object: ->(b) { composite_content_wrap_block(b, block_type) })
54
54
 
55
55
  cocooned_add_item_link(label, form, :blocks, opts)
@@ -34,7 +34,7 @@ module CompositeContent
34
34
 
35
35
  def class_mixin(name)
36
36
  Module.new do
37
- define_method "strong_parameters_for_#{name}" do
37
+ define_method :"strong_parameters_for_#{name}" do
38
38
  reflect_on_association(name).class_name.constantize.strong_parameters
39
39
  end
40
40
  end
@@ -14,7 +14,10 @@ module CompositeContent
14
14
  #
15
15
  # # In config/initializers/composite_content.rb
16
16
  # require 'composite_content'
17
- # CompositeContent::Engine.config.block_types += %w[CompositeContent::Blocks::Image]
17
+ # CompositeContent::Engine.config.tap do |config|
18
+ # config.block_types += %w[CompositeContent::Blocks::Image]
19
+ # config.views_path = 'shared/composite_content'
20
+ # end
18
21
 
19
22
  # Allowed block types
20
23
  config.block_types = %w[
@@ -23,6 +26,10 @@ module CompositeContent
23
26
  CompositeContent::Blocks::Text
24
27
  ]
25
28
 
29
+ # Path where the composite content partials are stored in your application.
30
+ # Relative to `app/views/`
31
+ config.views_path = 'composite_content'
32
+
26
33
  # Engine internals
27
34
  #
28
35
  # Following configurations are here for engine initialization and internal
@@ -16,6 +16,12 @@ module CompositeContent
16
16
  def block_type
17
17
  self.class.name.demodulize.underscore
18
18
  end
19
+
20
+ module ClassMethods # :nodoc:
21
+ def strong_parameters_names
22
+ column_names.collect(&:to_sym) - %i[created_at updated_at]
23
+ end
24
+ end
19
25
  end
20
26
  end
21
27
  end
@@ -32,23 +32,26 @@ module CompositeContent
32
32
  end
33
33
 
34
34
  def strong_parameters
35
- [:id, { blocks_attributes: block_column_names + [{ blockable_attributes: blockable_column_names }, :_destroy] }]
35
+ [
36
+ :id,
37
+ { blocks_attributes: block_strong_parameters_names + [
38
+ { blockable_attributes: blockable_strong_parameters_names },
39
+ :_destroy
40
+ ] }
41
+ ]
36
42
  end
37
43
 
38
44
  protected
39
45
 
40
- def block_column_names
41
- @block_column_names ||= begin
42
- columns = block_class.column_names.collect(&:to_sym)
43
- columns - %i[slot_id blockable_id created_at updated_at]
46
+ def block_strong_parameters_names
47
+ @block_strong_parameters_names ||= begin
48
+ parameters = block_class.column_names.collect(&:to_sym)
49
+ parameters - %i[slot_id blockable_id created_at updated_at]
44
50
  end
45
51
  end
46
52
 
47
- def blockable_column_names
48
- @blockable_column_names ||= begin
49
- columns = blockable_classes.collect(&:column_names).flatten.collect(&:to_sym).compact.uniq
50
- columns - %i[created_at updated_at]
51
- end
53
+ def blockable_strong_parameters_names
54
+ @blockable_strong_parameters_names ||= blockable_classes.collect(&:strong_parameters_names).flatten.compact.uniq
52
55
  end
53
56
  end
54
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CompositeContent
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.1'
5
5
  end
@@ -4,7 +4,8 @@
4
4
  <%= form.hidden_field :blockable_type %>
5
5
 
6
6
  <%= form.fields_for :blockable, form.object.blockable do |blockable_form| %>
7
- <%= render "composite_content/blocks/#{form.object.blockable.block_type}/form", form: blockable_form %>
7
+ <%= render "#{CompositeContent::Engine.config.views_path}/blocks/#{form.object.blockable.block_type}/form",
8
+ form: blockable_form %>
8
9
  <% end %>
9
10
 
10
11
  <%= composite_content_move_block_up_link form %>
@@ -2,7 +2,8 @@
2
2
 
3
3
  <%= cocooned_container reorderable: true do %>
4
4
  <%= form.fields_for :blocks do |block_form| %>
5
- <%= render 'composite_content/block/form', form: block_form %>
5
+ <%= render "#{CompositeContent::Engine.config.views_path}/block/form",
6
+ form: block_form %>
6
7
  <% end %>
7
8
 
8
9
  <div class="links">
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composite_content
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaël-Ian Havard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
11
+ date: 2024-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_validations_reflection
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.0
47
+ version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.0
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
197
  requirements: []
198
- rubygems_version: 3.4.1
198
+ rubygems_version: 3.5.3
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: Add composite content capacities to your ActiveRecord models.