Add sdg manager section to admin
Allow a user to become an sdg manager
This commit is contained in:
13
app/components/admin/header.rb
Normal file
13
app/components/admin/header.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module Admin::Header
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def header(options: {})
|
||||
provide(:title) do
|
||||
title
|
||||
end
|
||||
|
||||
tag.h2 options do
|
||||
title
|
||||
end
|
||||
end
|
||||
end
|
||||
38
app/components/admin/sdg/managers/index_component.html.erb
Normal file
38
app/components/admin/sdg/managers/index_component.html.erb
Normal file
@@ -0,0 +1,38 @@
|
||||
<%= header %>
|
||||
|
||||
<%= render "admin/shared/user_search", url: admin_sdg_managers_path %>
|
||||
|
||||
<div id="sdg_managers">
|
||||
<% if users.any? %>
|
||||
<h3 class="margin"><%= page_entries_info users %></h3>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<th scope="col"><%= SDG::Manager.human_attribute_name(:name) %></th>
|
||||
<th scope="col"><%= SDG::Manager.human_attribute_name(:email) %></th>
|
||||
<th scope="col"><%= t("admin.shared.actions") %></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% users.each do |user| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= user.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= user.email %>
|
||||
</td>
|
||||
<td>
|
||||
<%= render Admin::Roles::TableActionsComponent.new(user.sdg_manager || user.build_sdg_manager) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= paginate users %>
|
||||
<% else %>
|
||||
<div class="callout primary">
|
||||
<%= t("admin.sdg_managers.index.no_sdg_managers") %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
15
app/components/admin/sdg/managers/index_component.rb
Normal file
15
app/components/admin/sdg/managers/index_component.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class Admin::SDG::Managers::IndexComponent < ApplicationComponent
|
||||
include Admin::Header
|
||||
|
||||
attr_reader :users
|
||||
|
||||
def initialize(users)
|
||||
@users = users
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def title
|
||||
SDG::Manager.model_name.human(count: 2).upcase_first
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user