From 20c735b0c5a2db9b8984848253ad99332d6211a8 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sun, 9 Aug 2026 03:33:55 +0200 Subject: Attach assets to the draft instead of to every lifecycle row Node#attach_asset! writes to the node's draft alone, creating one from the head when none is pending. It refuses when another user holds the lock, and when an autosave already exists The asset_attach verb goes with it. create_new_draft names the editor on the draft it creates and the publish entry's asset delta reports the attachment. --- app/controllers/assets_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index f8a7d1e4..d86370f4 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -111,8 +111,10 @@ class AssetsController < ApplicationController flash[:notice] = if result[:attached].zero? t("flash.assets.already_attached", :title => node.title) + elsif result[:draft_created] + t("flash.assets.attached_new_draft", :title => node.title) else - t("flash.assets.attached", :title => node.title) + t("flash.assets.attached_to_draft", :title => node.title) end case result[:headline] when :set then flash[:notice] += " " + t("flash.common.now_headline") @@ -122,5 +124,8 @@ class AssetsController < ApplicationController rescue LockedByAnotherUser flash[:locked_by] = node.lock_owner&.login flash[:locked_node_path] = node_path(node) + rescue ActiveRecord::RecordInvalid => e + flash[:error] = e.record.errors.full_messages.to_sentence + flash[:resolve_node_path] = node_path(node) end end -- cgit v1.3