ucb_rails_user 6.1.0 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,111 @@
1
+ import Bloodhound from "ucb_rails_user/bloodhound"
2
+
3
+ // the users table has width set to auto, but the pagination tries to stretch to full width - this
4
+ // forces the pagination to match the table
5
+ var resizePagination = function () {
6
+ //var paginationDiv = $('.dataTables_info').parents('.row').first()
7
+ //paginationDiv.width($('.dataTable').width())
8
+ }
9
+
10
+ var addDatatablesToNewUserSearchResults = function () {
11
+ $('.add-user-search-results-table').dataTable({
12
+ searching: true,
13
+ order: [[ 2, "asc" ]],
14
+ columnDefs: [ {
15
+ targets: 3,
16
+ orderable: false
17
+ }]
18
+ })
19
+ resizePagination()
20
+ }
21
+
22
+ var addDatatablesToUsersTable = function () {
23
+ var unsorted_columns = $('.ucb-rails-users-table th.unsorted').map((i, e) => $(e).index()).toArray()
24
+ if (unsorted_columns == []) {
25
+ var unsorted_columns = $(".ucb-rails-users-table th:contains('Edit'),.ucb-rails-users-table th:contains('Delete')").map((i, e) => $(e).index()).toArray()
26
+ }
27
+
28
+ $('.ucb-rails-users-table').dataTable({
29
+ searching: true,
30
+ order: [[ 3, "asc" ]],
31
+ columnDefs: [ {
32
+ targets: unsorted_columns,
33
+ orderable: false
34
+ }],
35
+ })
36
+ var addNewHtml = '&nbsp;&nbsp;<a href="/admin/users/new" class="btn btn-primary">Add New</a>'
37
+ $('.ucb-rails-users-table-wrapper #DataTables_Table_0_filter').append(addNewHtml)
38
+ }
39
+
40
+ var resetImpersonateButton = function() {
41
+ var targetId = $('#ucb_rails_user_impersonation_target_id').val()
42
+ if (targetId != null && targetId.toString().length > 0) {
43
+ $('input[data-impersonate-button]').removeAttr('disabled')
44
+ } else {
45
+ $('input[data-impersonate-button]').attr('disabled', 'disabled')
46
+ }
47
+ }
48
+
49
+ var clearImpersonateSelection = function() {
50
+ $('#ucb_rails_user_impersonation_target_id').val('')
51
+ resetImpersonateButton()
52
+ }
53
+
54
+ $( window ).on("load", function() {
55
+ // the datatable calling was failing intermittently, but adding the timeout
56
+ // seemed to fix it, so ¯\_(ツ)_/¯
57
+ window.setTimeout(addDatatablesToUsersTable, 100)
58
+
59
+ $('.user-search-form').on('submit', function() {
60
+ $('.search-results').hide()
61
+ $('.ucb-rails-user-loader').show()
62
+ })
63
+
64
+ var usersSource = new Bloodhound({
65
+ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
66
+ queryTokenizer: Bloodhound.tokenizers.whitespace,
67
+ remote: {
68
+ url: '/admin/users/impersonate_search?q=%QUERY',
69
+ wildcard: '%QUERY'
70
+ }
71
+ });
72
+
73
+ $('#ucb_rails_user_impersonation_target').typeahead(null, {
74
+ name: 'users',
75
+ source: usersSource,
76
+ display: 'name',
77
+ limit: 7, // any higher than this, and the results don't display properly
78
+ templates: {
79
+ empty: [
80
+ '<div class="empty-message">',
81
+ 'No match found',
82
+ '</div>'
83
+ ].join('\n'),
84
+ suggestion: function (data) {
85
+ return '<div><strong>' + data.name + '</strong> (' + data.uid + ')</div>'
86
+ }
87
+ }
88
+ });
89
+
90
+ $('#ucb_rails_user_impersonation_target').keyup(function(event) {
91
+ if ($(event.target).val().length == 0) {
92
+ clearImpersonateSelection()
93
+ }
94
+ })
95
+
96
+ $('#ucb_rails_user_impersonation_target').bind('typeahead:open', function(event, suggestion) {
97
+ clearImpersonateSelection()
98
+ })
99
+
100
+ $('#ucb_rails_user_impersonation_target').bind('typeahead:select', function(event, suggestion) {
101
+ $('#ucb_rails_user_impersonation_target_id').val(suggestion.id)
102
+ resetImpersonateButton()
103
+ })
104
+
105
+ })
106
+
107
+ // hack to make this work better with ES modules
108
+ window.resizePagination = resizePagination
109
+ window.addDatatablesToNewUserSearchResults = addDatatablesToNewUserSearchResults
110
+ window.resetImpersonateButton = resetImpersonateButton
111
+ window.clearImpersonateSelection = clearImpersonateSelection
@@ -11,5 +11,6 @@
11
11
  // about supported directives.
12
12
  //
13
13
  //= require rails-ujs
14
- //= require_tree .
15
-
14
+ //= require ucb_rails_user/datatables
15
+ //= require ucb_rails_user/typeahead.bundle
16
+ //= require ucb_rails_user/ucb_rails_user
@@ -5,7 +5,7 @@ var resizePagination = function () {
5
5
  //paginationDiv.width($('.dataTable').width())
6
6
  }
7
7
 
8
- var addDatatablesToSearchResults = function () {
8
+ var addDatatablesToNewUserSearchResults = function () {
9
9
  $('.add-user-search-results-table').dataTable({
10
10
  searching: true,
11
11
  order: [[ 2, "asc" ]],
@@ -19,7 +19,7 @@ var addDatatablesToSearchResults = function () {
19
19
 
20
20
  var addDatatablesToUsersTable = function () {
21
21
  var unsorted_columns = $('.ucb-rails-users-table th.unsorted').map((i, e) => $(e).index()).toArray()
22
- if (unsorted_columns === []) {
22
+ if (unsorted_columns == []) {
23
23
  var unsorted_columns = $(".ucb-rails-users-table th:contains('Edit'),.ucb-rails-users-table th:contains('Delete')").map((i, e) => $(e).index()).toArray()
24
24
  }
25
25
 
@@ -101,4 +101,3 @@ $( window ).on("load", function() {
101
101
  })
102
102
 
103
103
  })
104
-
@@ -0,0 +1,3 @@
1
+ @use "impersonations"
2
+ @use "loader"
3
+ @use "users_table"
@@ -83,7 +83,9 @@ table.dataTable thead > tr > th.sorting_asc, table.dataTable thead > tr > th.sor
83
83
  table.dataTable thead > tr > td.sorting_asc,
84
84
  table.dataTable thead > tr > td.sorting_desc,
85
85
  table.dataTable thead > tr > td.sorting {
86
+ /*
86
87
  padding-right: 30px;
88
+ */
87
89
  }
88
90
  table.dataTable thead > tr > th:active,
89
91
  table.dataTable thead > tr > td:active {
@@ -398,5 +400,3 @@ div.dtr-modal div.dtr-modal-background {
398
400
  div.dtr-bs-modal table.table tr:first-child td {
399
401
  border-top: none;
400
402
  }
401
-
402
-
@@ -0,0 +1,3 @@
1
+ @import "datatables"
2
+ @import "typeahead_tweaks"
3
+ @import "components"
@@ -1,3 +1,6 @@
1
+ /* this is here for backwards compatibility - it should be removed in the future */
1
2
  @import "datatables"
2
3
  @import "typeahead_tweaks"
3
- @import "components/**/*"
4
+ @import "components/impersonations"
5
+ @import "components/loader"
6
+ @import "components/users_table"
@@ -1,5 +1,4 @@
1
1
  $('.ucb-rails-user-loader').hide()
2
2
  $('.search-results').html("#{ j render(partial: "search_results") }")
3
- addDatatablesToSearchResults()
3
+ addDatatablesToNewUserSearchResults()
4
4
  $('.search-results').show()
5
-
@@ -1,3 +1,3 @@
1
1
  module UcbRailsUser
2
- VERSION = '6.1.0'
2
+ VERSION = '6.2.0'
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: 6.1.0
4
+ version: 6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Downey
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2024-02-09 00:00:00.000000000 Z
14
+ date: 2024-03-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -33,20 +33,6 @@ dependencies:
33
33
  - - "<"
34
34
  - !ruby/object:Gem::Version
35
35
  version: '8.0'
36
- - !ruby/object:Gem::Dependency
37
- name: sprockets-rails
38
- requirement: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: '0'
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '0'
50
36
  - !ruby/object:Gem::Dependency
51
37
  name: haml
52
38
  requirement: !ruby/object:Gem::Requirement
@@ -235,6 +221,20 @@ dependencies:
235
221
  - - ">="
236
222
  - !ruby/object:Gem::Version
237
223
  version: '0'
224
+ - !ruby/object:Gem::Dependency
225
+ name: sprockets-rails
226
+ requirement: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ type: :development
232
+ prerelease: false
233
+ version_requirements: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - ">="
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
238
  - !ruby/object:Gem::Dependency
239
239
  name: capybara
240
240
  requirement: !ruby/object:Gem::Requirement
@@ -303,13 +303,19 @@ files:
303
303
  - Rakefile
304
304
  - app/assets/config/ucb_rails_user_manifest.js
305
305
  - app/assets/javascripts/ucb_rails_user/datatables.js
306
+ - app/assets/javascripts/ucb_rails_user/esm/bloodhound.js
307
+ - app/assets/javascripts/ucb_rails_user/esm/datatables.js
308
+ - app/assets/javascripts/ucb_rails_user/esm/typeahead.js
309
+ - app/assets/javascripts/ucb_rails_user/esm/ucb_rails_user.js
306
310
  - app/assets/javascripts/ucb_rails_user/scripts.js
307
311
  - app/assets/javascripts/ucb_rails_user/typeahead.bundle.js
308
312
  - app/assets/javascripts/ucb_rails_user/ucb_rails_user.js
309
313
  - app/assets/stylesheets/ucb_rails_user/components/_impersonations.sass
310
314
  - app/assets/stylesheets/ucb_rails_user/components/_loader.sass
311
315
  - app/assets/stylesheets/ucb_rails_user/components/_users_table.sass
316
+ - app/assets/stylesheets/ucb_rails_user/components/index.sass
312
317
  - app/assets/stylesheets/ucb_rails_user/datatables.css
318
+ - app/assets/stylesheets/ucb_rails_user/index.sass
313
319
  - app/assets/stylesheets/ucb_rails_user/main.sass
314
320
  - app/assets/stylesheets/ucb_rails_user/styles.css
315
321
  - app/assets/stylesheets/ucb_rails_user/typeahead_tweaks.sass