docbrown/app/views/admin/users/_credits.html.erb
Julianna Tetreault 92042333bd
[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
2020-08-31 11:23:19 -04:00

47 lines
2.7 KiB
Text

<div class="crayons-card p-6 grid gap-6">
<h2>Credits</h2>
<div>
<h4 class="mt-3"><%= @user.username %></h4>
<% current_credits = @user.unspent_credits_count %>
<p>Available User Credits: <%= current_credits %></p>
<%= form_with scope: :user, url: admin_user_path(@user), method: :patch, local: true, html: { class: "form-inline justify-content-between mb-2" } do |f| %>
<div class="form-group">
<%= f.number_field :add_credits, in: 1...10_000, required: true, class: "form-control mr-3", size: 5 %>
<%= f.text_field :new_note, placeholder: "Why are you adding these credits?", size: 50, required: true, class: "form-control" %>
</div>
<%= f.submit "Add Credits", class: "btn btn-primary" %>
<% end %>
<% if current_credits.positive? %>
<%= form_with scope: :user, url: admin_user_path(@user), method: :patch, local: true, html: { class: "form-inline justify-content-between mb-2" } do |f| %>
<div class="form-group">
<%= f.number_field :remove_credits, in: 1..current_credits, required: true, class: "form-control mr-3", size: 5 %>
<%= f.text_field :new_note, placeholder: "Why are you removing these credits?", size: 50, required: true, class: "form-control" %>
</div>
<%= f.submit "Remove Credits", class: "btn btn-danger" %>
<% end %>
<% end %>
</div>
<% if @organizations.present? %>
<div>
<h4>Organizations</h4>
<%= form_with scope: :user, url: admin_user_path(@user), method: :patch, local: true, html: { class: "form-inline justify-content-between mb-2" } do |f| %>
<div class="form-group">
<%= f.number_field :add_org_credits, in: 1...10_000, required: true, class: "form-control mr-3", size: 5 %>
<%= f.text_field :new_note, placeholder: "Why are you adding these credits?", size: 50, required: true, class: "form-control mr-3" %>
<%= f.select :organization_id, orgs_with_credits(@organizations), {}, { class: "form-control" } %>
</div>
<%= f.submit "Add Org Credits", class: "btn btn-primary" %>
<% end %>
<%= form_with scope: :user, url: admin_user_path(@user), method: :patch, local: true, html: { class: "form-inline justify-content-between mb-2" } do |f| %>
<div class="form-group">
<%= f.number_field :remove_org_credits, in: 1...10_000, required: true, class: "form-control mr-3", size: 5 %>
<%= f.text_field :new_note, placeholder: "Why are you removing these credits?", size: 50, required: true, class: "form-control mr-3" %>
<%= f.select :organization_id, orgs_with_credits(@organizations), {}, { class: "form-control" } %>
</div>
<%= f.submit "Remove Org Credits", class: "btn btn-danger" %>
<% end %>
</div>
<% end %>
</div>