katalyst-content 2.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8972c901b7463acaafc585438ac770f56a3636d6a82685bc875f20363b831089
|
4
|
+
data.tar.gz: 850d22ee22e8c82158fd655460c8e6eab91c6f03d13542392a18be38756b6543
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a11515dafad3e8c39c5fc1734d520612927c91ebdea98eeed913d1fdf4a5cbfbea8ecc993ae60175c068d89c4ac0f917f5918b05bfd5ca1ee2448c3fa734a2c
|
7
|
+
data.tar.gz: 41faa7d49f39de485e3372963ea472fd67e2a85b751d5021320705b3dbddccc6462fb75b78f5a57dfc733e5bc5d892f87cabd853c4ffb1773735d62afeb21ec4
|
@@ -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
|