From dc8251df17086995686e85fdb9bfa9fde731997a Mon Sep 17 00:00:00 2001 From: Patricio Mac Adden Date: Mon, 20 Jan 2025 22:50:44 -0300 Subject: [PATCH 1/2] index: show the actions to the right of the partial and add a division between objects --- .../scaffold/templates/index.html.erb.tt | 16 +++++++++++----- test/integration/user_install_test.sh | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt index 3d337f95..71b7ec23 100644 --- a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt @@ -10,13 +10,19 @@ <%%= link_to "New <%= human_name.downcase %>", new_<%= singular_route_name %>_path, class: "rounded-md px-3.5 py-2.5 bg-blue-600 hover:bg-blue-500 text-white block font-medium" %> -
+
<%% if @<%= plural_table_name %>.any? %> <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %> - <%%= render <%= singular_table_name %> %> -

- <%%= link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(singular_table_name) %>, class: "ml-2 rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> -

+
+ <%%= render <%= singular_table_name %> %> +
+ <%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> + <%%= link_to "Edit", edit_<%= singular_route_name %>_path(<%= singular_table_name %>), class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> +
+ <%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium" %> +
+
+
<%% end %> <%% else %>

No <%= human_name.downcase.pluralize %> found.

diff --git a/test/integration/user_install_test.sh b/test/integration/user_install_test.sh index df3aa8f2..6f4ca301 100755 --- a/test/integration/user_install_test.sh +++ b/test/integration/user_install_test.sh @@ -61,7 +61,7 @@ fi # TEST: presence of the generated file bin/rails generate scaffold post title:string body:text published:boolean -grep -q "Show this post" app/views/posts/index.html.erb +grep -q "Show" app/views/posts/index.html.erb # TEST: contents of the css file bin/rails tailwindcss:build[verbose] From ad98417f261dee5a6538489f2e48a083c60fcd7d Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 19 Feb 2025 10:41:30 -0500 Subject: [PATCH 2/2] Simplify index page edit button to use edit_helper --- lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt index 71b7ec23..7e9b26af 100644 --- a/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt +++ b/lib/generators/tailwindcss/scaffold/templates/index.html.erb.tt @@ -17,7 +17,7 @@ <%%= render <%= singular_table_name %> %>
<%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> - <%%= link_to "Edit", edit_<%= singular_route_name %>_path(<%= singular_table_name %>), class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %> + <%%= link_to "Edit", <%= edit_helper(singular_table_name, type: :path) %>, class: "rounded-md px-3.5 py-2.5 bg-gray-100 hover:bg-gray-50 inline-block font-medium" %>
<%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "rounded-md px-3.5 py-2.5 text-white bg-red-600 hover:bg-red-500 font-medium" %>