docbrown/app/views/internal/users/_credits.erb
rhymes b94dea9b70
Upgrade erb_lint to support latest Rubocop and fix violations (#9663)
* Upgrade erb_lint to support latest Rubocop and fix violations

* Wrong template name
2020-08-07 15:36:48 +02:00

48 lines
2.8 KiB
Text

<div class="row">
<div class="col-12">
<h2>Credits</h2>
<hr>
<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: internal_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: internal_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 %>
<hr>
</div>
<% if @organizations.present? %>
<div class="col-12">
<h4>Organizations</h4>
<%= form_with scope: :user, url: internal_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: internal_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 %>
<hr>
</div>
<% end %>
</div>