katalyst-content 2.1.0 → 2.1.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8049155bd0d6a4679582aa45f971b9cf8cc6248504e55f460c25c116f1f6b577
|
4
|
+
data.tar.gz: 5c9e52f70eae3349e8fea0bf0e2cfaa117a4b2727b83e01456146423c6ed794b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a07c22615e56c8b55c84c01ce851162c91084130af068f22daff77c0614ed909f173e5b1eaefe8f3112e24c87a7d3ba9babfe12f2a7c667cdfc69dd12151768
|
7
|
+
data.tar.gz: 6206169b03510648758311e432dc8fd7b745688e4a96ac37d705614263816f9c61460277a535a7dfae438ca7908a024a5a8d3c18001fe5f643b1b0fab73f2c1e
|
@@ -25,6 +25,8 @@ module Katalyst
|
|
25
25
|
if item.save
|
26
26
|
render :update, locals: { editor:, item:, previous: @container.items.build(type: item.type) }
|
27
27
|
else
|
28
|
+
store_attachments(item)
|
29
|
+
|
28
30
|
render_editor status: :unprocessable_entity
|
29
31
|
end
|
30
32
|
end
|
@@ -38,6 +40,8 @@ module Katalyst
|
|
38
40
|
|
39
41
|
render locals: { editor:, item:, previous: }
|
40
42
|
else
|
43
|
+
store_attachments(item)
|
44
|
+
|
41
45
|
render_editor status: :unprocessable_entity
|
42
46
|
end
|
43
47
|
end
|
@@ -78,6 +82,24 @@ module Katalyst
|
|
78
82
|
def render_editor(**)
|
79
83
|
render(:edit, locals: { item_editor: editor.item_editor(item:) }, **)
|
80
84
|
end
|
85
|
+
|
86
|
+
# Ensure that any attachments are stored before the item is returned to
|
87
|
+
# the editor, so that uploads are not lost if the item is invalid.
|
88
|
+
#
|
89
|
+
# This mimics the behaviour of direct uploads without requiring the JS
|
90
|
+
# integration.
|
91
|
+
def store_attachments(item)
|
92
|
+
item.attachment_changes.each_value do |change|
|
93
|
+
case change
|
94
|
+
when ActiveStorage::Attached::Changes::CreateOne
|
95
|
+
change.upload
|
96
|
+
change.blob.save!
|
97
|
+
when ActiveStorage::Attached::Changes::CreateMany
|
98
|
+
change.upload
|
99
|
+
change.blobs.each(&:save!)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
81
103
|
end
|
82
104
|
end
|
83
105
|
end
|