-
-
Notifications
You must be signed in to change notification settings - Fork 315
/
Copy path_element.html.erb
79 lines (68 loc) · 2.99 KB
/
_element.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<%= content_tag :div,
id: "element_#{element.id}",
data: {'element-id' => element.id, 'element-name' => element.name},
class: element.css_classes do %>
<% unless element.fixed? %>
<%= render 'alchemy/admin/elements/element_header', element: element %>
<% end %>
<% if element.expanded? || element.fixed? %>
<%= render 'alchemy/admin/elements/element_toolbar', element: element %>
<% element.definition[:message].tap do |message| %>
<%= render_message(:info, sanitize(message)) if message %>
<% end %>
<% element.definition[:warning].tap do |warning| %>
<%= render_message(:warning, sanitize(warning)) if warning %>
<% end %>
<% if element.editable? %>
<%= form_for [alchemy, :admin, element], remote: true,
html: {id: "element_#{element.id}_form".html_safe, class: 'element-content'} do |f| %>
<div id="element_<%= element.id %>_errors" class="element_errors"></div>
<div id="element_<%= element.id %>_content" class="element-content-editors">
<%= render element.contents.map { |content| Alchemy::ContentEditor.new(content) } %>
</div>
<% if element.taggable? %>
<div class="autocomplete_tag_list">
<%= f.label :tag_list %>
<%= render 'alchemy/admin/partials/autocomplete_tag_list', f: f %>
</div>
<% end %>
<% end %>
<%= render 'alchemy/admin/elements/element_footer', element: element %>
<% end %>
<% end %>
<% if element.nestable_elements.any? %>
<div class="nestable-elements">
<%= content_tag :div,
class: "nested-elements", data: {
'droppable-elements' => element.nestable_elements.join(' ')
} do %>
<%= render element.all_nested_elements.map { |element|
Alchemy::ElementEditor.new(element)
} %>
<% end %>
<% if element.expanded? || element.fixed? %>
<% if element.nestable_elements.length == 1 %>
<% nestable_element = element.nestable_elements.first %>
<%= form_for [:admin, Alchemy::Element.new(name: nestable_element)],
remote: true, html: { class: 'add-nested-element-form', id: nil } do |f| %>
<%= f.hidden_field :name %>
<%= f.hidden_field :page_id, value: element.page_id %>
<%= f.hidden_field :parent_element_id, value: element.id %>
<button class="button add-nestable-element-button" data-alchemy-button>
<%= Alchemy.t(:add_nested_element) % { name: Alchemy.t(nestable_element, scope: 'element_names') } %>
</button>
<% end %>
<% else %>
<%= link_to_dialog Alchemy.t("New Element"),
alchemy.new_admin_element_path(
parent_element_id: element.id,
page_id: element.page.id
), {
size: "320x125",
title: Alchemy.t("New Element")
}, class: "button add-nestable-element-button" %>
<% end %>
<% end %>
</div>
<% end %>
<% end %>