From 6f4d8613458ffae85cb428f6c285a2db467d3fdb Mon Sep 17 00:00:00 2001 From: Justin Miller <16829344+jmilljr24@users.noreply.github.com> Date: Fri, 30 Jan 2026 09:21:21 -0500 Subject: [PATCH 1/5] set story attributes if story idea present --- app/controllers/stories_controller.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 79508449b..49468b4ef 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -33,8 +33,13 @@ def show end def new - @story = Story.new.decorate - @story = @story.decorate + if params[:story_idea_id].present? + idea = StoryIdea.find(params[:story_idea_id]) + @story = Story.new(set_story_attributes_from(idea)) + else + @story = Story.new + end + @story.decorate set_form_variables end @@ -108,4 +113,15 @@ def story_params :created_by_id, :updated_by_id, :story_idea_id, :spotlighted_facilitator_id ) end + + def set_story_attributes_from(idea) + { + rhino_body: idea.body, + project_id: idea.project.id, + workshop_id: idea.workshop_id, + external_workshop_title: idea.external_workshop_title, + windows_type_id: idea.windows_type_id, + youtube_url: idea.youtube_url + } + end end From 3170aa0cd699981e6f0dd2533c9f55f8a40b29a3 Mon Sep 17 00:00:00 2001 From: Justin Miller <16829344+jmilljr24@users.noreply.github.com> Date: Fri, 30 Jan 2026 10:46:41 -0500 Subject: [PATCH 2/5] update form and controller --- app/controllers/workshops_controller.rb | 4 ++-- app/views/workshop_ideas/_form.html.erb | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index fe3b200e6..f1afed1ff 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -67,8 +67,8 @@ def build_report end def new - if params[:workshop_idea_id].present? - @workshop_idea = WorkshopIdea.find(params[:workshop_idea_id]) + if params[:workshop_idea].present? + @workshop_idea = WorkshopIdea.find(params[:workshop_idea]) @workshop = WorkshopFromIdeaService.new(@workshop_idea, user: current_user).call else @workshop = Workshop.new(user: current_user) diff --git a/app/views/workshop_ideas/_form.html.erb b/app/views/workshop_ideas/_form.html.erb index 39c50c9eb..3a11f93d1 100644 --- a/app/views/workshop_ideas/_form.html.erb +++ b/app/views/workshop_ideas/_form.html.erb @@ -7,7 +7,11 @@ <%= tag.div class: "unpersisted_resource_asset_params" %> - <% if current_user.super_user && f.object.workshops.any? %> + <%= f.hidden_field :created_by_id, value: current_user&.id unless f.object.persisted? %> + <%= f.hidden_field :updated_by_id, value: current_user&.id %> + + <% promoted_to_workshop = f.object.workshops.any? %> + <% if promoted_to_workshop %>
This workshops idea has been promoted to a <% f.object.workshops.each do |workshop| %> @@ -16,11 +20,13 @@ <% end %> and should not be edited here.
+ <% elsif current_user.super_user? && f.object.persisted? %> +
+ <%= link_to "Promote to Workshop", new_workshop_path(workshop_idea: @workshop_idea), + class: "btn btn-secondary-outline", + data: { confirm: "Are you sure you want to promote this workshop idea to a workshop?" } %> +
<% end %> - - <%= f.hidden_field :created_by_id, value: current_user&.id unless f.object.persisted? %> - <%= f.hidden_field :updated_by_id, value: current_user&.id %> -
From 270988d3e94f1372ff203d79db2ccb547c9ccf1f Mon Sep 17 00:00:00 2001 From: Justin Miller <16829344+jmilljr24@users.noreply.github.com> Date: Fri, 30 Jan 2026 11:45:16 -0500 Subject: [PATCH 3/5] handle promoting assest in workshop idea --- app/controllers/workshops_controller.rb | 10 ++-- app/models/workshop.rb | 10 ++++ app/services/workshop_from_idea_service.rb | 57 +++++++++++++--------- app/views/workshop_ideas/_form.html.erb | 2 +- app/views/workshops/_form.html.erb | 16 ++++++ 5 files changed, 67 insertions(+), 28 deletions(-) diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index f1afed1ff..4c5e6df4b 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -67,8 +67,8 @@ def build_report end def new - if params[:workshop_idea].present? - @workshop_idea = WorkshopIdea.find(params[:workshop_idea]) + if params[:workshop_idea_id].present? + @workshop_idea = WorkshopIdea.find(params[:workshop_idea_id]) @workshop = WorkshopFromIdeaService.new(@workshop_idea, user: current_user).call else @workshop = Workshop.new(user: current_user) @@ -83,7 +83,9 @@ def create Workshop.transaction do if @workshop.save assign_associations(@workshop) - if params.dig(:library_asset, :new_assets).present? + if params[:promote_idea_assets] == true + @workshop.attach_assets_from_idea! + elsif params.dig(:library_asset, :new_assets).present? update_asset_owner(@workshop) end success = true @@ -298,7 +300,7 @@ def workshop_params sector_ids: [], workshop_series_children_attributes: [ :id, :workshop_child_id, :workshop_parent_id, :theme_name, :series_description, :series_description_spanish, - :position, :_destroy ], + :position, :_destroy ] ) end diff --git a/app/models/workshop.rb b/app/models/workshop.rb index b25ca7708..1fc83de25 100644 --- a/app/models/workshop.rb +++ b/app/models/workshop.rb @@ -291,6 +291,16 @@ def featured_or_visitor_featured_changed? featured_changed? || visitor_featured_changed? || inactive_changed? end + def attach_assets_from_idea! + return unless workshop_idea + + workshop_idea.assets.find_each do |asset| + new_asset = assets.build(type: asset.type) + new_asset.file.attach(asset.file.blob) + end + + save! + end private diff --git a/app/services/workshop_from_idea_service.rb b/app/services/workshop_from_idea_service.rb index 04d68b1c4..e78b0597a 100644 --- a/app/services/workshop_from_idea_service.rb +++ b/app/services/workshop_from_idea_service.rb @@ -9,7 +9,6 @@ def initialize(workshop_idea, user:) def call Workshop.new(attributes_from_idea).tap do |workshop| duplicate_series_children(workshop) - duplicate_assets(workshop) end end @@ -19,26 +18,44 @@ def call def attributes_from_idea workshop_idea.attributes.slice( - "title", "objective", "objective_spanish", - "materials", "materials_spanish", - "optional_materials", "optional_materials_spanish", - "setup", "setup_spanish", - "introduction", "introduction_spanish", - "demonstration", "demonstration_spanish", - "warm_up", "warm_up_spanish", - "creation", "creation_spanish", - "closing", "closing_spanish", - "opening_circle", "opening_circle_spanish", - "notes", "notes_spanish", - "tips", "tips_spanish", - "windows_type_id", "age_range", "age_range_spanish", - "visualization", "visualization_spanish", - "extra_field", "extra_field_spanish", - "misc1", "misc1_spanish", "misc2", "misc2_spanish", + "title", "windows_type_id", "age_range", "time_intro", "time_closing", "time_creation", "time_demonstration", "time_warm_up", "time_opening", "time_opening_circle" ).merge( + rhino_objective: workshop_idea.rhino_objective, + rhino_materials: workshop_idea.rhino_materials, + rhino_optional_materials: workshop_idea.rhino_optional_materials, + rhino_setup: workshop_idea.rhino_setup, + rhino_introduction: workshop_idea.rhino_introduction, + rhino_demonstration: workshop_idea.rhino_demonstration, + rhino_warm_up: workshop_idea.rhino_warm_up, + rhino_creation: workshop_idea.rhino_creation, + rhino_closing: workshop_idea.rhino_closing, + rhino_opening_circle: workshop_idea.rhino_opening_circle, + rhino_notes: workshop_idea.rhino_notes, + rhino_tips: workshop_idea.rhino_tips, + rhino_visualization: workshop_idea.rhino_visualization, + rhino_extra_field: workshop_idea.rhino_extra_field, + rhino_misc1: workshop_idea.rhino_misc1, + rhino_misc2: workshop_idea.rhino_misc2, + rhino_objective_spanish: workshop_idea.rhino_objective_spanish, + rhino_materials_spanish: workshop_idea.rhino_materials_spanish, + rhino_optional_materials_spanish: workshop_idea.rhino_optional_materials_spanish, + rhino_age_range_spanish: workshop_idea.rhino_age_range_spanish, + rhino_setup_spanish: workshop_idea.rhino_setup_spanish, + rhino_introduction_spanish: workshop_idea.rhino_introduction_spanish, + rhino_opening_circle_spanish: workshop_idea.rhino_opening_circle_spanish, + rhino_demonstration_spanish: workshop_idea.rhino_demonstration_spanish, + rhino_warm_up_spanish: workshop_idea.rhino_warm_up_spanish, + rhino_visualization_spanish: workshop_idea.rhino_visualization_spanish, + rhino_creation_spanish: workshop_idea.rhino_creation_spanish, + rhino_closing_spanish: workshop_idea.rhino_closing_spanish, + rhino_notes_spanish: workshop_idea.rhino_notes_spanish, + rhino_tips_spanish: workshop_idea.rhino_tips_spanish, + rhino_misc1_spanish: workshop_idea.rhino_misc1_spanish, + rhino_misc2_spanish: workshop_idea.rhino_misc2_spanish, + rhino_extra_field_spanish: workshop_idea.rhino_extra_field_spanish, user_id: user.id, workshop_idea_id: workshop_idea.id, month: workshop_idea.created_at.month, @@ -61,10 +78,4 @@ def duplicate_series_children(workshop) end ) end - - def duplicate_assets(workshop) - workshop_idea.assets.each do |image| - workshop.assets.build(file: image.file.blob) - end - end end diff --git a/app/views/workshop_ideas/_form.html.erb b/app/views/workshop_ideas/_form.html.erb index 3a11f93d1..71b3f3e17 100644 --- a/app/views/workshop_ideas/_form.html.erb +++ b/app/views/workshop_ideas/_form.html.erb @@ -22,7 +22,7 @@
<% elsif current_user.super_user? && f.object.persisted? %>
- <%= link_to "Promote to Workshop", new_workshop_path(workshop_idea: @workshop_idea), + <%= link_to "Promote to Workshop", new_workshop_path(workshop_idea_id: @workshop_idea.id), class: "btn btn-secondary-outline", data: { confirm: "Are you sure you want to promote this workshop idea to a workshop?" } %>
diff --git a/app/views/workshops/_form.html.erb b/app/views/workshops/_form.html.erb index ec3a4c133..82d3ac912 100644 --- a/app/views/workshops/_form.html.erb +++ b/app/views/workshops/_form.html.erb @@ -431,6 +431,22 @@ <%= f.submit "Submit", class: "btn btn-primary" %>
+ + <% if @workshop_idea %> +
+ <%= label_tag :promote_idea_assets do %> + <%= check_box_tag :promote_idea_assets, true %> + + + If the workshop idea was submitted with attachments, check this box to transfer them to this new workshop. + + +

+ (This will override any attachment uploaded in the form below.) +

+ <% end %> +
+ <% end %> <% end %> From 6cb02e513ae9bcaad933614fde58d8321511cc3f Mon Sep 17 00:00:00 2001 From: Justin Miller <16829344+jmilljr24@users.noreply.github.com> Date: Fri, 30 Jan 2026 12:03:49 -0500 Subject: [PATCH 4/5] add tailwind styles to form --- app/controllers/workshop_ideas_controller.rb | 2 +- app/controllers/workshops_controller.rb | 2 +- app/views/workshop_ideas/_form.html.erb | 2 +- app/views/workshops/_form.html.erb | 20 +++++++++++--------- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/controllers/workshop_ideas_controller.rb b/app/controllers/workshop_ideas_controller.rb index 6e899a1f9..820209068 100644 --- a/app/controllers/workshop_ideas_controller.rb +++ b/app/controllers/workshop_ideas_controller.rb @@ -29,7 +29,7 @@ def create notification_type: 0) if params.dig(:library_asset, :new_assets).present? - update_asset_owner(@workshop) + update_asset_owner(@workshop_idea) end redirect_to workshop_ideas_path, notice: "Workshop idea was successfully created." diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index 4c5e6df4b..d4947a693 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -83,7 +83,7 @@ def create Workshop.transaction do if @workshop.save assign_associations(@workshop) - if params[:promote_idea_assets] == true + if params[:promote_idea_assets] == "true" @workshop.attach_assets_from_idea! elsif params.dig(:library_asset, :new_assets).present? update_asset_owner(@workshop) diff --git a/app/views/workshop_ideas/_form.html.erb b/app/views/workshop_ideas/_form.html.erb index 71b3f3e17..c22e82d40 100644 --- a/app/views/workshop_ideas/_form.html.erb +++ b/app/views/workshop_ideas/_form.html.erb @@ -24,7 +24,7 @@
<%= link_to "Promote to Workshop", new_workshop_path(workshop_idea_id: @workshop_idea.id), class: "btn btn-secondary-outline", - data: { confirm: "Are you sure you want to promote this workshop idea to a workshop?" } %> + data: { confirm: "All edits must be saved before promoting. Are you sure you wish to promote?" } %>
<% end %> diff --git a/app/views/workshops/_form.html.erb b/app/views/workshops/_form.html.erb index 82d3ac912..559cf8ee3 100644 --- a/app/views/workshops/_form.html.erb +++ b/app/views/workshops/_form.html.erb @@ -433,17 +433,19 @@ <% if @workshop_idea %> -
- <%= label_tag :promote_idea_assets do %> - <%= check_box_tag :promote_idea_assets, true %> +
+ <%= label_tag :promote_idea_assets, class: "flex items-start space-x-3 cursor-pointer" do %> + <%= check_box_tag :promote_idea_assets, true, false, class: "mt-1 h-5 w-5 text-blue-600 rounded border-gray-300 focus:ring-blue-500" %> - - If the workshop idea was submitted with attachments, check this box to transfer them to this new workshop. - +
+ + If the workshop idea was submitted with attachments, check this box to transfer them to this new workshop. + -

- (This will override any attachment uploaded in the form below.) -

+

+ (This will override any attachments uploaded in the form below once you click submit.) +

+
<% end %>
<% end %> From bd6bfcf5e4534d79397e3b925d703bf267af4f56 Mon Sep 17 00:00:00 2001 From: Justin Miller <16829344+jmilljr24@users.noreply.github.com> Date: Fri, 30 Jan 2026 12:18:37 -0500 Subject: [PATCH 5/5] add asset promotion to story ideas --- app/controllers/stories_controller.rb | 8 +++++--- app/models/story.rb | 10 ++++++++++ app/views/stories/_form.html.erb | 18 ++++++++++++++++++ app/views/workshop_ideas/_form.html.erb | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 49468b4ef..0f37da84f 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -34,8 +34,8 @@ def show def new if params[:story_idea_id].present? - idea = StoryIdea.find(params[:story_idea_id]) - @story = Story.new(set_story_attributes_from(idea)) + @story_idea = StoryIdea.find(params[:story_idea_id]) + @story = Story.new(set_story_attributes_from(@story_idea)) else @story = Story.new end @@ -57,7 +57,9 @@ def create @story = Story.new(story_params) if @story.save - if params.dig(:library_asset, :new_assets).present? + if params[:promote_idea_assets] == "true" + @story.attach_assets_from_idea! + elsif params.dig(:library_asset, :new_assets).present? update_asset_owner(@story) end diff --git a/app/models/story.rb b/app/models/story.rb index 72bfc07af..b7fde0746 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -83,4 +83,14 @@ def organization_locality def organization_description project&.organization_description end + + def attach_assets_from_idea! + return unless story_idea + story_idea.assets.find_each do |asset| + new_asset = assets.build(type: asset.type) + new_asset.file.attach(asset.file.blob) + end + + save! + end end diff --git a/app/views/stories/_form.html.erb b/app/views/stories/_form.html.erb index 419178496..fb42e9371 100644 --- a/app/views/stories/_form.html.erb +++ b/app/views/stories/_form.html.erb @@ -125,6 +125,24 @@ <%= f.button :submit, class: "btn btn-primary" %>
+ + <% if story_idea %> +
+ <%= label_tag :promote_idea_assets, class: "flex items-start space-x-3 cursor-pointer" do %> + <%= check_box_tag :promote_idea_assets, true, false, class: "mt-1 h-5 w-5 text-blue-600 rounded border-gray-300 focus:ring-blue-500" %> + +
+ + If the story idea was submitted with attachments, check this box to transfer them to this new story. + + +

+ (This will override any attachments uploaded in the form below once you click submit.) +

+
+ <% end %> +
+ <% end %> <% end %>
<%= render "assets/form", owner: @story %>
diff --git a/app/views/workshop_ideas/_form.html.erb b/app/views/workshop_ideas/_form.html.erb index c22e82d40..14a465c89 100644 --- a/app/views/workshop_ideas/_form.html.erb +++ b/app/views/workshop_ideas/_form.html.erb @@ -24,7 +24,7 @@
<%= link_to "Promote to Workshop", new_workshop_path(workshop_idea_id: @workshop_idea.id), class: "btn btn-secondary-outline", - data: { confirm: "All edits must be saved before promoting. Are you sure you wish to promote?" } %> + data: { confirm: "All edits must be saved before promoting. Are you sure you wish to promote?All edits must be saved before promoting." } %>
<% end %>