From dfc50faee9ec0668b9a2b5e44776bd0918244849 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 30 Oct 2025 16:03:10 +0100 Subject: [PATCH] Extract helper instead of using anemic partial --- app/helpers/collections_helper.rb | 6 ++++++ app/views/cards/_collection_settings.html.erb | 4 ---- app/views/cards/index.html.erb | 2 +- app/views/collections/show.html.erb | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 app/views/cards/_collection_settings.html.erb diff --git a/app/helpers/collections_helper.rb b/app/helpers/collections_helper.rb index 56894e51e..1cb9d8a17 100644 --- a/app/helpers/collections_helper.rb +++ b/app/helpers/collections_helper.rb @@ -7,6 +7,12 @@ module CollectionsHelper end end + def link_to_edit_collection(collection) + link_to edit_collection_path(collection), class: "btn", data: { controller: "tooltip" } do + icon_tag("settings") + tag.span("Settings for #{collection.name}", class: "for-screen-reader") + end + end + def referenced_collections_from(records) Current.user.collections.where id: records.pluck(:collection_id).uniq end diff --git a/app/views/cards/_collection_settings.html.erb b/app/views/cards/_collection_settings.html.erb deleted file mode 100644 index b677c3f96..000000000 --- a/app/views/cards/_collection_settings.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= link_to edit_collection_path(collection), class: "btn", data: { controller: "tooltip" } do %> - <%= icon_tag "settings" %> - Settings for <%= collection.name %> -<% end %> diff --git a/app/views/cards/index.html.erb b/app/views/cards/index.html.erb index d700b363a..bc28fc82d 100644 --- a/app/views/cards/index.html.erb +++ b/app/views/cards/index.html.erb @@ -18,7 +18,7 @@
<% if collection = @filter.single_collection %> - <%= render "cards/collection_settings", collection: collection %> + <%= link_to_edit_collection collection %> <% end %>
<% end %> diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb index 0cff21b62..aa6f54768 100644 --- a/app/views/collections/show.html.erb +++ b/app/views/collections/show.html.erb @@ -15,7 +15,7 @@
- <%= render "cards/collection_settings", collection: @collection %> + <%= link_to_edit_collection @collection %>
<% end %>