Skip to content

Commit

Permalink
#57: Überarbeitung Layout und Renderstruktur
Browse files Browse the repository at this point in the history
  • Loading branch information
nbennke committed Dec 18, 2024
1 parent 0be18d6 commit 1cb75c7
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 58 deletions.
22 changes: 16 additions & 6 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,23 @@ th.action {
.inner-table {
margin-bottom: 0;

tr:first-of-type td {
padding-top: 0;
}
tr {
&:first-of-type td {
padding-top: 0;
}

tr:last-of-type td {
border-bottom: 0;
padding-bottom: 0;
&:last-of-type td {
border-bottom: 0;
padding-bottom: 0;
}

td:first-of-type {
padding-left: 0;
}

td:last-of-type {
padding-right: 0;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/responsibilities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def groups_options(resp_or_category)
options_for_select groups
end

def paginate
super(order_params[:column] == 'group' ? @responsibilities : @categories)
def order_by_group?
order_params[:column] == 'group'
end

private
Expand Down
26 changes: 26 additions & 0 deletions app/views/responsibilities/_category.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<tr>
<td><%= category.kind_name %></td>
<td><%= category %></td>
<td colspan="2">
<table class="table inner-table">
<% active_responsibilities(category).find_each do |responsibility| -%>
<tr>
<td title="<%= responsibility.group.logging_subject_name %>">
<%= responsibility.group %>
</td>
<td class="text-end">
<%= render partial: 'responsibility_actions', object: responsibility, as: :responsibility %>
</td>
</tr>
<% end -%>
<% if Current.user.role_admin? || active_responsibilities(category).blank? -%>
<tr>
<td colspan="2" class="text-end">
<%= link_to tag.i('', class: 'fa fa-plus'), new_category_responsibility_path(category),
remote: true, class: 'btn btn-sm btn-outline-primary' %>
</td>
</tr>
<% end -%>
</table>
</td>
</tr>
8 changes: 8 additions & 0 deletions app/views/responsibilities/_responsibility.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<tr>
<td><%= responsibility.category.kind_name %></td>
<td><%= responsibility.category %></td>
<td title="<%= responsibility.group.logging_subject_name %>"><%= responsibility.group %></td>
<td class="text-nowrap">
<%= render partial: 'responsibility_actions', object: responsibility, as: :responsibility %>
</td>
</tr>
5 changes: 5 additions & 0 deletions app/views/responsibilities/_responsibility_actions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%= link_to tag.i('', class: 'fa fa-pencil'), edit_responsibility_path(responsibility),
remote: true, class: 'btn btn-sm btn-outline-primary' %>
<%= link_to tag.i('', class: 'fa fa-trash'), responsibility_path(responsibility),
method: :delete, class: 'btn btn-sm btn-outline-danger',
data: { confirm: t('responsibilities.index.confirm_delete') } %>
32 changes: 0 additions & 32 deletions app/views/responsibilities/_result_list_by_category.html.erb

This file was deleted.

15 changes: 0 additions & 15 deletions app/views/responsibilities/_result_list_by_group.html.erb

This file was deleted.

10 changes: 7 additions & 3 deletions app/views/responsibilities/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1><%= Responsibility.model_name.human count: 2 %></h1>

<%= render partial: 'simple_text_filter' %>
<%= paginate %>
<%= paginate order_by_group? ? @responsibilities : @categories %>

<table class="table">
<thead>
Expand All @@ -13,11 +13,15 @@
</tr>
</thead>
<tbody>
<%= render partial: order_by_group? ? 'result_list_by_group' : 'result_list_by_category' %>
<% if order_by_group? -%>
<%= render partial: 'responsibility', collection: @responsibilities %>
<% else -%>
<%= render partial: 'category', collection: @categories %>
<% end -%>
</tbody>
</table>

<%= paginate %>
<%= paginate order_by_group? ? @responsibilities : @categories %>

<% content_for :footer do %>
<div class="float-end">
Expand Down

0 comments on commit 1cb75c7

Please sign in to comment.