ucb_rails_user 8.0.4 → 8.0.5

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: 8d1e82725f375724e87fee2abd8ebd6a1eef2d9e99866e2f93c42ceae225e540
4
- data.tar.gz: 9889577c25c659e93aa4ae9a4a1a4cbe8a672b325dd68d694d03b12078ef9120
3
+ metadata.gz: 33c1423ac635977abc651ba960a571fb70f398d436475d701f8932b06f54b361
4
+ data.tar.gz: 15d1eadd248c5a83ef7bc45511e7920721c344f24594eb9083856fb5343a545c
5
5
  SHA512:
6
- metadata.gz: c1e3e70e8637c5bcc38cd1916950d18137de5638963fdd58067665946aeb3e51fd54562cd8c14425aae85ee68574b8acabd29f34e0f4026e0a94e3d49e47c7ec
7
- data.tar.gz: e7c74e99cc0cb2c0206fd7a507a3e18f152dedc756648058792f34610ce796a87985752a06ec89a83847686a0353463d54d2e08e22081197e4afbe1bbace1821
6
+ metadata.gz: 23e75ecaf5356a46eb33bda871f6fdb6f0416b3d8b27bbaf5c3fba830ec5cb00958d23997cf6139ff3918c7d33907dfb8df64197bcbcadcc6ae9ddd9c17d95a2
7
+ data.tar.gz: 35eb226797cc645fdb3a7f2798bb0dc88315e9c62e5ff5e0eb8e317c59fb3581032417139c794e7c5833c3dbd724b1704c575a718297a6414cae7317dc0b8c71
@@ -35,20 +35,6 @@ var addDatatablesToUsersTable = function () {
35
35
  $('.ucb-rails-users-table-wrapper #DataTables_Table_0_filter').append(addNewHtml)
36
36
  }
37
37
 
38
- var resetImpersonateButton = function() {
39
- var targetId = $('#ucb_rails_user_impersonation_target_id').val()
40
- if (targetId != null && targetId.toString().length > 0) {
41
- $('input[data-impersonate-button]').removeAttr('disabled')
42
- } else {
43
- $('input[data-impersonate-button]').attr('disabled', 'disabled')
44
- }
45
- }
46
-
47
- var clearImpersonateSelection = function() {
48
- $('#ucb_rails_user_impersonation_target_id').val('')
49
- resetImpersonateButton()
50
- }
51
-
52
38
  $( window ).on("load", function() {
53
39
  // the datatable calling was failing intermittently, but adding the timeout
54
40
  // seemed to fix it, so ¯\_(ツ)_/¯
@@ -58,46 +44,4 @@ $( window ).on("load", function() {
58
44
  $('.search-results').hide()
59
45
  $('.ucb-rails-user-loader').show()
60
46
  })
61
-
62
- var usersSource = new Bloodhound({
63
- datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
64
- queryTokenizer: Bloodhound.tokenizers.whitespace,
65
- remote: {
66
- url: '/admin/users/impersonate_search?q=%QUERY',
67
- wildcard: '%QUERY'
68
- }
69
- });
70
-
71
- $('#ucb_rails_user_impersonation_target').typeahead(null, {
72
- name: 'users',
73
- source: usersSource,
74
- display: 'name',
75
- limit: 7, // any higher than this, and the results don't display properly
76
- templates: {
77
- empty: [
78
- '<div class="empty-message">',
79
- 'No match found',
80
- '</div>'
81
- ].join('\n'),
82
- suggestion: function (data) {
83
- return '<div><strong>' + data.name + '</strong> (' + data.uid + ')</div>'
84
- }
85
- }
86
- });
87
-
88
- $('#ucb_rails_user_impersonation_target').keyup(function(event) {
89
- if ($(event.target).val().length == 0) {
90
- clearImpersonateSelection()
91
- }
92
- })
93
-
94
- $('#ucb_rails_user_impersonation_target').bind('typeahead:open', function(event, suggestion) {
95
- clearImpersonateSelection()
96
- })
97
-
98
- $('#ucb_rails_user_impersonation_target').bind('typeahead:select', function(event, suggestion) {
99
- $('#ucb_rails_user_impersonation_target_id').val(suggestion.id)
100
- resetImpersonateButton()
101
- })
102
-
103
47
  })
@@ -10,3 +10,29 @@
10
10
  .recent-impersonations li {
11
11
  list-style-type: none;
12
12
  font-size: 110%; }
13
+
14
+ .impersonate_search_results_container {
15
+ margin-top: 10px;
16
+ }
17
+
18
+ .impersonate_result_list {
19
+ list-style: none;
20
+ padding: 0;
21
+ margin-top: 10px;
22
+ }
23
+
24
+ .impersonate_result_list_item {
25
+ padding: 8px;
26
+ border-bottom: 1px solid #eee;
27
+ }
28
+
29
+ .impersonate_no_results_found {
30
+ margin-top: 10px;
31
+ color: #999;
32
+ }
33
+
34
+ .impersonate_before_search {
35
+ margin-top: 10px;
36
+ color: #666;
37
+ }
38
+
@@ -65,3 +65,39 @@ h1 {
65
65
  padding-left: 10px;
66
66
  padding-right: 10px;
67
67
  }
68
+
69
+ .user_sort {
70
+ text-decoration: none;
71
+ color: inherit;
72
+ }
73
+
74
+ .user_form_container {
75
+ margin-top: 10px;
76
+ overflow: auto;
77
+ margin-bottom: 10px;
78
+ vertical-align: middle;
79
+ }
80
+
81
+ .user_form_base_style {
82
+ display: flex;
83
+ gap: 10px;
84
+ align-items:
85
+ center; flex-grow: 1;
86
+ }
87
+
88
+ .user_form_return_count {
89
+ float: left;
90
+ padding-right: 15px;
91
+ }
92
+
93
+ .user_form_search_box {
94
+ float: left;
95
+ }
96
+
97
+ .user_form_add_user_link {
98
+ float: right;
99
+ }
100
+
101
+ .user_turbo_frame_users {
102
+ margin-bottom: 10px;
103
+ }
@@ -37,8 +37,12 @@ module UcbRailsUser::UsersControllerConcerns
37
37
  end
38
38
 
39
39
  def impersonate_search
40
- result = UcbRailsUser::UserSearch.find_users_by_name(params[:q])
41
- render json: result.map { |u| { name: u.full_name, id: u.id, uid: u.ldap_uid } }
40
+ @query = params[:q]
41
+ @results = if @query.present? && @query.length >= 2
42
+ UcbRailsUser::UserSearch.find_users_by_name(@query)
43
+ else
44
+ []
45
+ end
42
46
  end
43
47
 
44
48
  def edit
@@ -6,10 +6,22 @@
6
6
  </div>
7
7
  <% else %>
8
8
  <div class="impersonation-form">
9
- <%= simple_form_for UcbRailsUser::Impersonation.new, url: admin_impersonations_path, method: :post do |f| %>
10
- <%= f.input :target, label: "User", input_html: { class: "typeahead" } %>
11
- <%= f.input :target_id, as: :hidden %>
12
- <%= f.button :submit, value: "Impersonate", class: "btn btn-primary", disabled: true, data: { impersonate_button: true } %>
9
+ <%= form_with url: admin_user_impersonate_search_path, method: :get, data: { turbo_frame: "search_results" } do |f| %>
10
+ <%= f.label :q, "Search for user:" %>
11
+ <%= f.search_field :q, placeholder: "Enter name...", oninput: "
12
+ clearTimeout(window.impersonateSearchTimer);
13
+ window.impersonateSearchTimer = setTimeout(() => {
14
+ if (this.value.length >= 2) {
15
+ this.form.requestSubmit();
16
+ }
17
+ }, 300);
18
+ " %>
19
+ <% end %>
20
+
21
+ <%= turbo_frame_tag "search_results" do %>
22
+ <div style="margin-top: 10px; color: #666;">
23
+ Type at least 2 characters to search for a user...
24
+ </div>
13
25
  <% end %>
14
26
  </div>
15
27
  <% end %>
@@ -20,7 +32,7 @@
20
32
  <ul>
21
33
  <% current_user.recent_impersonations.each do |imp| %>
22
34
  <li>
23
- <%= link_to full_name_with_uid(imp.target), "#{admin_impersonations_path}?ucb_rails_user_impersonation[target_id]=#{imp.target.id}", method: :post %>
35
+ <%= link_to full_name_with_uid(imp.target), admin_impersonations_path(ucb_rails_user_impersonation: { target_id: imp.target.id }), data: { turbo_method: :post, turbo_frame: "_top" } %>
24
36
  </li>
25
37
  <% end %>
26
38
  </ul>
@@ -0,0 +1,25 @@
1
+ <%= turbo_frame_tag "search_results" do %>
2
+ <% if @results.any? %>
3
+ <div class="impersonate_search_results_container">
4
+ <strong>Search results for "<%= @query %>":</strong>
5
+ <ul class="impersonate_result_list">
6
+ <% @results.each do |user| %>
7
+ <li class="impersonate_result_list_item">
8
+ <%= link_to admin_impersonations_path(ucb_rails_user_impersonation: { target_id: user.id }), data: { turbo_method: :post, turbo_frame: "_top" }, style: "text-decoration: none; color: inherit; display: block;" do %>
9
+ <strong><%= user.full_name %></strong>
10
+ <span style="color: #666; margin-left: 10px;">(<%= user.ldap_uid %>)</span>
11
+ <% end %>
12
+ </li>
13
+ <% end %>
14
+ </ul>
15
+ </div>
16
+ <% elsif @query.present? && @query.length >= 2 %>
17
+ <div class="impersonate_no_results_found">
18
+ No users found matching "<%= @query %>"
19
+ </div
20
+ <% else %>
21
+ <div class="impersonate_before_search">
22
+ Type at least 2 characters to search for a user...
23
+ </div>
24
+ <% end %>
25
+ <% end %>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <%= turbo_frame_tag "users" do %>
6
6
  <% if flash[:notice] || flash[:error] || flash[:alert] %>
7
- <div style="margin-bottom: 10px;">
7
+ <div class="user_turbo_frame_users">
8
8
  <% if flash[:notice] %>
9
9
  <div class="alert alert-info"><%= flash[:notice] %></div>
10
10
  <% end %>
@@ -16,14 +16,14 @@
16
16
  <% end %>
17
17
  </div>
18
18
  <% end %>
19
- <div style="margin-top: 10px; overflow: auto; margin-bottom: 10px; vertical-align: middle; ">
20
- <%= form_with url: "", method: :get, data: { turbo_frame: "users" }, style: "display: flex; gap: 10px; align-items: center; flex-grow: 1;" do |form| %>
19
+ <div class="user_form_container">
20
+ <%= form_with url: "", method: :get, data: { turbo_frame: "users" }, class: "user_form_base_style" do |form| %>
21
21
  <%= form.hidden_field :sort, value: @sort %>
22
22
  <%= form.hidden_field :dir, value: @sort_dir %>
23
- <div style="float: left; padding-right: 15px">
23
+ <div class="user_form_return_count">
24
24
  Show <%= form.select :count, options_for_select([10, 25, 50, 100], selected: params[:count]), {}, { onchange: "this.form.requestSubmit()" } %>
25
25
  </div>
26
- <div style="float: left;">
26
+ <div class="user_form_search_box">
27
27
  Search <%= form.search_field :query, value: params[:query], id: "user_search_field", placeholder: "Search users...", data: { turbo_permanent: true }, oninput: "
28
28
  clearTimeout(window.searchTimer);
29
29
  window.searchTimer = setTimeout(() => {
@@ -32,7 +32,7 @@
32
32
  " %>
33
33
  </div>
34
34
  <% end %>
35
- <div style="float: right;">
35
+ <div class="user_form_add_user_link">
36
36
  <%= link_to "Add User", new_admin_user_path, class: "btn btn-primary" %>
37
37
  </div>
38
38
  </div>
@@ -41,7 +41,7 @@
41
41
  <thead>
42
42
  <tr>
43
43
  <th class="min">
44
- <%= 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 %>
44
+ <%= 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" }, class: "user_sort" do %>
45
45
  Superuser?
46
46
  <% if @sort == "superuser_flag" %>
47
47
  <%= @sort_dir == "asc" ? "▲" : "▼" %>
@@ -49,7 +49,7 @@
49
49
  <% end %>
50
50
  </th>
51
51
  <th class="min">
52
- <%= 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 %>
52
+ <%= 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" }, class: "user_sort" do %>
53
53
  Inactive?
54
54
  <% if @sort == "inactive_flag" %>
55
55
  <%= @sort_dir == "asc" ? "▲" : "▼" %>
@@ -57,7 +57,7 @@
57
57
  <% end %>
58
58
  </th>
59
59
  <th>
60
- <%= 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 %>
60
+ <%= 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" }, class: "user_sort" do %>
61
61
  First Name
62
62
  <% if @sort == "first_name" %>
63
63
  <%= @sort_dir == "asc" ? "▲" : "▼" %>
@@ -65,7 +65,7 @@
65
65
  <% end %>
66
66
  </th>
67
67
  <th>
68
- <%= 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 %>
68
+ <%= 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" }, class: "user_sort" do %>
69
69
  Last Name
70
70
  <% if @sort == "last_name" %>
71
71
  <%= @sort_dir == "asc" ? "▲" : "▼" %>
@@ -73,7 +73,7 @@
73
73
  <% end %>
74
74
  </th>
75
75
  <th>
76
- <%= 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 %>
76
+ <%= 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" }, class: "user_sort" do %>
77
77
  Email
78
78
  <% if @sort == "email" %>
79
79
  <%= @sort_dir == "asc" ? "▲" : "▼" %>
@@ -81,7 +81,7 @@
81
81
  <% end %>
82
82
  </th>
83
83
  <th class="dt">
84
- <%= 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 %>
84
+ <%= 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" }, class: "user_sort" do %>
85
85
  Last Login
86
86
  <% if @sort == "last_login_at" %>
87
87
  <%= @sort_dir == "asc" ? "▲" : "▼" %>
@@ -89,7 +89,7 @@
89
89
  <% end %>
90
90
  </th>
91
91
  <th>
92
- <%= 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 %>
92
+ <%= 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" }, class: "user_sort" do %>
93
93
  UID
94
94
  <% if @sort == "ldap_uid" %>
95
95
  <%= @sort_dir == "asc" ? "▲" : "▼" %>
@@ -97,7 +97,7 @@
97
97
  <% end %>
98
98
  </th>
99
99
  <th>
100
- <%= 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 %>
100
+ <%= 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" }, class: "user_sort" do %>
101
101
  Employee ID
102
102
  <% if @sort == "employee_id" %>
103
103
  <%= @sort_dir == "asc" ? "▲" : "▼" %>
@@ -1,3 +1,3 @@
1
1
  module UcbRailsUser
2
- VERSION = '8.0.4'
2
+ VERSION = '8.0.5'
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.4
4
+ version: 8.0.5
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-10-01 00:00:00.000000000 Z
16
+ date: 2025-10-23 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails
@@ -336,13 +336,8 @@ files:
336
336
  - README.md
337
337
  - Rakefile
338
338
  - app/assets/config/ucb_rails_user_manifest.js
339
- - app/assets/javascripts/ucb_rails_user/datatables.js
340
- - app/assets/javascripts/ucb_rails_user/esm/bloodhound.js
341
- - app/assets/javascripts/ucb_rails_user/esm/datatables.js
342
- - app/assets/javascripts/ucb_rails_user/esm/typeahead.js
343
339
  - app/assets/javascripts/ucb_rails_user/esm/ucb_rails_user.js
344
340
  - app/assets/javascripts/ucb_rails_user/scripts.js
345
- - app/assets/javascripts/ucb_rails_user/typeahead.bundle.js
346
341
  - app/assets/javascripts/ucb_rails_user/ucb_rails_user.js
347
342
  - app/assets/stylesheets/ucb_rails_user/components/impersonations.css
348
343
  - app/assets/stylesheets/ucb_rails_user/components/loader.css
@@ -350,7 +345,6 @@ files:
350
345
  - app/assets/stylesheets/ucb_rails_user/datatables.css
351
346
  - app/assets/stylesheets/ucb_rails_user/index.sass
352
347
  - app/assets/stylesheets/ucb_rails_user/main.css
353
- - app/assets/stylesheets/ucb_rails_user/pagy_tailwind.css
354
348
  - app/assets/stylesheets/ucb_rails_user/styles.css
355
349
  - app/assets/stylesheets/ucb_rails_user/typeahead_tweaks.sass
356
350
  - app/assets/stylesheets/ucb_rails_user/user.css
@@ -394,6 +388,7 @@ files:
394
388
  - app/views/ucb_rails_user/users/_search_results.html.erb
395
389
  - app/views/ucb_rails_user/users/_user.html.erb
396
390
  - app/views/ucb_rails_user/users/edit.html.erb
391
+ - app/views/ucb_rails_user/users/impersonate_search.html.erb
397
392
  - app/views/ucb_rails_user/users/index.html.erb
398
393
  - app/views/ucb_rails_user/users/new.html.erb
399
394
  - app/views/ucb_rails_user/users/search.html.erb