katalyst-content 2.0.1 → 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/app/assets/stylesheets/katalyst/content/editor/_new-items.scss +0 -5
- data/app/components/katalyst/content/editor/base_component.rb +0 -2
- data/app/components/katalyst/content/editor/item_component.html.erb +1 -1
- data/app/components/katalyst/content/editor/item_component.rb +2 -0
- data/app/components/katalyst/content/editor/item_editor_component.rb +51 -0
- data/app/components/katalyst/content/editor/new_item_component.rb +2 -3
- data/app/components/katalyst/content/editor/new_items_component.html.erb +3 -5
- data/app/components/katalyst/content/editor_component.rb +4 -0
- data/app/controllers/katalyst/content/items_controller.rb +41 -9
- data/app/views/katalyst/content/figures/_figure.html+form.erb +5 -0
- data/app/views/katalyst/content/items/edit.html.erb +4 -3
- data/app/views/katalyst/content/items/edit.turbo_stream.erb +3 -0
- data/app/views/katalyst/content/items/update.turbo_stream.erb +1 -4
- data/lib/katalyst/content.rb +4 -0
- metadata +19 -4
- data/app/views/katalyst/content/items/new.html.erb +0 -4
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
|
@@ -12,8 +12,6 @@ module Katalyst
|
|
12
12
|
STATUS_BAR_CONTROLLER = "content--editor--status-bar"
|
13
13
|
NEW_ITEM_CONTROLLER = "content--editor--new-item"
|
14
14
|
|
15
|
-
TURBO_FRAME = "content--editor--item-frame"
|
16
|
-
|
17
15
|
attr_accessor :container, :item
|
18
16
|
|
19
17
|
delegate :config, to: ::Katalyst::Content
|
@@ -15,7 +15,7 @@
|
|
15
15
|
<div role="toolbar" data-tree-controls>
|
16
16
|
<span role="button" value="de-nest" data-action="click-><%= CONTAINER_CONTROLLER %>#deNest" title="Outdent"></span>
|
17
17
|
<span role="button" value="nest" data-action="click-><%= CONTAINER_CONTROLLER %>#nest" title="Indent"></span>
|
18
|
-
<%=
|
18
|
+
<%= kpop_link_to("", edit_item_link, role: "button", title: "Edit", value: "edit") %>
|
19
19
|
<span role="button" value="remove" data-action="click-><%= CONTAINER_CONTROLLER %>#remove" title="Remove"></span>
|
20
20
|
</div>
|
21
21
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Katalyst
|
4
|
+
module Content
|
5
|
+
module Editor
|
6
|
+
class ItemEditorComponent < BaseComponent
|
7
|
+
include ::Turbo::FramesHelper
|
8
|
+
|
9
|
+
module Helpers
|
10
|
+
def prefix_partial_path_with_controller_namespace
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def call
|
16
|
+
tag.div(**html_attributes) do
|
17
|
+
helpers.extend(Helpers)
|
18
|
+
helpers.render(item, path:)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def id
|
23
|
+
"item-editor-#{item.id}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def title
|
27
|
+
if item.persisted?
|
28
|
+
"Edit #{item.model_name.human.downcase}"
|
29
|
+
else
|
30
|
+
"New #{item.model_name.human.downcase}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def path
|
35
|
+
if item.persisted?
|
36
|
+
view_context.katalyst_content.item_path(item)
|
37
|
+
else
|
38
|
+
view_context.katalyst_content.items_path
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def default_html_attributes
|
43
|
+
{
|
44
|
+
id:,
|
45
|
+
class: "content--item-editor",
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
</div>
|
5
|
-
<% end %>
|
1
|
+
<div class="content--editor--new-items" role="listbox">
|
2
|
+
<%= render Katalyst::Content::Editor::NewItemComponent.with_collection(items) %>
|
3
|
+
</div>
|
@@ -7,23 +7,27 @@ module Katalyst
|
|
7
7
|
before_action :set_item, except: %i[new create]
|
8
8
|
before_action :set_editor_variant
|
9
9
|
|
10
|
+
attr_reader :container, :item, :editor
|
11
|
+
|
10
12
|
helper EditorHelper
|
11
13
|
|
14
|
+
layout nil
|
15
|
+
|
12
16
|
def new
|
13
|
-
|
17
|
+
render_editor
|
14
18
|
end
|
15
19
|
|
16
20
|
def edit
|
17
|
-
|
21
|
+
render_editor
|
18
22
|
end
|
19
23
|
|
20
24
|
def create
|
21
|
-
@item = item = @container.items.build(item_params)
|
22
25
|
if item.save
|
23
|
-
editor = Katalyst::Content::EditorComponent.new(container: @item.container, item: @item)
|
24
26
|
render :update, locals: { editor:, item:, previous: @container.items.build(type: item.type) }
|
25
27
|
else
|
26
|
-
|
28
|
+
store_attachments(item)
|
29
|
+
|
30
|
+
render_editor status: :unprocessable_entity
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
@@ -33,11 +37,12 @@ module Katalyst
|
|
33
37
|
if @item.valid?
|
34
38
|
previous = @item
|
35
39
|
@item = @item.dup.tap(&:save!)
|
36
|
-
editor = Katalyst::Content::EditorComponent.new(container: @item.container, item: @item)
|
37
40
|
|
38
|
-
render locals: { editor:, item
|
41
|
+
render locals: { editor:, item:, previous: }
|
39
42
|
else
|
40
|
-
|
43
|
+
store_attachments(item)
|
44
|
+
|
45
|
+
render_editor status: :unprocessable_entity
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
@@ -59,15 +64,42 @@ module Katalyst
|
|
59
64
|
def set_container
|
60
65
|
@container = Item.new(item_params).container
|
61
66
|
raise ActiveRecord::RecordNotFound unless @container
|
67
|
+
|
68
|
+
@item = @container.items.build(item_params)
|
69
|
+
@editor = Katalyst::Content::EditorComponent.new(container:, item:)
|
62
70
|
end
|
63
71
|
|
64
72
|
def set_item
|
65
|
-
@item
|
73
|
+
@item = Item.find(params[:id])
|
74
|
+
@container = @item.container
|
75
|
+
@editor = Katalyst::Content::EditorComponent.new(container:, item:)
|
66
76
|
end
|
67
77
|
|
68
78
|
def set_editor_variant
|
69
79
|
request.variant << :form
|
70
80
|
end
|
81
|
+
|
82
|
+
def render_editor(**)
|
83
|
+
render(:edit, locals: { item_editor: editor.item_editor(item:) }, **)
|
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
|
71
103
|
end
|
72
104
|
end
|
73
105
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
|
1
|
+
<%= render Kpop::FrameComponent.new do %>
|
2
|
+
<%= render Kpop::ModalComponent.new(title: item_editor.title) do %>
|
3
|
+
<%= render item_editor %>
|
4
|
+
<% end %>
|
4
5
|
<% end %>
|
data/lib/katalyst/content.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katalyst-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
|
- Katalyst Interactive
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_storage_validations
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: katalyst-kpop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: view_component
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,7 @@ files:
|
|
80
94
|
- app/components/katalyst/content/editor/errors_component.rb
|
81
95
|
- app/components/katalyst/content/editor/item_component.html.erb
|
82
96
|
- app/components/katalyst/content/editor/item_component.rb
|
97
|
+
- app/components/katalyst/content/editor/item_editor_component.rb
|
83
98
|
- app/components/katalyst/content/editor/new_item_component.html.erb
|
84
99
|
- app/components/katalyst/content/editor/new_item_component.rb
|
85
100
|
- app/components/katalyst/content/editor/new_items_component.html.erb
|
@@ -136,7 +151,7 @@ files:
|
|
136
151
|
- app/views/katalyst/content/items/_item.html+form.erb
|
137
152
|
- app/views/katalyst/content/items/_item.html.erb
|
138
153
|
- app/views/katalyst/content/items/edit.html.erb
|
139
|
-
- app/views/katalyst/content/items/
|
154
|
+
- app/views/katalyst/content/items/edit.turbo_stream.erb
|
140
155
|
- app/views/katalyst/content/items/update.turbo_stream.erb
|
141
156
|
- app/views/katalyst/content/sections/_section.html+form.erb
|
142
157
|
- app/views/katalyst/content/sections/_section.html.erb
|
@@ -171,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
186
|
- !ruby/object:Gem::Version
|
172
187
|
version: '0'
|
173
188
|
requirements: []
|
174
|
-
rubygems_version: 3.4.
|
189
|
+
rubygems_version: 3.4.10
|
175
190
|
signing_key:
|
176
191
|
specification_version: 4
|
177
192
|
summary: Rich content page builder and editor
|