composite_content 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +1 -1
- data/composite_content.gemspec +1 -1
- data/config/locales/fr.yml +1 -1
- data/lib/composite_content/action_view.rb +2 -2
- data/lib/composite_content/active_record.rb +1 -1
- data/lib/composite_content/engine.rb +8 -1
- data/lib/composite_content/model/blockable.rb +6 -0
- data/lib/composite_content/slot.rb +13 -10
- data/lib/composite_content/version.rb +1 -1
- data/lib/generators/composite_content/templates/block/_form.html.erb +2 -1
- data/lib/generators/composite_content/templates/slot/_form.html.erb +2 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3745b218d85539ed9073b1d873a089cb105ad42a55626605e2efeaaaa4099229
|
4
|
+
data.tar.gz: eeeb112da951023401f8966f306cf9b9fbb353576c448b5b3ea515da390fc076
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
100
|
+
<%= render "#{CompositeContent::Engine.config.views_path}/slot/form", form: composite_content_form %>
|
101
101
|
<% end %>
|
102
102
|
```
|
103
103
|
|
data/composite_content.gemspec
CHANGED
@@ -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
|
39
|
+
spec.add_dependency 'cocooned', '~> 2.0'
|
40
40
|
spec.add_dependency 'rails', '>= 6.1.0'
|
41
41
|
|
42
42
|
# Development tools
|
data/config/locales/fr.yml
CHANGED
@@ -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 "
|
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:
|
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.
|
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
|
-
[
|
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
|
41
|
-
@
|
42
|
-
|
43
|
-
|
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
|
48
|
-
@
|
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
|
@@ -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 "
|
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
|
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.
|
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:
|
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
|
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
|
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.
|
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.
|