-
Notifications
You must be signed in to change notification settings - Fork 189
make the index a table again #457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,44 @@ | |
<%%= 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" %> | ||
</div> | ||
|
||
<div id="<%= plural_table_name %>" class="min-w-full"> | ||
<div id="<%= plural_table_name %>" class="inline-block min-w-full mt-10"> | ||
<%% if @<%= plural_table_name %>.any? %> | ||
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %> | ||
<%%= render <%= singular_table_name %> %> | ||
<p> | ||
<%%= 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" %> | ||
</p> | ||
<%% end %> | ||
<table class="min-w-full divide-y divide-gray-300"> | ||
<thead> | ||
<tr> | ||
<% attributes.reject(&:password_digest?).each do |attribute| -%> | ||
<th class="py-3.5 text-left font-semibold"><%= attribute.human_name %></th> | ||
<% end -%> | ||
<th class="py-3.5 text-left font-semibold">Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody class="divide-y divide-gray-200"> | ||
<%% @<%= plural_table_name %>.each do |<%= singular_name %>| %> | ||
<tr class="border-b"> | ||
<% attributes.reject(&:password_digest?).each do |attribute| -%> | ||
<% if attribute.attachment? -%> | ||
<td class="py-4 whitespace-nowrap"><%%= link_to <%= singular_name %>.<%= attribute.column_name %>.filename, <%= singular_name %>.<%= attribute.column_name %> if <%= singular_name %>.<%= attribute.column_name %>.attached? %></td> | ||
<% elsif attribute.attachments? -%> | ||
<td class="py-4 whitespace-nowrap"> | ||
<%% <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %> | ||
<div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div> | ||
<%% end %> | ||
</td> | ||
<% else -%> | ||
<td class="py-4 whitespace-nowrap"><%%= <%= singular_name %>.<%= attribute.column_name %> %></td> | ||
<% end -%> | ||
<% end -%> | ||
<td class="py-4 space-x-4 whitespace-nowrap"> | ||
<%%= link_to "Show", <%= model_resource_name(singular_table_name) %>, class: "text-blue-600 hover:text-blue-900" %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kept just the link to the show action, but we can also add the Edit and Destroy links. thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would personally like to have the Edit and Destroy links in the table, but I suppose we could do that in a separate PR if you're unsure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's a nice addition - added! |
||
<%%= link_to "Edit", edit_<%= singular_route_name %>_path(<%= singular_table_name %>), class: "text-blue-600 hover:text-blue-900" %> | ||
<div class="inline-block ml-2"> | ||
<%%= button_to "Destroy", <%= model_resource_name %>, method: :delete, class: "text-red-600 hover:text-red-900" %> | ||
</div> | ||
</td> | ||
</tr> | ||
<%% end %> | ||
</tbody> | ||
</table> | ||
<%% else %> | ||
<p class="text-center my-10">No <%= human_name.downcase.pluralize %> found.</p> | ||
<%% end %> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The partial has logic to handle rendering links to attachments, which we should probably mirror.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch - added!