This repository was archived by the owner on Jun 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add user management to Admin dashboard
- Loading branch information
Showing
14 changed files
with
347 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$("#<%=@row_id%>").replaceWith("<%= escape_javascript(render 'users/user_row', { user: @user }) %>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class="row justify-content-center m-2"> | ||
<div class="col pt-3"> | ||
<%= paginate @users %> | ||
</div> | ||
<%= search_form_for @q, url: administrate_users_path, html: { class: "form-inline col-8" } do |f| %> | ||
<%= f.search_field :email_or_nickname_cont, class: "form-control col-10", placeholder: "Search..." %> | ||
<%= f.submit "Search", class: "btn btn-outline-success" %> | ||
<% end %> | ||
</div> | ||
<%= render "users/users_list", users: @users %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% flash.each do |key, value| %> | ||
<div class="alert alert-light alert-<%= key %> alert-dismissible fade show" role="alert"> | ||
<%= value %> | ||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<% row_id = "user_row_#{user.id}" %> | ||
<tr id="<%= row_id %>"> | ||
<td><%= user.nickname %></td> | ||
<td><%= user.email %></td> | ||
<td> | ||
<% user.roles.each do |role| %> | ||
<div class="btn-group" role="group" aria-label="Button group with nested dropdown"> | ||
<%= @q.present? ? link_to(role.name, url_for(only_path: false, q: { roles_name_eq: role.name }), | ||
class: "btn btn-sm btn-info") : content_tag(:span, role.name, class: "btn btn-sm btn-info") %> | ||
<% if policy(:administrate).access? %> | ||
<%= link_to "", remove_user_role_path(id: user.id, role_id: role.id, row_id: row_id ), class: "btn btn-sm btn-danger fa fa-close", remote: true, method: :put %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</td> | ||
<td class="d-flex align-items-center justify-content-around"> | ||
<% if policy(:administrate).access? %> | ||
<div class="btn-group"> | ||
<%= content_tag :button, "Assign role", class: "btn btn-outline-info dropdown-toggle", data: { toggle: "dropdown" }, aria: { haspopup: "true", expanded: "false" } %> | ||
<div class="dropdown-menu"> | ||
<%= link_to "Admin", make_user_admin_path(id: user.id, row_id: row_id), class: "dropdown-item", remote: true, method: :put %> | ||
<%= link_to "Moderator", make_user_moderator_path(id: user.id, row_id: row_id), class: "dropdown-item", remote: true, method: :put %> | ||
<%= link_to "Editor", make_user_editor_path(id: user.id, row_id: row_id), class: "dropdown-item", remote: true, method: :put %> | ||
<%= link_to "Contributor", make_user_contributor_path(id: user.id, row_id: row_id), class: "dropdown-item", remote: true, method: :put %> | ||
<%= link_to "Banned", ban_user_path(id: user.id, row_id: row_id), class: "dropdown-item", remote: true, method: :put %> | ||
</div> | ||
</div> | ||
<% end %> | ||
</td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<table class="table"> | ||
<thead class="thead-default"> | ||
<tr> | ||
<th><%= @q.present? ? sort_link(@q, :nickname, 'Nickname') : "Nickname" %></th> | ||
<th><%= @q.present? ? sort_link(@q, :email, 'Email') : "Email" %></th> | ||
<th>Roles</th> | ||
<th ><i class="fa fa-cogs"></i> Modify</th> | ||
</tr> | ||
</thead> | ||
<tbody > | ||
<% users.each do |user| %> | ||
<%= render "users/user_row", user: user %> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,47 @@ | ||
<h2>Edit <%= resource_name.to_s.humanize %></h2> | ||
<div class="card"> | ||
<div class="card-header "> | ||
<ul class="nav nav-pills row card-header-pills"> | ||
<div class="col nav"> | ||
<li class="nav-item"> | ||
<%= link_to "Profile", user_profile_path, class: "nav-link" %> | ||
</li> | ||
<li class="nav-item"> | ||
<%= link_to "Edit information", edit_user_registration_path, class: "nav-link active" %> | ||
</li> | ||
<li class="nav-item"> | ||
<%= link_to "Notifications", notifications_path, class: "nav-link" %> | ||
</li> | ||
</div> | ||
</ul> | ||
</div> | ||
|
||
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> | ||
<%= f.error_notification %> | ||
<div class="card-body"> | ||
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> | ||
<%= f.error_notification %> | ||
|
||
<div class="form-inputs"> | ||
<%= f.input :email, required: true, autofocus: true %> | ||
<div class="form-inputs"> | ||
<%= f.input :email, required: true, autofocus: true %> | ||
|
||
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> | ||
<p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p> | ||
<% end %> | ||
<%= f.input :first_name, required: true %> | ||
<%= f.input :last_name, required: true %> | ||
<%= f.input :nickname, required: true %> | ||
<%= f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false %> | ||
<%= f.input :password_confirmation, required: false %> | ||
<%= f.input :current_password, hint: "we need your current password to confirm your changes", required: true %> | ||
</div> | ||
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> | ||
<p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p> | ||
<% end %> | ||
<%= f.input :first_name, required: true %> | ||
<%= f.input :last_name, required: true %> | ||
<%= f.input :nickname, required: true %> | ||
<%= f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false %> | ||
<%= f.input :password_confirmation, required: false %> | ||
<%= f.input :current_password, hint: "we need your current password to confirm your changes", required: true %> | ||
</div> | ||
|
||
<div class="form-actions"> | ||
<%= f.button :submit, "Update" %> | ||
</div> | ||
<% end %> | ||
<div class="form-actions"> | ||
<%= f.button :submit, "Update" %> | ||
</div> | ||
<% end %> | ||
|
||
<h3>Cancel my account</h3> | ||
<h3>Cancel my account</h3> | ||
|
||
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p> | ||
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p> | ||
|
||
<%= link_to "Back", :back %> | ||
<%= link_to "Back", :back %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.