From 619dcc171cc594cde3b341fe6cda6ef416e33540 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Tue, 12 Nov 2024 20:50:17 -0600 Subject: [PATCH] Use turbo frame for assignments --- .../{ => bubbles}/assignments_controller.rb | 10 +++++-- app/views/bubbles/_assignments.html.erb | 26 ----------------- app/views/bubbles/_bubble.html.erb | 2 +- app/views/bubbles/assignments/new.html.erb | 14 ++++++++++ app/views/bubbles/assignments/show.html.erb | 28 +++++++++++++++++++ app/views/bubbles/show.html.erb | 11 ++++++-- config/routes.rb | 2 +- 7 files changed, 61 insertions(+), 32 deletions(-) rename app/controllers/{ => bubbles}/assignments_controller.rb (63%) delete mode 100644 app/views/bubbles/_assignments.html.erb create mode 100644 app/views/bubbles/assignments/new.html.erb create mode 100644 app/views/bubbles/assignments/show.html.erb diff --git a/app/controllers/assignments_controller.rb b/app/controllers/bubbles/assignments_controller.rb similarity index 63% rename from app/controllers/assignments_controller.rb rename to app/controllers/bubbles/assignments_controller.rb index 05ce8a5b5..4ca0d7031 100644 --- a/app/controllers/assignments_controller.rb +++ b/app/controllers/bubbles/assignments_controller.rb @@ -1,9 +1,15 @@ -class AssignmentsController < ApplicationController +class Bubbles::AssignmentsController < ApplicationController include BubbleScoped, BucketScoped + def new + end + + def show + end + def create @bubble.assign(find_assignee) - redirect_to @bubble + render :show end private diff --git a/app/views/bubbles/_assignments.html.erb b/app/views/bubbles/_assignments.html.erb deleted file mode 100644 index 143c6fa07..000000000 --- a/app/views/bubbles/_assignments.html.erb +++ /dev/null @@ -1,26 +0,0 @@ - id="new-assignee" class="bubble__bubble bubble__meta bubble__assignee <%= "bubble__assignee--new" if bubble.assignees.none? %>"> - <%= form_with url: bucket_bubble_assignments_path(bubble.bucket, bubble), data: { controller: "form" } do |form| %> - - - <%= form.submit "Save", class: "btn", hidden: true %> - <% end %> - diff --git a/app/views/bubbles/_bubble.html.erb b/app/views/bubbles/_bubble.html.erb index 03ea60bf3..9cbffe4c1 100644 --- a/app/views/bubbles/_bubble.html.erb +++ b/app/views/bubbles/_bubble.html.erb @@ -16,7 +16,7 @@ <%= bubble.title %> <% end %> - <%= render "bubbles/assignments", bubble: bubble %> + <%= turbo_frame_tag dom_id(bubble, :assignments), src: bucket_bubble_assignments_path(bubble.bucket, bubble) %> <%= render "bubbles/boosts", bubble: bubble %> <%= render "bubbles/color", bubble: bubble %> <%= turbo_frame_tag dom_id(bubble, :date_picker), src: bucket_bubble_date_picker_path(bubble.bucket, bubble) %> diff --git a/app/views/bubbles/assignments/new.html.erb b/app/views/bubbles/assignments/new.html.erb new file mode 100644 index 000000000..60330a618 --- /dev/null +++ b/app/views/bubbles/assignments/new.html.erb @@ -0,0 +1,14 @@ +<%= turbo_frame_tag dom_id(@bubble, :assignments) do %> + <%= form_with url: bucket_bubble_assignments_path(@bubble.bucket, @bubble), data: { controller: "form" } do |form| %> +
+ + <%= form.submit "Save", class: "btn", hidden: true %> +
+ <% end %> +<% end %> diff --git a/app/views/bubbles/assignments/show.html.erb b/app/views/bubbles/assignments/show.html.erb new file mode 100644 index 000000000..7d7c7c9fc --- /dev/null +++ b/app/views/bubbles/assignments/show.html.erb @@ -0,0 +1,28 @@ +<%= turbo_frame_tag dom_id(@bubble, :assignments) do %> + <% if @bubble.assignments.any? %> +
+ <%= form_with url: bucket_bubble_assignments_path(@bubble.bucket, @bubble), data: { controller: "form" } do |form| %> + + + <%= form.submit "Save", class: "btn", hidden: true %> + <% end %> +
+ <% end %> +<% end %> diff --git a/app/views/bubbles/show.html.erb b/app/views/bubbles/show.html.erb index 3b81368a9..de6aed524 100644 --- a/app/views/bubbles/show.html.erb +++ b/app/views/bubbles/show.html.erb @@ -24,12 +24,19 @@