Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<%= errors_summary_for user %>
<%= bootstrap_form_with model: [:admin, user], local: true, html: { autocorrect: :off, autocapitalize: :none, autocomplete: :off, spellcheck: false } do |form| %>
<%= form.email_field :email %>
<%# autocomplete: 'new-password' prevent the existing password value from showing up %>
<%= form.password_field :password, autocomplete: "new-password" %>
<% if user.new_record? %>
<%= form.collection_select :account_id, accounts, :id, :name, { prompt: "Select an Account", required: true }, class: "form-control custom-select" %>
<%= form.select :role, options_for_role_select, {}, class: "form-control custom-select" %>
<% end %>
<div class="mb-4">
<%= form.check_box :admin, label: "Admin User" %>
<div class="help-block text-muted"><%= fa_icon :warning, text: "This option grants access to the Admin dashboard. This should only be for trusted BiG employees." %></div>
</div>
<div class="row align-items-center text-center mt-4">
<%= link_to t("shared.cancel"), [:admin, :users], class: "col-3 text-reset" %>
<div class="col-9">
<%= form.button class: class_string("btn btn-block", ["btn-success", "btn-primary"] => user.new_record?), data: { disable_with: t("shared.disable_with") } %>
</div>
</div>
<% end %>

View File

@@ -0,0 +1,32 @@
<tr id="<%= dom_id(user) %>">
<td>
<%= user.email %>
</td>
<td>
<%= user.first_name %>
</td>
<td>
<%= user.last_name %>
</td>
<td>
<%= user.account_auths.map(&:role).compact.join(",") %>
</td>
<td>
<%= user.accounts.map(&:name).join(",") %>
</td>
<td>
<%= time_ago_in_words(user.created_at) %> ago
</td>
<td class="text-right">
<% if user != Current.user %>
<div class="btn-group">
<%= button_tag "Manage", class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %>
<div class="dropdown-menu dropdown-menu-right">
<%= link_to fa_icon("user-secret", text: "Masquerade"), [:admin, user, :masquerade], method: :post, class: "dropdown-item" %>
<%= link_to fa_icon("pencil", text: "Edit"), [:edit, :admin, user], class: "dropdown-item" %>
<%= link_to fa_icon("trash", text: "Delete"), [:admin, user], class: "dropdown-item", remote: true, method: :delete, data: { confirm: "Are you sure?" } %>
</div>
</div>
<% end %>
</td>
</tr>

View File

@@ -0,0 +1,6 @@
<div class="card shadow-sm">
<%= card_header text: "Edit User", close_action_path: [:admin, :users] %>
<div class="card-body">
<%= render "form", user: @user, accounts: @accounts %>
</div>
</div>

View File

@@ -0,0 +1,34 @@
<div class="d-flex flex-row justify-content-between align-items-center mb-3">
<% if policy(User).new? %>
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, :admin, :user], class: "btn btn-primary mb-3" %>
<% end %>
<%= bootstrap_form_with url: admin_users_path, method: :get, remote: true, layout: :inline, id: "search" do |form| %>
<%= form.search_field :query, hide_label: true, placeholder: t(".actions.search"), class: "rounded-pill-right", value: params[:query], prepend: form.button(fa_icon("search"), class: "btn btn-light border rounded-pill-left") %>
<% end %>
</div>
<div class="border bg-white rounded shadow-sm pb-3 table-responsive">
<table class="table table-striped tr-px-4 align-all-middle">
<thead class="thead-light">
<tr>
<th>Email</th>
<th>First Name</th>
<th>Last Name</th>
<th>Role</th>
<th>Account Name</th>
<th>Created At</th>
<th></th>
</tr>
</thead>
<tbody id="users">
<% if @users.any? %>
<%= render @users %>
<% else %>
<tr>
<td colspan="5" class="py-4 text-center text-muted"><%= t(".empty") %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -0,0 +1,2 @@
$("#users").html("<%= j render(@users) %>");
$("form input[type='search']").val("<%= params[:query] %>");

View File

@@ -0,0 +1,6 @@
<div class="card shadow-sm">
<%= card_header text: "New User", close_action_path: [:admin, :users] %>
<div class="card-body">
<%= render "form", user: @user, accounts: @accounts %>
</div>
</div>