Improve table actions layout

In the past we were using some <div> tags surrounding table action
links in order to guarantee these links wouldn't be wider that their
cell's space and wouldn't expand over two lines.

However, while these links didn't expand over two lines, at certain
resolutions the width of their text exceeded the width of the links,
causing part of the text to be outside their borders.

This behavior was also inconsistent: some tables had these <div> tags,
and some tables didn't.

Since we've now introduced the table actions component, the code is more
consistent and we're getting rid of these <div> tags. So now we're again
facing the issue where links could expand over two lines.

Using a flex layout solves this issue and considerably improves the
layout at lower resolutions.
This commit is contained in:
Javi Martín
2020-07-05 12:11:38 +02:00
parent fb23df2e5b
commit 64b0cc741b
13 changed files with 38 additions and 35 deletions

View File

@@ -236,16 +236,8 @@ $sidebar-active: #f4fcd0;
table-layout: fixed; table-layout: fixed;
} }
[type="submit"] ~ a, [type="submit"] ~ a {
a ~ a { margin-left: $line-height / 2;
margin-left: 0;
margin-right: 0;
margin-top: $line-height / 2;
@include breakpoint(medium) {
margin-left: $line-height / 2;
margin-top: 0;
}
} }
} }

View File

@@ -0,0 +1,12 @@
.admin .table-actions {
align-items: baseline;
display: flex;
> :not(:first-child) {
margin-left: $line-height / 2;
}
> p {
align-self: flex-start;
}
}

View File

@@ -27,3 +27,4 @@
@import "jquery-ui/sortable"; @import "jquery-ui/sortable";
@import "leaflet"; @import "leaflet";
@import "sticky_overrides"; @import "sticky_overrides";
@import "admin/*";

View File

@@ -1,9 +1,11 @@
<%= content %> <div class="table-actions">
<%= content %>
<% if actions.include?(:edit) %> <% if actions.include?(:edit) %>
<%= link_to edit_text, edit_path, edit_options %> <%= link_to edit_text, edit_path, edit_options %>
<% end %> <% end %>
<% if actions.include?(:destroy) %> <% if actions.include?(:destroy) %>
<%= link_to destroy_text, destroy_path, destroy_options %> <%= link_to destroy_text, destroy_path, destroy_options %>
<% end %> <% end %>
</div>

View File

@@ -17,7 +17,7 @@
<tr> <tr>
<td><%= user.name %></td> <td><%= user.name %></td>
<td><%= user.email %></td> <td><%= user.email %></td>
<td class="text-right"> <td>
<% if user.administrator? && user.administrator.persisted? %> <% if user.administrator? && user.administrator.persisted? %>
<%= render Admin::TableActionsComponent.new(user.administrator, actions: [:destroy]) %> <%= render Admin::TableActionsComponent.new(user.administrator, actions: [:destroy]) %>
<% else %> <% else %>

View File

@@ -4,7 +4,7 @@
<td><%= Dashboard::Action.human_attribute_name("action_type_resource") %></td> <td><%= Dashboard::Action.human_attribute_name("action_type_resource") %></td>
<td class="text-center"><%= t("admin.dashboard.actions.index.active") %></td> <td class="text-center"><%= t("admin.dashboard.actions.index.active") %></td>
<td colspan="4">&nbsp;</td> <td colspan="4">&nbsp;</td>
<td class="text-right"> <td>
<%= render Admin::TableActionsComponent.new( <%= render Admin::TableActionsComponent.new(
actions: [:edit], actions: [:edit],
edit_path: admin_settings_path(anchor: "tab-proposals"), edit_path: admin_settings_path(anchor: "tab-proposals"),

View File

@@ -17,7 +17,7 @@
<th class="text-center"><%= t("admin.dashboard.actions.index.day_offset") %></th> <th class="text-center"><%= t("admin.dashboard.actions.index.day_offset") %></th>
<th class="text-center"><%= t("admin.dashboard.actions.index.required_supports") %></th> <th class="text-center"><%= t("admin.dashboard.actions.index.required_supports") %></th>
<th class="text-center"><%= t("admin.dashboard.actions.index.order") %></th> <th class="text-center"><%= t("admin.dashboard.actions.index.order") %></th>
<th class="text-right small-3"><%= t("admin.actions.actions") %></th> <th class="small-3"><%= t("admin.actions.actions") %></th>
</tr> </tr>
</thead> </thead>
@@ -31,7 +31,7 @@
<td class="text-center"><%= number_with_delimiter(action.day_offset, delimiter: ".") %></td> <td class="text-center"><%= number_with_delimiter(action.day_offset, delimiter: ".") %></td>
<td class="text-center"><%= number_with_delimiter(action.required_supports, delimiter: ".") %></td> <td class="text-center"><%= number_with_delimiter(action.required_supports, delimiter: ".") %></td>
<td class="text-center"><%= action.order %></td> <td class="text-center"><%= action.order %></td>
<td class="text-right"> <td>
<%= render Admin::TableActionsComponent.new(action) %> <%= render Admin::TableActionsComponent.new(action) %>
</td> </td>
</tr> </tr>

View File

@@ -10,7 +10,7 @@
<tr> <tr>
<th><%= t("admin.dashboard.administrator_tasks.index.source") %></th> <th><%= t("admin.dashboard.administrator_tasks.index.source") %></th>
<th><%= t("admin.dashboard.administrator_tasks.index.resource") %></th> <th><%= t("admin.dashboard.administrator_tasks.index.resource") %></th>
<th class="text-right"><%= t("admin.actions.actions") %></th> <th><%= t("admin.actions.actions") %></th>
</tr> </tr>
</thead> </thead>
@@ -23,7 +23,7 @@
<td> <td>
<%= task.source.action.title %> <%= task.source.action.title %>
</td> </td>
<td class="text-right"> <td>
<% unless task.executed_at? %> <% unless task.executed_at? %>
<%= render Admin::TableActionsComponent.new(task, <%= render Admin::TableActionsComponent.new(task,
actions: [:edit], actions: [:edit],

View File

@@ -5,7 +5,7 @@
<td> <td>
<%= booth.location %> <%= booth.location %>
</td> </td>
<td class="text-right"> <td>
<% if controller_name == "shifts" || controller_name == "booths" && action_name == "available" %> <% if controller_name == "shifts" || controller_name == "booths" && action_name == "available" %>
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %> <%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
<%= actions.link_to t("admin.booths.booth.shifts"), <%= actions.link_to t("admin.booths.booth.shifts"),

View File

@@ -18,7 +18,7 @@
<thead> <thead>
<th><%= t("admin.booths.index.name") %></th> <th><%= t("admin.booths.index.name") %></th>
<th><%= t("admin.booths.index.location") %></th> <th><%= t("admin.booths.index.location") %></th>
<th class="text-right"><%= t("admin.actions.actions") %></th> <th><%= t("admin.actions.actions") %></th>
</thead> </thead>
<tbody> <tbody>
<% @booths.each do |booth| %> <% @booths.each do |booth| %>

View File

@@ -27,7 +27,7 @@
<table> <table>
<tr> <tr>
<th scope="col"><%= t("admin.questions.show.answers.document_title") %></th> <th scope="col"><%= t("admin.questions.show.answers.document_title") %></th>
<th scope="col" class="text-right"><%= t("admin.questions.show.answers.document_actions") %></th> <th scope="col"><%= t("admin.questions.show.answers.document_actions") %></th>
</tr> </tr>
<% @answer.documents.each do |document| %> <% @answer.documents.each do |document| %>
@@ -35,7 +35,7 @@
<td> <td>
<%= link_to document.title, document.attachment.url %> <%= link_to document.title, document.attachment.url %>
</td> </td>
<td class="text-right"> <td>
<%= render Admin::TableActionsComponent.new(document, <%= render Admin::TableActionsComponent.new(document,
actions: [:destroy], actions: [:destroy],
destroy_path: document_path(document) destroy_path: document_path(document)

View File

@@ -17,9 +17,7 @@
<tr> <tr>
<th><%= t("admin.answers.videos.index.video_title") %></th> <th><%= t("admin.answers.videos.index.video_title") %></th>
<th><%= t("admin.answers.videos.index.video_url") %></th> <th><%= t("admin.answers.videos.index.video_url") %></th>
<th class="text-right"> <th><%= t("admin.actions.actions") %></th>
<%= t("admin.actions.actions") %>
</th>
</tr> </tr>
</thead> </thead>
@@ -28,7 +26,7 @@
<tr id="<%= dom_id(video) %>" class="poll_question_answer_video"> <tr id="<%= dom_id(video) %>" class="poll_question_answer_video">
<td><%= video.title %></td> <td><%= video.title %></td>
<td><%= link_to "#{video.url}", video.url %></td> <td><%= link_to "#{video.url}", video.url %></td>
<td class="text-right"> <td>
<%= render Admin::TableActionsComponent.new(video) %> <%= render Admin::TableActionsComponent.new(video) %>
</td> </td>
</tr> </tr>

View File

@@ -10,9 +10,7 @@
<tr> <tr>
<th><%= t("admin.poll_shifts.new.table_name") %></th> <th><%= t("admin.poll_shifts.new.table_name") %></th>
<th><%= t("admin.poll_shifts.new.table_email") %></th> <th><%= t("admin.poll_shifts.new.table_email") %></th>
<th class="text-right"> <th><%= t("admin.poll_shifts.new.table_shift") %></th>
<%= t("admin.poll_shifts.new.table_shift") %>
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -24,7 +22,7 @@
<td> <td>
<%= user.email %> <%= user.email %>
</td> </td>
<td class="text-right"> <td>
<%= render Admin::TableActionsComponent.new( <%= render Admin::TableActionsComponent.new(
actions: [:edit], actions: [:edit],
edit_text: t("admin.poll_shifts.new.edit_shifts"), edit_text: t("admin.poll_shifts.new.edit_shifts"),