Skip to content

Commit

Permalink
Display Staff ID on site pages in the directory, closes #18.
Browse files Browse the repository at this point in the history
  • Loading branch information
remomueller committed Sep 26, 2019
1 parent aa58d91 commit a9fc81d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- Reduced size of folder names in documents sidebar
- Admins can now set keywords for documents to improve search results for
documents
- **Site Changes**
- Display Staff ID on site pages in the directory
- **User Changes**
- Admins can now associate a Staff ID with a user that will display in the
directory and in the menu bar
Expand Down
9 changes: 6 additions & 3 deletions app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ def coordinating_centers
@sites = scope_order(scope).page(params[:page]).per(20)
end

# # GET /sites/1
# def show
# end
# GET /sites/1
def show
@users = @site.users
.order(Arel.sql(User::ORDERS[params[:order]] || "users.staffid"))
.page(params[:page]).per(40)
end

# GET /sites/new
def new
Expand Down
10 changes: 9 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ class User < ApplicationRecord
ORDERS = {
"activity desc" => "(CASE WHEN (users.current_sign_in_at IS NULL) THEN users.created_at ELSE users.current_sign_in_at END) desc",
"activity" => "(CASE WHEN (users.current_sign_in_at IS NULL) THEN users.created_at ELSE users.current_sign_in_at END)",
"email desc" => "users.email desc",
"email" => "users.email",
"logins desc" => "users.sign_in_count desc",
"logins" => "users.sign_in_count"
"logins" => "users.sign_in_count",
"name desc" => "users.full_name desc",
"name" => "users.full_name",
"role desc" => "users.role desc",
"role" => "users.role",
"staffid desc" => "users.staffid desc",
"staffid" => "users.staffid"
}
DEFAULT_ORDER = "(CASE WHEN (users.current_sign_in_at IS NULL) THEN users.created_at ELSE users.current_sign_in_at END) desc"

Expand Down
16 changes: 10 additions & 6 deletions app/views/sites/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,28 @@
= @site.name
Members

- if @site.users.present?
- if @users.present?
.dashboard-container.dashboard-table
%table.table.table-striped.table-borderless.table-hover.table-sticky
%col.d-none.d-lg-table-column{ width: "1px" }
%col
%col
%col.d-none.d-md-table-column
%thead
%tr
%th Name
%th Email
%th.d-none.d-md-table-cell Role
%th.d-none.d-lg-table-cell.text-center.nowrap= order_to "Staff ID", primary: "staffid"
%th= order_to "Name", primary: "name"
%th= order_to "Email", primary: "email"
%th.d-none.d-md-table-cell= order_to "Role", primary: "role"

- @site.users.each do |user|
- @users.each do |user|
%tr
%td.d-none.d-lg-table-cell.nowrap.text-center
%small= user.staffid
%td= user.full_name
%td= user.email
%td.d-none.d-md-table-cell= user.role

.center-horizontally= paginate @users, theme: "bootstrap"
.jumbotron.jumbotron-custom-text.jumbotron-shadow
= icon("far", "comments")
= mail_to ActionMailer::Base.smtp_settings[:email], "Contact us"
Expand Down

0 comments on commit a9fc81d

Please sign in to comment.