improves admin moderators views

This commit is contained in:
decabeza
2017-10-25 18:43:19 +02:00
parent 1e49265288
commit 0f4c03e407
3 changed files with 80 additions and 66 deletions

View File

@@ -5,48 +5,48 @@
<%= render 'admin/shared/user_search', url: search_admin_moderators_path %>
<div id="moderators">
<% if @moderators.any? %>
<h3 class="margin"><%= page_entries_info @moderators %></h3>
<% if @moderators.any? %>
<h3 class="margin"><%= page_entries_info @moderators %></h3>
<table>
<thead>
<th scope="col"><%= t("admin.moderators.index.name") %></th>
<th scope="col" class="small-6"><%= t("admin.moderators.index.email") %></th>
<th scope="col" class="small-3"><%= t("admin.shared.actions") %></th>
</thead>
<tbody>
<% @moderators.each do |moderator| %>
<tr>
<td>
<%= moderator.name %>
</td>
<td>
<%= moderator.email %>
</td>
<td>
<% if moderator.persisted? %>
<%= link_to t('admin.moderators.moderator.delete'),
admin_moderator_path(moderator),
method: :delete,
class: "button hollow alert expanded"
%>
<% else %>
<%= link_to t('admin.moderators.moderator.add'),
{ controller: "admin/moderators", action: :create,
user_id: moderator.user_id },
method: :post,
class: "button success expanded" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<table>
<thead>
<th scope="col"><%= t("admin.moderators.index.name") %></th>
<th scope="col" class="small-6"><%= t("admin.moderators.index.email") %></th>
<th scope="col" class="small-3"><%= t("admin.shared.actions") %></th>
</thead>
<tbody>
<% @moderators.each do |moderator| %>
<tr>
<td>
<%= moderator.name %>
</td>
<td>
<%= moderator.email %>
</td>
<td>
<% if moderator.persisted? %>
<%= link_to t('admin.moderators.moderator.delete'),
admin_moderator_path(moderator),
method: :delete,
class: "button hollow alert expanded"
%>
<% else %>
<%= link_to t('admin.moderators.moderator.add'),
{ controller: "admin/moderators", action: :create,
user_id: moderator.user_id },
method: :post,
class: "button success expanded" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @moderators %>
<% else %>
<div class="callout primary">
<%= t("admin.moderators.index.no_moderators") %>
</div>
<% end %>
<%= paginate @moderators %>
<% else %>
<div class="callout primary">
<%= t("admin.moderators.index.no_moderators") %>
</div>
<% end %>
</div>

View File

@@ -2,28 +2,42 @@
<%= render 'admin/shared/user_search', url: search_admin_moderators_path %>
<h3><%= page_entries_info @users %></h3>
<div id="moderators">
<% if @users.any? %>
<h3 class="margin"><%= page_entries_info @users %></h3>
<table id="moderators">
<% @users.each do |user| %>
<tr>
<td><%= user.name %></td>
<td><%= user.email %></td>
<td class="text-right">
<% if user.moderator? && user.moderator.persisted? %>
<%= link_to t('admin.moderators.moderator.delete'),
admin_moderator_path(user),
method: :delete,
class: "button hollow alert" %>
<% else %>
<%= link_to t('admin.moderators.moderator.add'),
{ controller: "admin/moderators",
action: :create,
user_id: user },
method: :post,
class: "button success" %>
<% end %>
</td>
</tr>
<table id="moderators">
<thead>
<th scope="col"><%= t("admin.moderators.index.name") %></th>
<th scope="col" class="small-6"><%= t("admin.moderators.index.email") %></th>
<th scope="col" class="small-3"><%= t("admin.shared.actions") %></th>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= user.name %></td>
<td><%= user.email %></td>
<td class="text-right">
<% if user.moderator? && user.moderator.persisted? %>
<%= link_to t('admin.moderators.moderator.delete'),
admin_moderator_path(user),
method: :delete,
class: "button hollow alert" %>
<% else %>
<%= link_to t('admin.moderators.moderator.add'),
{ controller: "admin/moderators",
action: :create,
user_id: user },
method: :post,
class: "button success" %>
<% end %>
</td>
</tr>
<% end %>
</table>
<% else %>
<div class="callout alert margin">
<%= t("admin.shared.no_search_results") %>
</div>
<% end %>
</table>
</div>

View File

@@ -52,7 +52,7 @@ feature 'Admin moderators' do
click_button 'Search'
expect(page).to have_content('Moderators: User search')
expect(page).to have_content('users cannot be found')
expect(page).to have_content('No results found')
expect(page).to_not have_content(@moderator1.name)
expect(page).to_not have_content(@moderator2.name)
end