From c8c8d8cd70ea7e9ce27053207680a28fca73995e Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Mon, 30 Dec 2024 00:44:21 +0100 Subject: [PATCH] Hide actions for restricted users Closes #43 --- app/assets/stylesheets/application.css | 2 +- app/views/default/units/_unit.html.erb | 29 ++++++++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 3e8b804..71bcfde 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -355,7 +355,7 @@ table.items td:last-child { } table.items td { border-top: solid 1px var(--color-border-gray); - min-height: 2.4em; + height: 2.4em; padding-block: 0.1em; } /* For to fill completely, we use an ::after pseudoelement. */ diff --git a/app/views/default/units/_unit.html.erb b/app/views/default/units/_unit.html.erb index ddccdd4..2fe42bc 100644 --- a/app/views/default/units/_unit.html.erb +++ b/app/views/default/units/_unit.html.erb @@ -3,21 +3,24 @@ <%= unit %> - - <% unless unit.portable.nil? %> - <% if current_user.at_least(:active) && unit.default? %> - <%= image_button_to t('.import'), 'download-outline', import_default_unit_path(unit), - disabled_attributes(!unit.portable?) %> - <% end %> - <% if current_user.at_least(:admin) %> + <% if current_user.at_least(:active) %> + + <% unless unit.portable.nil? %> <% if unit.default? %> - <%= image_button_to t('.delete'), 'delete-outline', default_unit_path(unit), - method: :delete, **disabled_attributes(!unit.movable?) %> - <% else %> - <%= image_button_to t('.export'), 'upload-outline', export_default_unit_path(unit), + <%= image_button_to t('.import'), 'download-outline', import_default_unit_path(unit), disabled_attributes(!unit.portable?) %> <% end %> + + <% if current_user.at_least(:admin) %> + <% if unit.default? %> + <%= image_button_to t('.delete'), 'delete-outline', default_unit_path(unit), + method: :delete, **disabled_attributes(!unit.movable?) %> + <% else %> + <%= image_button_to t('.export'), 'upload-outline', export_default_unit_path(unit), + disabled_attributes(!unit.portable?) %> + <% end %> + <% end %> <% end %> - <% end %> - + + <% end %> <% end %>