diff --git a/app/controllers/taggings/toggles_controller.rb b/app/controllers/taggings/toggles_controller.rb index 3a8055098..786271c41 100644 --- a/app/controllers/taggings/toggles_controller.rb +++ b/app/controllers/taggings/toggles_controller.rb @@ -1,6 +1,10 @@ class Taggings::TogglesController < ApplicationController include BubbleScoped, BucketScoped + def new + render partial: "bubbles/sidebar/tag", locals: { bubble: @bubble, tags: Current.account.tags } + end + def create if params[:tag_title].present? sanitized_title = params[:tag_title].strip.gsub(/\A#/, "") @@ -20,6 +24,14 @@ class Taggings::TogglesController < ApplicationController end end - redirect_to @bubble + @bubble.tags.reload + + respond_to do |format| + format.turbo_stream do + render turbo_stream: turbo_stream.replace([ @bubble, :tags ], + partial: "bubbles/tags", + locals: { bubble: @bubble }) + end + end end end diff --git a/app/views/bubbles/_tags.html.erb b/app/views/bubbles/_tags.html.erb index ba774fbaf..4c3072285 100644 --- a/app/views/bubbles/_tags.html.erb +++ b/app/views/bubbles/_tags.html.erb @@ -1,13 +1,22 @@ -
- <% if bubble.tags.any? || bubble.creating? %> - # - <% bubble.tags.each_with_index do |tag, index| %> - <%= link_to bubbles_path(bucket_ids: [ bubble.bucket ], tag_ids: [ tag.id ]), - class: "card__tag btn btn--plain min-width txt-uppercase fill-transparent", data: { turbo_frame: "_top" } do %> - <%= tag.title %> - <% end %><%= ", " unless index == bubble.tags.size - 1 %> +<%= turbo_frame_tag bubble, :tags do %> +
+ <% if bubble.tags.any? || bubble.creating? %> + # + <% bubble.tags.each_with_index do |tag, index| %> + <%= link_to bubbles_path(bucket_ids: [ bubble.bucket ], tag_ids: [ tag.id ]), + class: "card__tag btn btn--plain min-width txt-uppercase fill-transparent", data: { turbo_frame: "_top" } do %> + <%= tag.title %> + <% end %><%= ", " unless index == bubble.tags.size - 1 %> + <% end %> <% end %> - <% end %> - <%= render "bubbles/sidebar/tag", bubble: bubble, tags: Current.account.tags %> -
+
+ + + <%= turbo_frame_tag bubble, :tag, src: new_bucket_bubble_tagging_toggle_path(bubble.bucket, bubble) %> +
+
+<% end %> diff --git a/app/views/bubbles/sidebar/_assignment.html.erb b/app/views/bubbles/sidebar/_assignment.html.erb index 1c6f223b4..489d92a60 100644 --- a/app/views/bubbles/sidebar/_assignment.html.erb +++ b/app/views/bubbles/sidebar/_assignment.html.erb @@ -1,4 +1,4 @@ -<% cache [bubble, bubble.bucket] do %> +<% cache [ bubble, bubble.bucket ] do %> <%= turbo_frame_tag bubble, :assignment do %> Assign this to… diff --git a/app/views/bubbles/sidebar/_tag.html.erb b/app/views/bubbles/sidebar/_tag.html.erb index 2fd5718ba..59223ccc6 100644 --- a/app/views/bubbles/sidebar/_tag.html.erb +++ b/app/views/bubbles/sidebar/_tag.html.erb @@ -1,34 +1,31 @@ -
- +<% cache [ bubble, Current.account ] do %> + <%= turbo_frame_tag bubble, :tag do %> + + Tag this… - - Tag this… - - <%= form_with url: bucket_bubble_tagging_toggles_path(bubble.bucket, bubble), class: "flex gap-half align-center full-width pad-inline-half margin-block-end" do |form| %> - <%= form.text_field :tag_title, placeholder: "New tag name...", class: "input txt-small full-width" %> - <%= form.button "Add a tag…", type: "submit", class: "btn txt-small" do %> - <%= image_tag "add.svg", aria: { hidden: true }, size: 24 %> - Add a tag + <%= form_with url: bucket_bubble_tagging_toggles_path(bubble.bucket, bubble), class: "flex gap-half align-center full-width pad-inline-half margin-block-end" do |form| %> + <%= form.text_field :tag_title, placeholder: "New tag name...", class: "input txt-small full-width" %> + <%= form.button "Add a tag…", type: "submit", class: "btn txt-small" do %> + <%= image_tag "add.svg", aria: { hidden: true }, size: 24 %> + Add a tag + <% end %> <% end %> - <% end %> - <%= form_with url: bucket_bubble_tagging_toggles_path(bubble.bucket, bubble), class: "flex flex-column full-width popup__list", data: { controller: "form" } do |form| %> - <% tags.sort_by { |tag| tag.hashtag.downcase }.each do |tag| %> - + <% end %> <% end %> - <% end %> - -
+
+ <% end %> +<% end %> diff --git a/test/controllers/taggings/toggles_controller_test.rb b/test/controllers/taggings/toggles_controller_test.rb index 1fe593c38..4d54086ad 100644 --- a/test/controllers/taggings/toggles_controller_test.rb +++ b/test/controllers/taggings/toggles_controller_test.rb @@ -5,17 +5,23 @@ class Taggings::TogglesControllerTest < ActionDispatch::IntegrationTest sign_in_as :kevin end + test "new" do + get new_bucket_bubble_tagging_toggle_url(buckets(:writebook), bubbles(:logo)) + + assert_response :success + end + test "create" do assert_changes "bubbles(:logo).tagged_with?(tags(:mobile))", from: false, to: true do - post bucket_bubble_tagging_toggles_url(buckets(:writebook), bubbles(:logo)), params: { tag_id: tags(:mobile).id } + post bucket_bubble_tagging_toggles_url(buckets(:writebook), bubbles(:logo)), params: { tag_id: tags(:mobile).id }, as: :turbo_stream end - assert_redirected_to bubbles(:logo) + assert_response :success assert_changes "bubbles(:logo).tagged_with?(tags(:web))", from: false, to: true do assert_changes "bubbles(:logo).tagged_with?(tags(:mobile))", from: true, to: false do - post bucket_bubble_tagging_toggles_url(buckets(:writebook), bubbles(:logo)), params: { tag_id: tags(:web).id } + post bucket_bubble_tagging_toggles_url(buckets(:writebook), bubbles(:logo)), params: { tag_id: tags(:web).id }, as: :turbo_stream end end - assert_redirected_to bubbles(:logo) + assert_response :success end end