diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index d034bfbcd..d14f26c32 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -8,8 +8,11 @@ class CollectionsController < ApplicationController end def show - set_page_and_extract_portion_from @collection.cards.awaiting_triage.reverse_chronologically.with_golden_first - fresh_when etag: [ @collection, @page.records, @user_filtering ] + if @filter.used?(ignore_collections: true) + show_filtered_events + else + show_columns + end end def create @@ -42,6 +45,16 @@ class CollectionsController < ApplicationController @collection = Current.user.collections.find params[:id] end + def show_filtered_events + @filter.collection_ids = [ @collection.id ] + set_page_and_extract_portion_from @filter.cards + end + + def show_columns + set_page_and_extract_portion_from @collection.cards.awaiting_triage.reverse_chronologically.with_golden_first + fresh_when etag: [ @collection, @page.records, @user_filtering ] + end + def collection_params params.expect(collection: [ :name, :all_access, :auto_postpone_period, :public_description ]) end diff --git a/app/javascript/controllers/turbo_navigation_controller.js b/app/javascript/controllers/turbo_navigation_controller.js new file mode 100644 index 000000000..4c5823620 --- /dev/null +++ b/app/javascript/controllers/turbo_navigation_controller.js @@ -0,0 +1,25 @@ +import { Controller } from "@hotwired/stimulus" + +export default class extends Controller { + rememberLocation() { + sessionStorage.setItem("referrerUrl", window.location.href) + } + + backIfSamePath(event) { + const link = event.target.closest("a") + const targetUrl = new URL(link.href) + + if (this.#referrerPath && targetUrl.pathname === this.#referrerPath) { + event.preventDefault() + Turbo.visit(this.#referrerUrl) + } + } + get #referrerPath() { + if (!this.#referrerUrl) return null + return new URL(this.#referrerUrl).pathname + } + + get #referrerUrl() { + return sessionStorage.getItem("referrerUrl") + } +} diff --git a/app/views/cards/index.html.erb b/app/views/cards/index.html.erb index e1b0264ed..1e457c452 100644 --- a/app/views/cards/index.html.erb +++ b/app/views/cards/index.html.erb @@ -23,7 +23,7 @@ <% end %> -<%= render "filters/settings", user_filtering: @user_filtering, no_filtering_url: cards_path %> +<%= render "filters/settings", filter_url: cards_path, user_filtering: @user_filtering, no_filtering_url: cards_path %> <%= turbo_frame_tag :cards_container do %>
diff --git a/app/views/cards/show.html.erb b/app/views/cards/show.html.erb index 461afdd9b..9b35b9b1e 100644 --- a/app/views/cards/show.html.erb +++ b/app/views/cards/show.html.erb @@ -12,7 +12,9 @@ <% content_for :header do %> <%= render "filters/menu", user_filtering: @user_filtering %> - <%= link_to collection_path(@card.collection), class: "header__title btn borderless txt-large", style: "--btn-padding: 0.25ch 1ch 0.25ch 0.75ch; view-transistion-name: card-collection-title;", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %> + <%= link_to collection_url(@card.collection), class: "header__title btn borderless txt-large", + style: "--btn-padding: 0.25ch 1ch 0.25ch 0.75ch; view-transistion-name: card-collection-title;", + data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click click->turbo-navigation#backIfSamePath" } do %> <%= @card.collection.name %> diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb index ed71b1395..ac7343885 100644 --- a/app/views/collections/show.html.erb +++ b/app/views/collections/show.html.erb @@ -19,24 +19,18 @@
- <%= render "cards/collection_settings", collection: @collection %> + <%= render "cards/collection_settings", collection: @collection %>
<% end %> -<%= render "filters/settings", user_filtering: @user_filtering, no_filtering_url: collection_path(@collection) do |form| %> +<%= render "filters/settings", filter_url: collection_path(@collection), user_filtering: @user_filtering, no_filtering_url: collection_path(@collection) do |form| %> <%= hidden_field_tag "collection_ids[]", @collection.id %> <% end %> -<%= tag.div data: { - controller: "drag-and-drop drag-and-strum", - drag_and_drop_dragged_item_class: "drag-and-drop__dragged-item", - drag_and_drop_hover_container_class: "drag-and-drop__hover-container", - action: " - dragstart->drag-and-drop#dragStart - dragover->drag-and-drop#dragOver - dragenter->drag-and-strum#dragEnter - drop->drag-and-drop#drop - dragend->drag-and-drop#dragEnd" } do %> - - <%= render "collections/show/columns", page: @page, collection: @collection %> +<%= turbo_frame_tag :cards_container do %> + <% if @filter.used?(ignore_collections: true) %> + <%= render "collections/show/filtered_cards", page: @page %> + <% else %> + <%= render "collections/show/columns", page: @page, collection: @collection %> + <% end %> <% end %> diff --git a/app/views/collections/show/_columns.html.erb b/app/views/collections/show/_columns.html.erb index e4c872b50..a290cf221 100644 --- a/app/views/collections/show/_columns.html.erb +++ b/app/views/collections/show/_columns.html.erb @@ -1,6 +1,15 @@ -<%= turbo_frame_tag :cards_container do %> -
+<%= tag.div data: { + controller: "drag-and-drop drag-and-strum", + drag_and_drop_dragged_item_class: "drag-and-drop__dragged-item", + drag_and_drop_hover_container_class: "drag-and-drop__hover-container", + action: " + dragstart->drag-and-drop#dragStart + dragover->drag-and-drop#dragOver + dragenter->drag-and-strum#dragEnter + drop->drag-and-drop#drop + dragend->drag-and-drop#dragEnd" } do %> +
<%= render "collections/show/not_now", collection: collection %>
@@ -11,7 +20,8 @@ <%= render partial: "collections/show/column", collection: collection.columns, cached: true %> <%= render "collections/show/closed", collection: collection %> - <%= render "collections/show/menu/columns", collection: collection %> + <%= render "collections/show/menu/columns", collection: collection %>
<% end %> + diff --git a/app/views/collections/show/_filtered_cards.html.erb b/app/views/collections/show/_filtered_cards.html.erb new file mode 100644 index 000000000..281af18f6 --- /dev/null +++ b/app/views/collections/show/_filtered_cards.html.erb @@ -0,0 +1,3 @@ +
+ <%= render partial: "cards/display/preview", collection: page.records, as: :card, locals: { draggable: true }, cached: ->(card) { cacheable_preview_parts_for(card) } %> +
\ No newline at end of file diff --git a/app/views/filters/_settings.html.erb b/app/views/filters/_settings.html.erb index 538c766e5..16b37ba6d 100644 --- a/app/views/filters/_settings.html.erb +++ b/app/views/filters/_settings.html.erb @@ -7,7 +7,7 @@ filter_settings_filters_set_class: "filters--has-filters-set", filter_settings_no_filtering_url_value: no_filtering_url, filter_settings_refresh_url_value: settings_refresh_path } do %> - <%= form_with url: cards_path, method: :get, class: "", data: { + <%= form_with url: filter_url, method: :get, class: "", data: { controller: "form", turbo_frame: "cards_container", filter_settings_target: "form", diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 4176e8c3f..87eef1d5c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -2,7 +2,7 @@ <%= render "layouts/shared/head" %> - +