From bcac3fad10b3f668cd048b20a9cb7146c1cbf847 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 30 Oct 2025 09:12:49 +0100 Subject: [PATCH] Move perma collection picker to turbo frame --- .../cards/collections_controller.rb | 12 ++++++++- app/views/cards/collections/edit.html.erb | 26 +++++++++++++++++++ .../cards/display/perma/_collection.html.erb | 25 +----------------- config/routes.rb | 2 +- 4 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 app/views/cards/collections/edit.html.erb diff --git a/app/controllers/cards/collections_controller.rb b/app/controllers/cards/collections_controller.rb index 31d48b8a5..7a9f0b097 100644 --- a/app/controllers/cards/collections_controller.rb +++ b/app/controllers/cards/collections_controller.rb @@ -1,9 +1,19 @@ class Cards::CollectionsController < ApplicationController - include CollectionScoped + before_action :set_collection, only: %i[ update ] + + def edit + @card = Current.user.accessible_cards.find(params[:card_id]) + @collections = Current.user.collections.ordered_by_recently_accessed + end def update @card = Current.user.accessible_cards.find(params[:card_id]) @card.move_to(@collection) redirect_to @card end + + private + def set_collection + @collection = Current.user.collections.find(params[:collection_id]) + end end diff --git a/app/views/cards/collections/edit.html.erb b/app/views/cards/collections/edit.html.erb new file mode 100644 index 000000000..9a9ef4130 --- /dev/null +++ b/app/views/cards/collections/edit.html.erb @@ -0,0 +1,26 @@ +<%= turbo_frame_tag "collection_picker" do %> + <%= tag.div class: "max-width full-width", data: { + action: "turbo:before-cache@document->dialog#close dialog:show@document->navigable-list#reset keydown->navigable-list#navigate filter:changed->navigable-list#reset", + controller: "filter navigable-list", + dialog_target: "dialog", + navigable_list_focus_on_selection_value: false, + navigable_list_actionable_items_value: true } do %> + Move this card to… + + <%= text_field_tag :search, nil, placeholder: "Filter…", class: "input input--transparent txt-small margin-block-half font-weight-normal", autofocus: true, + type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", action: "input->filter#filter" } %> + + + <% end %> +<% end %> diff --git a/app/views/cards/display/perma/_collection.html.erb b/app/views/cards/display/perma/_collection.html.erb index da0aeed25..a9e0cbbfa 100644 --- a/app/views/cards/display/perma/_collection.html.erb +++ b/app/views/cards/display/perma/_collection.html.erb @@ -7,30 +7,7 @@ - <%= tag.div class: "max-width full-width", data: { - action: "turbo:before-cache@document->dialog#close dialog:show@document->navigable-list#reset keydown->navigable-list#navigate filter:changed->navigable-list#reset", - controller: "filter navigable-list", - dialog_target: "dialog", - navigable_list_focus_on_selection_value: false, - navigable_list_actionable_items_value: true } do %> - Move this card to… - - <%= text_field_tag :search, nil, placeholder: "Filter…", class: "input input--transparent txt-small margin-block-half font-weight-normal", autofocus: true, - type: "search", autocorrect: "off", autocomplete: "off", data: { "1p-ignore": "true", filter_target: "input", action: "input->filter#filter" } %> - - - <% end %> + <%= turbo_frame_tag "collection_picker", src: edit_card_collection_path(card), target: "_top" %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index ece63ccf9..6bbc8fbcf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -69,7 +69,7 @@ Rails.application.routes.draw do resource :reading resource :recover resource :watch - resource :collection, only: :update + resource :collection resources :assignments resources :taggings