Class: Katalyst::Content::Editor::Item
- Inherits:
-
Base
- Object
- Base
- Katalyst::Content::Editor::Item
show all
- Defined in:
- app/helpers/katalyst/content/editor/item.rb
Constant Summary
Constants inherited
from Base
Base::CONTAINER_CONTROLLER, Base::ITEM_CONTROLLER, Base::LIST_CONTROLLER, Base::NEW_ITEM_CONTROLLER, Base::STATUS_BAR_CONTROLLER, Base::TURBO_FRAME
Instance Attribute Summary collapse
Attributes inherited from Base
#container, #template
Instance Method Summary
collapse
Methods inherited from Base
#attributes_scope, #container_form_id, #initialize
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
7
8
9
|
# File 'app/helpers/katalyst/content/editor/item.rb', line 7
def item
@item
end
|
Instance Method Details
#accordion_actions ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'app/helpers/katalyst/content/editor/item.rb', line 17
def accordion_actions
tag.div role: "toolbar", data: { tree_accordion_controls: "" } do
concat tag.span(role: "button", value: "collapse",
data: { action: "click->#{CONTAINER_CONTROLLER}#collapse", title: "Collapse tree" })
concat tag.span(role: "button", value: "expand",
data: { action: "click->#{CONTAINER_CONTROLLER}#expand", title: "Expand tree" })
end
end
|
#build(item, **options, &block) ⇒ Object
9
10
11
12
13
14
15
|
# File 'app/helpers/katalyst/content/editor/item.rb', line 9
def build(item, **options, &block)
self.item = item
tag.div **default_options(id: dom_id(item), **options) do
concat(capture { yield self }) if block
concat fields(item)
end
end
|
#edit_item_link ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'app/helpers/katalyst/content/editor/item.rb', line 40
def edit_item_link
if item.persisted?
katalyst_content.edit_item_path(item)
else
katalyst_content.new_item_path(item: item.attributes.slice("type", "container_id",
"container_type").compact)
end
end
|
#fields(item) ⇒ Object
49
50
51
52
53
54
55
|
# File 'app/helpers/katalyst/content/editor/item.rb', line 49
def fields(item)
template.fields(attributes_scope, model: item, index: nil, skip_default_ids: true) do |f|
concat f.hidden_field(:id)
concat f.hidden_field(:depth)
concat f.hidden_field(:index)
end
end
|
#item_actions ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/helpers/katalyst/content/editor/item.rb', line 26
def item_actions
tag.div role: "toolbar", data: { tree_controls: "" } do
concat tag.span(role: "button", value: "de-nest",
data: { action: "click->#{CONTAINER_CONTROLLER}#deNest", title: "Outdent" })
concat tag.span(role: "button", value: "nest",
data: { action: "click->#{CONTAINER_CONTROLLER}#nest", title: "Indent" })
concat link_to("", edit_item_link,
role: "button", title: "Edit", value: "edit",
data: { turbo_frame: TURBO_FRAME })
concat tag.span(role: "button", value: "remove",
data: { action: "click->#{CONTAINER_CONTROLLER}#remove", title: "Remove" })
end
end
|