From 8b6d3c76451d4ece5fd829d0e2d96a00aa19122d Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 22 Jul 2026 20:44:34 +0200 Subject: Add attached nodes subsection in assets#show and thumbnail in nodes#create --- app/controllers/nodes_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 87d2681..ce8f053 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -30,6 +30,7 @@ class NodesController < ApplicationController @node = Node.new node_params @selected_kind = CccConventions::NODE_KINDS.key?(params[:kind]) ? params[:kind] : "generic" @parent = Node.find(params[:parent_id]) if params.has_key?(:parent_id) + @attach_asset = Asset.find(params[:asset_id]) if params.has_key?(:asset_id) end def create @@ -51,10 +52,19 @@ class NodesController < ApplicationController :action => "create", :title => params[:title], :path => @node.unique_name) + if params[:asset_id].present? && (asset = Asset.find(params[:asset_id])) + result = @node.attach_asset!(asset, :user => current_user, + :headline => params[:asset_headline].present?) + flash[:notice] = "Page created with “#{asset.name}” attached." + flash[:notice] += " It is the page's headline." if result[:headline] == :set + flash[:error] = "This asset type cannot be a headline." if result[:headline] == :not_eligible + end + redirect_to(edit_node_path(@node)) else @selected_kind = CccConventions::NODE_KINDS.key?(params[:kind]) ? params[:kind] : "generic" @parent = Node.find(params[:parent_id]) if params.has_key?(:parent_id) + @attach_asset = Asset.find(params[:asset_id]) if params.has_key?(:asset_id) render :new end end -- cgit v1.3