summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-13 03:22:37 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-13 03:22:37 +0200
commit70653b681d10917b77dced08f577446ced7568f1 (patch)
tree3c92383e29da79beb3e1419c153952a4aa7dc1ab /config
parent65c7c40f74c315c1a39fb15da8ce341fb8b9b05e (diff)
Add RelatedAssetsController: search, attach, detach, reorder
Backend for the asset-picker rebuild -- replaces the plan to dump every image asset in the system into a hidden, unfiltered browse panel on every node edit (the actual current behavior, confirmed by reading nodes/edit.html.erb directly) with a small, name-scoped search endpoint plus create/destroy/update for attach, detach, and reorder. No schema change needed -- RelatedAsset already had everything this requires (asset_id, page_id, an acts_as_list position). search excludes assets already attached to the page, keeping results meaningfully small given hundreds of assets total but only a handful per node in practice. create is find_or_create_by! rather than a bare create!, guarding against the same asset being attached twice from two separate search results. update leans on acts_as_list's own insert_at rather than custom position-shifting logic. Node#editable_page (autosave || draft || head) is extracted since this is now its third call site with identical logic -- deliberately not touching nodes#show, which resolves draft || head without autosave on purpose, a different and correct semantic for "current committed state" versus "what's actively being edited."
Diffstat (limited to 'config')
-rw-r--r--config/routes.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/config/routes.rb b/config/routes.rb
index 92301e5..5d61bae 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -55,6 +55,12 @@ Cccms::Application.routes.draw do
55 put :revert 55 put :revert
56 end 56 end
57 57
58 resources :related_assets, only: [:create, :destroy, :update] do
59 collection do
60 get :search
61 end
62 end
63
58 resources :revisions do 64 resources :revisions do
59 collection do 65 collection do
60 post :diff 66 post :diff