summaryrefslogtreecommitdiff
path: root/app/views/nodes/show.html.erb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-13 04:54:33 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-13 04:54:33 +0200
commit8baac265059b70da0148487458ee4077b15f155e (patch)
treeb97b07a76bec2fef602fa01c1739a89a412d812f /app/views/nodes/show.html.erb
parentb138f40a6493f7c4341fba196c48440e795babb9 (diff)
Asset picker: attach/detach/reorder UI, read-only view, autosave fix
Replaces nodes#edit's old Images section -- a hidden panel dumping every image asset in the system unfiltered (#image_browser) plus a raw drag-and-drop box (#image_box) -- with a small search-and-click picker built on the endpoint from the last two commits. Attaching posts immediately and appends the new thumbnail via a cloned <template> -- icons only render correctly through the Rails helper server-side, so the template holds real, pre-rendered markup for JS to clone rather than duplicating raw SVG in a JS string. Reordering is jQuery UI sortable on the small attached list only, with a dedicated drag handle rather than the whole thumbnail. Two bugs caught while click-testing, fixed here rather than shipped and patched after: the search panel never closed after attaching an image, since the success handler re-triggered focus to keep it open for attaching several in a row -- which meant it just re-populated itself forever instead of signaling "done." Fixed to close explicitly; a click-outside-closes handler was added alongside it, matching the affordance the top-bar search already has. A real, independent, pre-existing data bug surfaced during the same testing: Node#autosave!'s first-time-creation branch never carried related assets forward from whatever page was previously current -- attach an image, let autosave fire once, and it silently landed on a fresh, assetless Page row. Long-dormant, not introduced by this work, just finally exercised by something that made it visible. Fixed inside the `unless self.autosave` guard specifically -- running this on every call, not just creation, would overwrite anything attached directly to an existing autosave in between, a worse bug than the one being fixed. nodes#show gains a read-only Images section, rendered only when a page actually has attached images, so an attachment can be confirmed present without entering the edit/lock cycle -- useful on its own, and specifically useful the next time an asset bug needs investigating. Its thumbnail CSS is shared with the edit view's picker via a class (.thumbnail_list) rather than duplicated under a second name.
Diffstat (limited to 'app/views/nodes/show.html.erb')
-rw-r--r--app/views/nodes/show.html.erb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb
index 280e4928..8ea03cdc 100644
--- a/app/views/nodes/show.html.erb
+++ b/app/views/nodes/show.html.erb
@@ -152,6 +152,17 @@
152 <div class="node_description">Tags</div> 152 <div class="node_description">Tags</div>
153 <div class="node_content node_info_group"><%= @page.tag_list %></div> 153 <div class="node_content node_info_group"><%= @page.tag_list %></div>
154 154
155 <% if @page.assets.images.any? %>
156 <div class="node_description">Images</div>
157 <div class="node_content node_info_group">
158 <ul class="thumbnail_list">
159 <% @page.assets.images.each do |asset| %>
160 <li><%= link_to image_tag(asset.upload.url(:thumb)), asset_path(asset) %></li>
161 <% end %>
162 </ul>
163 </div>
164 <% end %>
165
155 <div class="node_description">Events</div> 166 <div class="node_description">Events</div>
156 <div class="node_content node_info_group"> 167 <div class="node_content node_info_group">
157 <ul> 168 <ul>