diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-13 04:54:33 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-13 04:54:33 +0200 |
| commit | 8baac265059b70da0148487458ee4077b15f155e (patch) | |
| tree | b97b07a76bec2fef602fa01c1739a89a412d812f /public/stylesheets/admin.css | |
| parent | b138f40a6493f7c4341fba196c48440e795babb9 (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 'public/stylesheets/admin.css')
| -rw-r--r-- | public/stylesheets/admin.css | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index a58a061..c3c0cb4 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css | |||
| @@ -1210,3 +1210,78 @@ div#image_browser { | |||
| 1210 | div#image_browser ul li { | 1210 | div#image_browser ul li { |
| 1211 | list-style-type: none; | 1211 | list-style-type: none; |
| 1212 | } | 1212 | } |
| 1213 | |||
| 1214 | .thumbnail_list { | ||
| 1215 | display: flex; | ||
| 1216 | flex-wrap: wrap; | ||
| 1217 | gap: 0.75rem; | ||
| 1218 | list-style: none; | ||
| 1219 | margin: 0 0 0.75rem; | ||
| 1220 | padding: 0; | ||
| 1221 | } | ||
| 1222 | |||
| 1223 | .thumbnail_list li { | ||
| 1224 | position: relative; | ||
| 1225 | display: flex; | ||
| 1226 | align-items: center; | ||
| 1227 | gap: 0.25rem; | ||
| 1228 | border: 1px solid #e8e8e8; | ||
| 1229 | border-radius: 6px; | ||
| 1230 | padding: 4px; | ||
| 1231 | } | ||
| 1232 | |||
| 1233 | .thumbnail_list img { | ||
| 1234 | display: block; | ||
| 1235 | width: 60px; | ||
| 1236 | height: 60px; | ||
| 1237 | object-fit: cover; | ||
| 1238 | border-radius: 4px; | ||
| 1239 | } | ||
| 1240 | |||
| 1241 | .related_asset_handle { | ||
| 1242 | display: flex; | ||
| 1243 | color: #969696; | ||
| 1244 | cursor: grab; | ||
| 1245 | } | ||
| 1246 | |||
| 1247 | .related_asset_handle svg { | ||
| 1248 | width: 1rem; | ||
| 1249 | height: 1rem; | ||
| 1250 | } | ||
| 1251 | |||
| 1252 | .related_asset_remove { | ||
| 1253 | display: flex; | ||
| 1254 | align-items: center; | ||
| 1255 | justify-content: center; | ||
| 1256 | background: none; | ||
| 1257 | border: none; | ||
| 1258 | padding: 2px; | ||
| 1259 | cursor: pointer; | ||
| 1260 | color: #969696; | ||
| 1261 | } | ||
| 1262 | |||
| 1263 | .related_asset_remove svg { | ||
| 1264 | width: 0.9rem; | ||
| 1265 | height: 0.9rem; | ||
| 1266 | } | ||
| 1267 | |||
| 1268 | .related_asset_remove:hover { | ||
| 1269 | color: #cc0000; | ||
| 1270 | } | ||
| 1271 | |||
| 1272 | .related_asset_result { | ||
| 1273 | display: flex; | ||
| 1274 | align-items: center; | ||
| 1275 | gap: 0.5rem; | ||
| 1276 | padding: 4px; | ||
| 1277 | border-bottom: 1px solid #e8e8e8; | ||
| 1278 | text-decoration: none; | ||
| 1279 | } | ||
| 1280 | |||
| 1281 | .related_asset_result img { | ||
| 1282 | width: 40px; | ||
| 1283 | height: 40px; | ||
| 1284 | object-fit: cover; | ||
| 1285 | border-radius: 4px; | ||
| 1286 | } | ||
| 1287 | |||
