composite_content 2.0.0 → 2.1.0

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: ccf56533554d8f9d97dfab613e4ee0ada78da592eccd4cceb8df32e6a0a1c8d2
4
+ data.tar.gz: 672795ed87288743f2ff87f37e025d43ba719d6e642e363fda2cc71ecf10086e
5
5
  SHA512:
6
- metadata.gz: c2e7259176997a992fe3d415140e23fc4d5f9dbee1a7cf14b5fdf589b3a966fb4e5b54257f59dc7c76741b0e352522ce3cff1baefda77df2fa4f05b55fa8f5b9
7
- data.tar.gz: c31419a9fd5cac3cf1d784523603b22ab7afebe068ecae2a0477a7203e2c503d49ba8e484c904237df33e78ab6b85ddd080f2beecf2c7de4e862540bfba9f2ee
6
+ metadata.gz: 8033506c9619daa7030139aed7964359e8007f6d41d2c328d2403c06d14e5a6828444e25e055e4b77a525589299e229464f3b7aa96eedf10bc9f8c9daa7b951e
7
+ data.tar.gz: ce91296bce01bb21899f02ac3a0f9779b4600bf8acbf5c083c13e24655b3e2d67e90919ad0f7bca1bf143c3b165f97e980c7b51d0e722cbe87ef55bddf6796e4
data/CHANGELOG.md CHANGED
@@ -6,6 +6,17 @@ 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.0 (2023-08-29)
10
+
11
+ ### Added
12
+
13
+ * Allow to customize strong parameters names on a block class with `.strong_parameters_names` (#11)
14
+ * Allow to change composite_content views base path with `CompositeContent::Engine.config.views_path` (#10)
15
+
16
+ ### Fixed
17
+
18
+ * Typo in french translations
19
+
9
20
  ## Version 2.0.0 (2023-03-07)
10
21
 
11
22
  ### 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
 
@@ -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)
@@ -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.0'
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.0
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: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_validations_reflection