-
Notifications
You must be signed in to change notification settings - Fork 187
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 1 commit
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 |
---|---|---|
|
@@ -2,24 +2,40 @@ | |
|
||
<div class="w-full"> | ||
<%% if notice.present? %> | ||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-md inline-block" id="notice"><%%= notice %></p> | ||
<p class="inline-block px-3 py-2 mb-5 font-medium text-green-500 rounded-md bg-green-50" id="notice"><%%= notice %></p> | ||
<%% end %> | ||
|
||
<div class="flex justify-between items-center"> | ||
<h1 class="font-bold text-4xl"><%= human_name.pluralize %></h1> | ||
<div class="flex items-center justify-between"> | ||
<h1 class="text-4xl font-bold"><%= human_name.pluralize %></h1> | ||
<%%= 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"> | ||
<%% @users.each do |user| %> | ||
<tr class="border-b"> | ||
<% attributes.reject(&:password_digest?).each do |attribute| -%> | ||
<td class="py-4 whitespace-nowrap"><%%= <%= singular_name %>.<%= attribute.column_name %> %></td> | ||
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. 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 commentThe reason will be displayed to describe this comment to others. Learn more. good catch - added! |
||
<% 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! |
||
</td> | ||
</tr> | ||
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. we can still have this in a partial but i don't see the benefit - i don't think it'll be used somewhere else. 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 fine to have it inline in this PR, if a need emerges for a partial it's easy to extract later. 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. perfect! |
||
<%% end %> | ||
</tbody> | ||
</table> | ||
<%% else %> | ||
<p class="text-center my-10">No <%= human_name.downcase.pluralize %> found.</p> | ||
<p class="my-10 text-center">No <%= human_name.downcase.pluralize %> found.</p> | ||
<%% end %> | ||
</div> | ||
</div> |
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.
This needs to be
@<%= plural_table_name %>.each
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.
🤦