[deploy] Add Recent Vomit Reaction Reports to Users' Admin Users Page (#10059)
* Capitalizes Admin on Admin Profile button for better consistency * Adds reactions and reports partials and adjusts filenames of _notes, _activity, and _credits * Removes code related to reports to separate this PR and the reports PR * Adds ability to toggle Recent Reactions and adds #get_related_reactions to controller - Adds a #get_related_reactions method to the Admin::Users::Controller - Moves the rendering of the reactions partial below the notes partial in edit - Styles Recent Reactions in a list format with the ability to toggle * Modifies #set_related_reactions name, query, and limit and the _reactions view with it - Adjust #get_related_reactions to read #set_related_reactions - Sort reactions by descending created_at - Add a limit of 15 to reactions displayed for any given user - Add .empty? in place of .nil? to _reactions.html.erb reaction check * Adjusts the format of how Recent Reactions are displayed and adds Reaction category * Adds a check for category: vomit in #set_related_reactions * Renames partial, adds User reactions to #set_related_reactions, and adjusts partial styling * Rewords message displayed when no negative reactions exist to make it fun * Adds additional styling changes to recent reactions
This commit is contained in:
parent
0ea843cf50
commit
92042333bd
8 changed files with 63 additions and 33 deletions
|
|
@ -15,6 +15,7 @@ module Admin
|
|||
def edit
|
||||
@user = User.find(params[:id])
|
||||
@notes = @user.notes.order(created_at: :desc).limit(10).load
|
||||
set_related_reactions
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
@ -170,6 +171,17 @@ module Admin
|
|||
Credit.remove_from(org, amount)
|
||||
end
|
||||
|
||||
def set_related_reactions
|
||||
user_article_ids = @user.articles.ids
|
||||
user_comment_ids = @user.comments.ids
|
||||
@related_vomit_reactions = Reaction.where(reactable_type: "Comment", reactable_id: user_comment_ids,
|
||||
category: "vomit")
|
||||
.or(Reaction.where(reactable_type: "Article", reactable_id: user_article_ids, category: "vomit"))
|
||||
.or(Reaction.where(reactable_type: "User", user_id: @user.id, category: "vomit"))
|
||||
.includes(:reactable)
|
||||
.order(created_at: :desc).limit(15)
|
||||
end
|
||||
|
||||
def user_params
|
||||
allowed_params = %i[
|
||||
new_note note_for_current_role user_status
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
<div class="crayons-card p-6">
|
||||
<div class="grid grid-cols-2">
|
||||
<div>
|
||||
<h2>Activity</h2>
|
||||
<ul>
|
||||
<li><%= @user.comments_count %> comments</li>
|
||||
<li><%= @user.articles_count %> articles</li>
|
||||
<li><%= @user.reactions_count %> reactions</li>
|
||||
<li><%= @user.followers_count %> followers</li>
|
||||
<li><%= @user.following_users_count %> users following</li>
|
||||
<li><%= @user.badge_achievements_count %> badges</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Current Roles</h2>
|
||||
<p>(view full history in notes below)</p>
|
||||
<ul>
|
||||
<% @user.roles.each do |role| %>
|
||||
<li><%= role.name %> <em><%= "- " + Tag.find(role.resource_id).name if role.resource_id.present? %></em></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
22
app/views/admin/users/_activity.html.erb
Normal file
22
app/views/admin/users/_activity.html.erb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<h2>Activity</h2>
|
||||
<ul>
|
||||
<li><%= @user.comments_count %> comments</li>
|
||||
<li><%= @user.articles_count %> articles</li>
|
||||
<li><%= @user.reactions_count %> reactions</li>
|
||||
<li><%= @user.followers_count %> followers</li>
|
||||
<li><%= @user.following_users_count %> users following</li>
|
||||
<li><%= @user.badge_achievements_count %> badges</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<h2>Current Roles</h2>
|
||||
<p>(view full history in notes below)</p>
|
||||
<ul>
|
||||
<% @user.roles.each do |role| %>
|
||||
<li><%= role.name %> <em><%= "- #{Tag.find(role.resource_id).name}" if role.resource_id.present? %></em></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
21
app/views/admin/users/_negative_reactions.html.erb
Normal file
21
app/views/admin/users/_negative_reactions.html.erb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<div class="row my-3">
|
||||
<div class="col-12">
|
||||
<h2 class="d-inline">Recent Reactions</h2>
|
||||
<button type="button" data-toggle="collapse" data-target="#reactions-row" class="btn btn-secondary float-right">Toggle</button>
|
||||
</div>
|
||||
<div class="col-12 collapse" id="reactions-row">
|
||||
<div class="list-group-flush">
|
||||
<% unless @related_vomit_reactions.empty? %>
|
||||
<% @related_vomit_reactions.each do |reaction| %>
|
||||
<a href="<%= reaction.reactable.path %>" class="list-group-item list-group-item-action px-5 d-flex justify-content-between">
|
||||
<span>🤢 <%= reaction.category.capitalize %></span>
|
||||
<span><strong><%= reaction.reactable_type %></strong><%= reaction.reactable_type == "User" ? "" : ": #{reaction.reactable.title}" %></span>
|
||||
<em><%= reaction.created_at&.strftime("%b %e '%y") %></em>
|
||||
</a>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p><em>Nothing negative to see here! 👀</em></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<%= link_to "Unlock access", unlock_access_admin_user_path(@user), method: :patch, class: "btn btn-success" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<a href="<%= admin_user_path(@user) %>" class="btn btn-primary float-right">admin Profile</a>
|
||||
<a href="<%= admin_user_path(@user) %>" class="btn btn-primary float-right">Admin Profile</a>
|
||||
<p class="font-italic">Member since <%= @user.created_at.strftime("%b %e '%y") %></p>
|
||||
</div>
|
||||
|
||||
|
|
@ -47,7 +47,8 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= render "notes" %>
|
||||
<%= render "notes" %>
|
||||
<%= render "negative_reactions" %>
|
||||
|
||||
<div class="crayons-card p-6">
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -35,10 +35,8 @@
|
|||
</dl>
|
||||
</div>
|
||||
|
||||
<%= render "activity" %>
|
||||
<%= render "credits" %>
|
||||
<%= render "notes" %>
|
||||
<%= render "user_organizations" %>
|
||||
<%= render "email_tools" %>
|
||||
|
||||
</div>
|
||||
<%= render "activity" %>
|
||||
<%= render "credits" %>
|
||||
<%= render "notes" %>
|
||||
<%= render "user_organizations" %>
|
||||
<%= render "email_tools" %>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue