ucb_rails_user 8.0.1 → 8.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8aab55213380e77313f71f4e8a439334bdade52baa590b11aa32e859796f584d
4
- data.tar.gz: 943419859c81c14f8dd5e48669434a0d3ffda66736211f4c267f765e8f7a9145
3
+ metadata.gz: c7dfe2bed6cddf061bb3792211ef87bf6c09aa4de9a71b1896aefe3d3b2cd5fe
4
+ data.tar.gz: c91dc9d3272bcbfa11ea36c55f3fc20dacaa97bbf845980bd8686fa31ed2df86
5
5
  SHA512:
6
- metadata.gz: e080941d597aaebb80b000e50fb7f2d33bb8d3c9ca7fed0beb0076529dc59d71efc19101e3d778f3c657437fd0f25774ca2732e9ba0ad4cf9030610abc60a143
7
- data.tar.gz: bef13c188932aebf937fccdccbad826770c532f016c8abea87d7f1978a5e4eb286fd22b46c090d2e5159494ab57a63864ed3c162b2b161e9a4071c35df852ef5
6
+ metadata.gz: a8d53e14084804c70c9f45d0047d1bbc42675119152f13e8ad623c71a1bc794bc8c1ec12a87a4eae7e85a59d0e33d8acc972612e9552bd3b098df731ef784f3f
7
+ data.tar.gz: d617d72f9956670b894e91268e9574410a00413db4e0b1e1873bd980a928173f8a2a8dc8334e8d9d3de6d7a02a3220859f9f1c8e1ef4abc5fae22d6308a3cb28
data/README.md CHANGED
@@ -89,7 +89,23 @@ And in `application.js` add this line:
89
89
  //= require ucb_rails_user/scripts
90
90
  ```
91
91
 
92
- 9. Restart your host app as usual
92
+ 9. Enable Turbo (required for admin user search functionality)
93
+
94
+ The admin user search uses Turbo Frames for seamless searching without page reloads. Add this to your application layout (typically `app/views/layouts/application.html.erb`):
95
+
96
+ ```erb
97
+ <%= turbo_include_tags %>
98
+ ```
99
+
100
+ Also update any `data-turbolinks-track` attributes to use `data-turbo-track` instead:
101
+
102
+ ```erb
103
+ <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
104
+ ```
105
+
106
+ If your app doesn't already include Turbo, make sure the `turbo-rails` gem is in your Gemfile (it's included as a dependency of this gem).
107
+
108
+ 10. Restart your host app as usual
93
109
 
94
110
  You should be able to access the following routes:
95
111
 
@@ -290,3 +306,5 @@ There is a new session timeout gem that can be used as well. It has a nice Javas
290
306
  ## Version 8+
291
307
 
292
308
  This version removes both the emailing setup functionality as well as the error reporting functionality. Those are both in the [UcbRailsDefaults] (https://gitlab.com/ucb-bit/cad/aa/ucb_rails_defaults) gem. This gem's dependencies have been slimmed down so that only the basics to run the gem are required. This makes it easier to upgrade the including apps.
309
+
310
+ Versions 8.0.x use the new standard of Turbo, importmaps, and propshaft. The 8.0.x versions do not have the latest CAS upgrades in them and are used for Rails 8 apps that are in maintenance mode.
@@ -1,13 +1,26 @@
1
1
  .ucb-rails-users-table-header {
2
2
  margin-top: 16px;
3
- margin-bottom: 16px; }
3
+ margin-bottom: 8px; }
4
4
 
5
5
  .ucb-rails-users-table-header a {
6
- margin-top: 16px; }
6
+ margin-top: 0px; }
7
+
8
+ .ucb-rails-users-table-header form {
9
+ display: flex !important;
10
+ gap: 15px;
11
+ align-items: center;
12
+ flex-direction: row;
13
+ }
14
+
15
+ .ucb-rails-users-table-header form span,
16
+ .ucb-rails-users-table-header form select,
17
+ .ucb-rails-users-table-header form input {
18
+ vertical-align: middle;
19
+ }
7
20
 
8
21
  table.ucb-rails-users-table {
9
22
  border-spacing: 0px;
10
- margin-top: 16px;
23
+ margin-top: 8px;
11
24
  }
12
25
 
13
26
  table.ucb-rails-users-table th {
@@ -9,7 +9,20 @@ module UcbRailsUser::UsersControllerConcerns
9
9
  end
10
10
 
11
11
  def index
12
- @pagy, @users = pagy(UcbRailsUser.user_class.all, limit: params[:count])
12
+ @sort = params[:sort] || "last_name"
13
+ @sort_dir = params[:dir] || "asc"
14
+
15
+ # Build the query
16
+ users = if !params[:query].blank?
17
+ search_user_table(params[:query])
18
+ else
19
+ UcbRailsUser.user_class.all
20
+ end
21
+
22
+ # Apply sorting
23
+ users = users.order("#{@sort} #{@sort_dir}")
24
+
25
+ @pagy, @users = pagy(users, limit: params[:count])
13
26
  end
14
27
 
15
28
  def search
@@ -91,7 +104,6 @@ module UcbRailsUser::UsersControllerConcerns
91
104
  @lps_existing_uids = UcbRailsUser.user_class.where(ldap_uid: uid_strings).pluck(:uid)
92
105
  render 'ucb_rails_user/lps/search'
93
106
  end
94
-
95
107
  end
96
108
 
97
109
  def typeahead_search
@@ -111,6 +123,11 @@ module UcbRailsUser::UsersControllerConcerns
111
123
 
112
124
  private
113
125
 
126
+ def search_user_table(query)
127
+ UcbRailsUser.user_class.where('lower(first_name) like lower(:q) or lower(last_name) like lower(:q) or ldap_uid like :q or employee_id like :q',
128
+ q: '%' + query + '%')
129
+ end
130
+
114
131
  def user_params(extra_params = [])
115
132
  params.require(:user).permit([
116
133
  :superuser_flag,
@@ -130,5 +147,4 @@ module UcbRailsUser::UsersControllerConcerns
130
147
  def find_user
131
148
  @user ||= UcbRailsUser.user_class.find(params.fetch(:id))
132
149
  end
133
-
134
150
  end
@@ -1,4 +1,3 @@
1
- <%= turbo_frame_tag "users" do %>
2
1
  <tr id="user_<%=user.id%>" class="user">
3
2
  <td><%= checkmark(user.superuser?) %></td>
4
3
  <td><%= checkmark(user.inactive?) %></td>
@@ -9,10 +8,9 @@
9
8
  <td class="min"><%= user.ldap_uid %></td>
10
9
  <td class="min"><%= user.employee_id %></td>
11
10
  <td>
12
- <%= link_to 'edit', edit_admin_user_path(user), class: 'btn btn-blue', id: dom_id(user, 'edit') %>
11
+ <%= link_to 'edit', edit_admin_user_path(user), class: 'btn btn-primary', id: dom_id(user, 'edit'), role: 'button' %>
13
12
  </td>
14
13
  <td>
15
14
  <%= button_to 'delete', admin_user_path(user), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger" %>
16
15
  </td>
17
16
  </tr>
18
- <% end %>
@@ -1,34 +1,106 @@
1
- <div class="ucb-rails-users-table-header clearfix">
1
+ <div class="ucb-rails-users-table-header">
2
2
  <h1>Users</h1>
3
+ <div style="margin-top: 10px; overflow: auto; margin-bottom: 10px; vertical-align: middle; ">
4
+ <%= form_with url: "", method: :get, data: { turbo_frame: "users" }, style: "display: flex; gap: 10px; align-items: center; flex-grow: 1;" do |form| %>
5
+ <%= form.hidden_field :sort, value: @sort %>
6
+ <%= form.hidden_field :dir, value: @sort_dir %>
7
+ <div style="float: left; padding-right: 15px">
8
+ Show <%= form.select :count, options_for_select([10, 25, 50, 100], selected: params[:count]), {}, { onchange: "this.form.requestSubmit()" } %>
9
+ </div>
10
+ <div style="float: left;">
11
+ Search <%= form.search_field :query, value: params[:query], id: "user_search_field", placeholder: "Search users...", oninput: "
12
+ clearTimeout(window.searchTimer);
13
+ window.searchTimer = setTimeout(() => {
14
+ this.form.requestSubmit();
15
+ }, 300);
16
+ " %>
17
+ </div>
18
+ <% end %>
19
+ <div style="float: right;">
20
+ <%= link_to "Add User", new_admin_user_path, class: "btn btn-primary" %>
21
+ </div>
22
+ </div>
3
23
  </div>
4
24
 
5
- <%= form_with url: "", method: :get, data: { turbo_frame: "users", turbo_action: "advance" } do |form| %>
6
- Show <%= form.select :count, options_for_select([10, 25, 50, 100], selected: params[:count]), {}, { onchange: "this.form.requestSubmit()" } %>
7
-
8
- Search <%= form.search_field :query, value: params[:query], oninput: "this.form.requestSubmit()" %>
9
- <% end %>
10
-
11
- <div class="table-responsive ucb-rails-users-table-wrapper">
12
- <table class="table table-striped table-bordered table-hover ucb-rails-users-table">
13
- <thead>
14
- <tr>
15
- <th class="min">Superuser?</th>
16
- <th class="min">Inactive?</th>
17
- <th>First Name</th>
18
- <th>Last Name</th>
19
- <th>Email</th>
20
- <th class="dt">Last Login</th>
21
- <th>UID</th>
22
- <th>Employee ID</th>
23
- <th class="min unsorted">Edit</th>
24
- <th class="min unsorted">Delete</th>
25
- </tr>
26
- </thead>
27
- <tbody class="highlight">
28
- <%= render partial: "ucb_rails_user/users/user", collection: @users %>
29
- </tbody>
30
- </table>
31
- <div class="ucb-rails-user">
32
- <%= pagy_nav(@pagy).html_safe %>
25
+ <%= turbo_frame_tag "users" do %>
26
+ <div class="table-responsive ucb-rails-users-table-wrapper">
27
+ <table class="table table-striped table-bordered table-hover ucb-rails-users-table">
28
+ <thead>
29
+ <tr>
30
+ <th class="min">
31
+ <%= link_to admin_users_path(sort: "superuser_flag", dir: @sort == "superuser_flag" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, style: "text-decoration: none; color: inherit;" do %>
32
+ Superuser?
33
+ <% if @sort == "superuser_flag" %>
34
+ <%= @sort_dir == "asc" ? "▲" : "▼" %>
35
+ <% end %>
36
+ <% end %>
37
+ </th>
38
+ <th class="min">
39
+ <%= link_to admin_users_path(sort: "inactive_flag", dir: @sort == "inactive_flag" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, style: "text-decoration: none; color: inherit;" do %>
40
+ Inactive?
41
+ <% if @sort == "inactive_flag" %>
42
+ <%= @sort_dir == "asc" ? "▲" : "▼" %>
43
+ <% end %>
44
+ <% end %>
45
+ </th>
46
+ <th>
47
+ <%= link_to admin_users_path(sort: "first_name", dir: @sort == "first_name" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, style: "text-decoration: none; color: inherit;" do %>
48
+ First Name
49
+ <% if @sort == "first_name" %>
50
+ <%= @sort_dir == "asc" ? "▲" : "▼" %>
51
+ <% end %>
52
+ <% end %>
53
+ </th>
54
+ <th>
55
+ <%= link_to admin_users_path(sort: "last_name", dir: @sort == "last_name" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, style: "text-decoration: none; color: inherit;" do %>
56
+ Last Name
57
+ <% if @sort == "last_name" %>
58
+ <%= @sort_dir == "asc" ? "▲" : "▼" %>
59
+ <% end %>
60
+ <% end %>
61
+ </th>
62
+ <th>
63
+ <%= link_to admin_users_path(sort: "email", dir: @sort == "email" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, style: "text-decoration: none; color: inherit;" do %>
64
+ Email
65
+ <% if @sort == "email" %>
66
+ <%= @sort_dir == "asc" ? "▲" : "▼" %>
67
+ <% end %>
68
+ <% end %>
69
+ </th>
70
+ <th class="dt">
71
+ <%= link_to admin_users_path(sort: "last_login_at", dir: @sort == "last_login_at" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, style: "text-decoration: none; color: inherit;" do %>
72
+ Last Login
73
+ <% if @sort == "last_login_at" %>
74
+ <%= @sort_dir == "asc" ? "▲" : "▼" %>
75
+ <% end %>
76
+ <% end %>
77
+ </th>
78
+ <th>
79
+ <%= link_to admin_users_path(sort: "ldap_uid", dir: @sort == "ldap_uid" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, style: "text-decoration: none; color: inherit;" do %>
80
+ UID
81
+ <% if @sort == "ldap_uid" %>
82
+ <%= @sort_dir == "asc" ? "▲" : "▼" %>
83
+ <% end %>
84
+ <% end %>
85
+ </th>
86
+ <th>
87
+ <%= link_to admin_users_path(sort: "employee_id", dir: @sort == "employee_id" && @sort_dir == "asc" ? "desc" : "asc", query: params[:query], count: params[:count]), data: { turbo_frame: "users" }, style: "text-decoration: none; color: inherit;" do %>
88
+ Employee ID
89
+ <% if @sort == "employee_id" %>
90
+ <%= @sort_dir == "asc" ? "▲" : "▼" %>
91
+ <% end %>
92
+ <% end %>
93
+ </th>
94
+ <th class="min unsorted">Edit</th>
95
+ <th class="min unsorted">Delete</th>
96
+ </tr>
97
+ </thead>
98
+ <tbody class="highlight">
99
+ <%= render partial: "ucb_rails_user/users/user", collection: @users %>
100
+ </tbody>
101
+ </table>
102
+ <div class="ucb-rails-user">
103
+ <%= pagy_nav(@pagy, pagy_url_for: ->(page, pagy) { admin_users_path(page: page, count: params[:count], query: params[:query], sort: @sort, dir: @sort_dir) }).html_safe %>
104
+ </div>
33
105
  </div>
34
- </div>
106
+ <% end %>
@@ -1,6 +1,9 @@
1
- <h2>Add New User</h2>
1
+ <div class="ucb-rails-users-table-header">
2
+ <h1>Users</h1>
3
+ <h2>Add New User</h2>
4
+ </div>
2
5
 
3
- <%= form_tag admin_user_search_path, method: :get, remote: true, class: "form-inline user-search-form" do %>
6
+ <%= form_tag admin_user_search_path, method: :get, class: "form-inline user-search-form" do %>
4
7
  <%= text_field_tag :first_name, "", placeholder: "First name", class: "form-control" %>
5
8
  <%= text_field_tag :last_name, "", placeholder: "Last name", class: "form-control" %>
6
9
  <%= text_field_tag :employee_id, "", placeholder: "Employee ID", class: "form-control" %>
@@ -8,7 +11,7 @@
8
11
  <%= link_to "Cancel", admin_users_path, class: "btn btn-default" %>
9
12
  <% end %>
10
13
 
11
- <div class="ucb-rails-user-loader">
14
+ <div class="ucb-rails-user-loader" style="display: none;">
12
15
  Loading...
13
16
  </div>
14
17
 
@@ -0,0 +1,16 @@
1
+ <div class="ucb-rails-users-table-header">
2
+ <h1>Users</h1>
3
+ <h2>Add New User</h2>
4
+ </div>
5
+
6
+ <%= form_tag admin_user_search_path, method: :get, class: "form-inline user-search-form" do %>
7
+ <%= text_field_tag :first_name, params[:first_name], placeholder: "First name", class: "form-control" %>
8
+ <%= text_field_tag :last_name, params[:last_name], placeholder: "Last name", class: "form-control" %>
9
+ <%= text_field_tag :employee_id, params[:employee_id], placeholder: "Employee ID", class: "form-control" %>
10
+ <%= submit_tag "Search", class: "btn btn-primary" %>
11
+ <%= link_to "Cancel", admin_users_path, class: "btn btn-default" %>
12
+ <% end %>
13
+
14
+ <div class="search-results">
15
+ <%= render "search_results" %>
16
+ </div>
@@ -0,0 +1,2 @@
1
+ # Pin npm packages for the engine
2
+ pin_all_from File.expand_path("../app/assets/javascripts/ucb_rails_user", __dir__), under: "ucb_rails_user"
@@ -1,3 +1,3 @@
1
1
  module UcbRailsUser
2
- VERSION = '8.0.1'
2
+ VERSION = '8.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ucb_rails_user
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.1
4
+ version: 8.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Downey
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2025-07-03 00:00:00.000000000 Z
16
+ date: 2025-09-30 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails
@@ -396,7 +396,9 @@ files:
396
396
  - app/views/ucb_rails_user/users/edit.html.erb
397
397
  - app/views/ucb_rails_user/users/index.html.erb
398
398
  - app/views/ucb_rails_user/users/new.html.erb
399
+ - app/views/ucb_rails_user/users/search.html.erb
399
400
  - app/views/ucb_rails_user/users/search.js.erb
401
+ - config/importmap.rb
400
402
  - config/initializers/simple_form.rb
401
403
  - config/initializers/simple_form_bootstrap.rb
402
404
  - config/locales/simple_form.en.yml