From a9fc81de4a396ff778ca9c6d72df6335b66c9543 Mon Sep 17 00:00:00 2001 From: Remo Mueller Date: Thu, 26 Sep 2019 19:35:35 -0400 Subject: [PATCH] Display Staff ID on site pages in the directory, closes #18. --- CHANGELOG.md | 2 ++ app/controllers/sites_controller.rb | 9 ++++++--- app/models/user.rb | 10 +++++++++- app/views/sites/show.html.haml | 16 ++++++++++------ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24c535d..4745aaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 5050f29..20ecdf9 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 53dc5f3..c572110 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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" diff --git a/app/views/sites/show.html.haml b/app/views/sites/show.html.haml index 7ff20fc..8cea9a2 100644 --- a/app/views/sites/show.html.haml +++ b/app/views/sites/show.html.haml @@ -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"