alchemy_cms 5.1.2 → 5.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/app/decorators/alchemy/element_editor.rb +66 -0
- data/app/views/alchemy/admin/elements/_element.html.erb +1 -1
- data/lib/alchemy/resource.rb +5 -3
- data/lib/alchemy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33ff8306fdffc9ad14b1bb85077ea9b6bdaafe6439f30b5b499ca6ed77b68c4d
|
4
|
+
data.tar.gz: 7497565de311903f47b2924394f588d49f5542902aab4da14ffd3bb3a01d72be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d385b92ccaaebff2f41118c9cc308524488fd8fecd394bfefa66cee8fc2c4827a08392985920657c87f9a519e274ad368961292500d034dbf276d3e9bea0126d
|
7
|
+
data.tar.gz: 277aade952423c3bd043603e3e4398ce3b8b2e5ea9600f3e5777429d3af29644b9bc4640548d0d4aa5094b5c8a3a3f5b531dd1f2fb9495d1115efdb2d07635c1
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
## 5.1.3 (2021-05-06)
|
2
|
+
|
3
|
+
- Use symbols in polymorphic routes for resources [#2087](https://github.com/AlchemyCMS/alchemy_cms/pull/2087) ([tvdeyen](https://github.com/tvdeyen))
|
4
|
+
- Backport #2049 to 5.1 [#2059](https://github.com/AlchemyCMS/alchemy_cms/pull/2059) ([rickythefox](https://github.com/rickythefox))
|
1
5
|
## 5.1.2 (2021-01-26)
|
2
6
|
|
3
7
|
- Allow to safe hidden elements [#2007](https://github.com/AlchemyCMS/alchemy_cms/pull/2007) ([tvdeyen](https://github.com/tvdeyen))
|
4
8
|
|
5
|
-
|
6
9
|
## 5.1.1 (2021-01-12)
|
7
10
|
|
8
11
|
- Fix copy element feature [#1996](https://github.com/AlchemyCMS/alchemy_cms/pull/1996) ([tvdeyen](https://github.com/tvdeyen))
|
@@ -8,6 +8,17 @@ module Alchemy
|
|
8
8
|
"alchemy/admin/elements/element"
|
9
9
|
end
|
10
10
|
|
11
|
+
# Returns content editor instances for defined contents
|
12
|
+
#
|
13
|
+
# Creates contents on demand if the content is not yet present on the element
|
14
|
+
#
|
15
|
+
# @return Array<Alchemy::ContentEditor>
|
16
|
+
def contents
|
17
|
+
element.definition.fetch(:contents, []).map do |content|
|
18
|
+
Alchemy::ContentEditor.new(find_or_create_content(content[:name]))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
11
22
|
# CSS classes for the element editor partial.
|
12
23
|
def css_classes
|
13
24
|
[
|
@@ -36,5 +47,60 @@ module Alchemy
|
|
36
47
|
|
37
48
|
super
|
38
49
|
end
|
50
|
+
|
51
|
+
# Returns a deprecation notice for elements marked deprecated
|
52
|
+
#
|
53
|
+
# You can either use localizations or pass a String as notice
|
54
|
+
# in the element definition.
|
55
|
+
#
|
56
|
+
# == Custom deprecation notices
|
57
|
+
#
|
58
|
+
# Use general element deprecation notice
|
59
|
+
#
|
60
|
+
# - name: old_element
|
61
|
+
# deprecated: true
|
62
|
+
#
|
63
|
+
# Add a translation to your locale file for a per element notice.
|
64
|
+
#
|
65
|
+
# en:
|
66
|
+
# alchemy:
|
67
|
+
# element_deprecation_notices:
|
68
|
+
# old_element: Foo baz widget is deprecated
|
69
|
+
#
|
70
|
+
# or use the global translation that apply to all deprecated elements.
|
71
|
+
#
|
72
|
+
# en:
|
73
|
+
# alchemy:
|
74
|
+
# element_deprecation_notice: Foo baz widget is deprecated
|
75
|
+
#
|
76
|
+
# or pass string as deprecation notice.
|
77
|
+
#
|
78
|
+
# - name: old_element
|
79
|
+
# deprecated: This element will be removed soon.
|
80
|
+
#
|
81
|
+
def deprecation_notice
|
82
|
+
case definition["deprecated"]
|
83
|
+
when String
|
84
|
+
definition["deprecated"]
|
85
|
+
when TrueClass
|
86
|
+
Alchemy.t(name,
|
87
|
+
scope: :element_deprecation_notices,
|
88
|
+
default: Alchemy.t(:element_deprecated))
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def find_or_create_content(name)
|
95
|
+
find_content(name) || create_content(name)
|
96
|
+
end
|
97
|
+
|
98
|
+
def find_content(name)
|
99
|
+
element.contents.find { |content| content.name == name }
|
100
|
+
end
|
101
|
+
|
102
|
+
def create_content(name)
|
103
|
+
Alchemy::Content.create(element: element, name: name)
|
104
|
+
end
|
39
105
|
end
|
40
106
|
end
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<div id="element_<%= element.id %>_errors" class="element_errors"></div>
|
26
26
|
|
27
27
|
<div id="element_<%= element.id %>_content" class="element-content-editors">
|
28
|
-
<%= render element.contents
|
28
|
+
<%= render element.contents %>
|
29
29
|
</div>
|
30
30
|
|
31
31
|
<% if element.taggable? %>
|
data/lib/alchemy/resource.rb
CHANGED
@@ -132,7 +132,9 @@ module Alchemy
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def namespaced_resource_name
|
135
|
-
@_namespaced_resource_name ||=
|
135
|
+
@_namespaced_resource_name ||= begin
|
136
|
+
namespaced_resources_name.to_s.singularize
|
137
|
+
end.to_sym # Rails >= 6.0.3.7 needs symbols in polymorphic routes
|
136
138
|
end
|
137
139
|
|
138
140
|
def namespaced_resources_name
|
@@ -140,13 +142,13 @@ module Alchemy
|
|
140
142
|
resource_name_array = resource_array.dup
|
141
143
|
resource_name_array.delete(engine_name) if in_engine?
|
142
144
|
resource_name_array.join("_")
|
143
|
-
end
|
145
|
+
end.to_sym # Rails >= 6.0.3.7 needs symbols in polymorphic routes
|
144
146
|
end
|
145
147
|
|
146
148
|
def namespace_for_scope
|
147
149
|
namespace_array = namespace_diff
|
148
150
|
namespace_array.delete(engine_name) if in_engine?
|
149
|
-
namespace_array
|
151
|
+
namespace_array.map(&:to_sym) # Rails >= 6.0.3.7 needs symbols in polymorphic routes
|
150
152
|
end
|
151
153
|
|
152
154
|
# Returns an array of underscored association names
|
data/lib/alchemy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.
|
4
|
+
version: 5.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas von Deyen
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2021-
|
16
|
+
date: 2021-05-06 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: active_model_serializers
|