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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
<h1><%= title_for_node(@node) %></h1>
<div class="node_action_bar">
<%= button_to 'Unlock + Back', unlock_node_path(@node), method: :put,
form: { class: 'button_to state_changing' },
disabled: @node.autosave.present? %>
<% if @node.autosave || (@node.draft && @node.head) %>
<%= button_to revert_node_path(@node), method: :put,
form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } do %>
<%= icon("trash", library: "tabler", "aria-hidden": true) %>
<%= @node.draft && !@node.autosave ? "Destroy Draft" : "Discard Autosave" %>
<% end %>
<% if pair = @node.available_layer_pairs.find { |p| p.include?(:autosave) } %>
<%= button_to 'What changed?',
diff_node_revisions_path(@node),
method: :get,
params: { start_revision: pair.first, end_revision: pair.last },
form: { class: 'button_to computation' } %>
<% end %>
<% end %>
<%= submit_tag "Save Draft", form: dom_id(@node, :edit) %>
<%= submit_tag "Save + Unlock + Exit", form: dom_id(@node, :edit) %>
<%= link_to "Preview ↗", preview_page_path(@page), target: "_blank", rel: "noopener", class: "preview_link" %>
</div>
<div id="page_editor">
<%= form_for(@node, html: { data: { autosave_url: autosave_node_path(@node), show_url: node_path(@node) } }) do |f| %>
<% if @node.errors.any? %>
<div class="error_messages">
<ul><% @node.errors.full_messages.each do |msg| %><li><%= msg %></li><% end %></ul>
</div>
<% end %>
<%= fields_for @page do |d| %>
<div id="edit_grid">
<div id="main_fields">
<div class="node_description">Title</div>
<div class="node_content"><%= d.text_field :title %></div>
<div class="node_description">Abstract</div>
<div class="node_content"><%= d.text_area :abstract %></div>
<div class="node_description">Attachments</div>
<div class="node_content">
<div id="related_assets"
data-search-url="<%= search_node_related_assets_path(@node) %>"
data-create-url="<%= node_related_assets_path(@node) %>">
<ul id="related_asset_list" class="thumbnail_list">
<% @page.related_assets.includes(:asset).each do |related| %>
<li data-url="<%= node_related_asset_path(@node, related) %>"
data-asset-id="<%= related.asset.id %>"
data-large-url="<%= related.asset.upload.url(:large) %>"
data-original-url="<%= related.asset.upload.url %>"
data-name="<%= related.asset.name %>"
data-has-credit="<%= related.asset.show_credit? %>"
data-headline="<%= related.headline? %>"
class="<%= "is_headline" if related.headline? %>">
<span class="related_asset_handle"><%= icon("grip-vertical", library: "tabler", "aria-hidden": true) %></span>
<%= image_tag related.asset.upload.url(:thumb) %>
<button type="button" class="related_asset_set_headline"
aria-pressed="<%= related.headline? %>" aria-label="Set as headline image"
title="Use this photo as the page's headline image">
<%= icon("star", library: "tabler", "aria-hidden": true) %>
</button>
<button type="button" class="related_asset_remove" aria-label="Remove image">
<%= icon("x", library: "tabler", "aria-hidden": true) %>
</button>
</li>
<% end %>
</ul>
<p class="field_hint">The starred image or PDF becomes this page's headline on the public site. If none is starred, visitors get a link to browse all attached images instead.</p>
<%= text_field_tag nil, nil, id: "related_asset_search_term", placeholder: "Search images to attach…", autocomplete: "off" %>
<div id="related_asset_search_results" class="search_results"></div>
</div>
</div>
<template id="related_asset_template">
<li>
<span class="related_asset_handle"><%= icon("grip-vertical", library: "tabler", "aria-hidden": true) %></span>
<img src="">
<button type="button" class="related_asset_set_headline" aria-pressed="false" aria-label="Set as headline image">
<%= icon("star", library: "tabler", "aria-hidden": true) %>
</button>
<button type="button" class="related_asset_remove" aria-label="Remove image">
<%= icon("x", library: "tabler", "aria-hidden": true) %>
</button>
</li>
</template>
</div>
<details id="metadata_details">
<summary>Metadata (slug, parent, tags, template, author, images)</summary>
<div id="metadata">
<div class="node_description">Slug</div>
<div class="node_content">
<%= f.text_field(
:staged_slug, :value => @node.staged_slug || @node.slug
)
%>
</div>
<div class="node_description">parent</div>
<div class="node_content">
<%= text_field_tag :move_to_search_term, @node.parent.title rescue "" %>
<p class="field_hint">Start typing to find a new parent for this node.</p>
<div id="move_to_search_results" class="search_results"></div>
<%= f.hidden_field(
:staged_parent_id,
:value => @node.staged_parent_id || @node.parent_id
)
%>
</div>
<div class="node_description">Tags</div>
<div class="node_content">
<%= text_field_tag :tag_list, @page.tag_list.join(', ') %>
<span class="field_hint">Comma separated.</span>
</div>
<div class="node_description">Publish at</div>
<div class="node_content"><%= d.datetime_select :published_at, :value => @page.published_at %></div>
<div class="node_description">Template</div>
<div class="node_content">
<%= d.select :template_name, custom_page_templates, {:prompt => 'Select Template'} %>
<span class="field_hint">Set automatically based on how this node was created - change it if needed.</span>
</div>
<div class="node_description">Author</div>
<div class="node_content">
<%= d.select :user_id, user_list,
:selected => @page.user_id || @node.draft&.user_id || @node.head&.user_id %>
</div>
</div>
</details>
<div id="content">
<div class="node_description">Body</div>
<div class="body_toolbar_row">
<button type="button" id="preview_toggle" class="view_toggle" aria-pressed="false" aria-label="Toggle live preview" title="Toggle live preview">
<%= icon("layout-sidebar-right", library: "tabler", "aria-hidden": true) %> <span>Live preview</span>
</button>
<button type="button" id="preview_force_render" class="view_toggle" style="display:none" aria-label="Force preview render" title="Force preview render">
<%= icon("refresh", library: "tabler", "aria-hidden": true) %> <span>Force refresh</span>
</button>
</div>
<div id="editor_and_preview">
<div class="preview_content">
<div class="node_content"><%= d.text_area :body, :class => 'with_editor' %></div>
</div>
<div id="preview_panel" style="display:none">
<iframe id="live_preview_iframe" title="Live preview" data-src="<%= preview_page_path(@page, :locale => I18n.default_locale) %>"></iframe>
</div>
</div>
</div>
</div>
<% end %>
<div class="node_action_bar">
<%= f.submit 'Save Draft' %>
<%= f.submit 'Save + Unlock + Exit' %>
</div>
<% end %>
</div>
|