administrate_batch_actions 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a33ac2550f09f1b8cb9a9bae773380bf14c55d7d5422835a2b170e31c716f983
4
- data.tar.gz: 3ee144b51a5b9a404421c34a9113395a8975fc2cee971025c89ea6df614b924c
3
+ metadata.gz: ad62aba64f88ca0163f6cbc96f0f5b136f05e6b7d05800bbbf36e84645fc1cb9
4
+ data.tar.gz: 37d7ba0e169d4f5e39b1b70dffaea7e42b4c42d05057c692109282d3ce1cd44f
5
5
  SHA512:
6
- metadata.gz: 2385cd89b2487180784f61766d531666d95d5b31f192744a2d35553672477676cb2e03a4872d2d8b58f45f94df2d60084bc3d15ce514cc5cc2d317082e4a30b7
7
- data.tar.gz: bdf87209596907b29b653c66e18b056b393dce3b3775184f0d4b5f00c4870a52e4ac63bacf055b0d62d3755d07ea832018c03b3f39eac8fc6466941f8083b34f
6
+ metadata.gz: a9ca8f5997d3cbbf03332456b3f2556cef7dc041bd5fcf0e25cc37fa0802dd521889e6f1c98bc12dd41d9af17466319324a5e0109412ce49de33a1dabfc838e8
7
+ data.tar.gz: 6abb1a112e82d9bfbd189f419e8328edf6573a6f7de3172039dbed3c91eb046e6767f761b11089214d1b3392b6a2e47b9de7b730c4e4f2c7eb84bae2c216753f
data/Gemfile.lock CHANGED
@@ -106,7 +106,7 @@ GEM
106
106
  activerecord
107
107
  kaminari-core (= 1.2.1)
108
108
  kaminari-core (1.2.1)
109
- loofah (2.12.0)
109
+ loofah (2.19.0)
110
110
  crass (~> 1.0.2)
111
111
  nokogiri (>= 1.5.9)
112
112
  mail (2.7.1)
@@ -114,19 +114,19 @@ GEM
114
114
  marcel (1.0.1)
115
115
  method_source (1.0.0)
116
116
  mini_mime (1.1.0)
117
- mini_portile2 (2.6.1)
117
+ mini_portile2 (2.8.0)
118
118
  minitest (5.14.4)
119
119
  momentjs-rails (2.20.1)
120
120
  railties (>= 3.1)
121
121
  nio4r (2.5.8)
122
- nokogiri (1.12.3)
123
- mini_portile2 (~> 2.6.1)
122
+ nokogiri (1.13.9)
123
+ mini_portile2 (~> 2.8.0)
124
124
  racc (~> 1.4)
125
125
  pry (0.14.1)
126
126
  coderay (~> 1.1)
127
127
  method_source (~> 1.0)
128
- racc (1.5.2)
129
- rack (2.2.3)
128
+ racc (1.6.0)
129
+ rack (2.2.4)
130
130
  rack-test (1.1.0)
131
131
  rack (>= 1.0, < 3)
132
132
  rails (6.1.4)
@@ -147,7 +147,7 @@ GEM
147
147
  rails-dom-testing (2.0.3)
148
148
  activesupport (>= 4.2.0)
149
149
  nokogiri (>= 1.6)
150
- rails-html-sanitizer (1.3.0)
150
+ rails-html-sanitizer (1.4.3)
151
151
  loofah (~> 2.3)
152
152
  railties (6.1.4)
153
153
  actionpack (= 6.1.4)
@@ -155,7 +155,7 @@ GEM
155
155
  method_source
156
156
  rake (>= 0.13)
157
157
  thor (~> 1.0)
158
- rake (10.5.0)
158
+ rake (13.0.6)
159
159
  rspec (3.8.0)
160
160
  rspec-core (~> 3.8.0)
161
161
  rspec-expectations (~> 3.8.0)
@@ -209,10 +209,10 @@ DEPENDENCIES
209
209
  administrate_batch_actions!
210
210
  bundler (~> 1.16)
211
211
  pry
212
- rake (~> 10.0)
212
+ rake (~> 13.0)
213
213
  rspec (~> 3.0)
214
214
  rspec-rails (~> 3.0)
215
215
  tzinfo-data
216
216
 
217
217
  BUNDLED WITH
218
- 2.2.26
218
+ 1.16.3
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ['lib']
30
30
 
31
31
  spec.add_development_dependency 'bundler', '~> 1.16'
32
- spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rake', '~> 13.0'
33
33
  spec.add_development_dependency 'rspec', '~> 3.0'
34
34
  spec.add_development_dependency 'rspec-rails', '~> 3.0'
35
35
  spec.add_development_dependency 'pry'
@@ -1,63 +1,71 @@
1
- var buttons = document.querySelectorAll("[data-batch-action-option='button']");
2
- var checkboxes = document.querySelectorAll("[data-batch-action-option='checkbox']");
3
- var selectAllCheckboxes = document.querySelector("[data-batch-action-option='select_all']");
1
+ const init = function() {
2
+ var buttons = document.querySelectorAll("[data-batch-action-option='button']");
3
+ var checkboxes = document.querySelectorAll("[data-batch-action-option='checkbox']");
4
+ var selectAllCheckboxes = document.querySelector("[data-batch-action-option='select_all']");
4
5
 
5
- if (selectAllCheckboxes && checkboxes && buttons) {
6
+ if (selectAllCheckboxes && checkboxes && buttons) {
6
7
 
7
- window.onpageshow = function(event) {
8
- if (selectedItemIds()) {
8
+ window.onpageshow = function(event) {
9
+ if (selectedItemIds()) {
10
+ checkboxes.forEach(function(checkbox) {
11
+ checkbox.checked = false;
12
+ });
13
+
14
+ selectAllCheckboxes.checked = false;
15
+ }
16
+ };
17
+
18
+ selectAllCheckboxes.addEventListener('click', function(){
9
19
  checkboxes.forEach(function(checkbox) {
10
- checkbox.checked = false;
20
+ checkbox.checked = selectAllCheckboxes.checked;
11
21
  });
12
22
 
13
- selectAllCheckboxes.checked = false;
14
- }
15
- };
23
+ checkAndToggleActionButtons();
24
+ });
16
25
 
17
- selectAllCheckboxes.addEventListener('click', function(){
18
- checkboxes.forEach(function(checkbox) {
19
- checkbox.checked = selectAllCheckboxes.checked;
26
+ buttons.forEach(function(button){
27
+ button.addEventListener('click', function(event){
28
+ button.href += '?' + selectedItemIds()
29
+ });
20
30
  });
21
31
 
22
- checkAndToggleActionButtons();
23
- });
32
+ checkboxes.forEach(function(checkbox){
33
+ checkbox.closest('td').addEventListener('click', function(event){
34
+ event.stopImmediatePropagation();
35
+ })
24
36
 
25
- buttons.forEach(function(button){
26
- button.addEventListener('click', function(event){
27
- button.href += '?' + selectedItemIds()
28
- });
29
- });
37
+ checkbox.addEventListener('click', function(event) {
38
+ event.stopImmediatePropagation();
30
39
 
31
- checkboxes.forEach(function(checkbox){
32
- checkbox.closest('td').addEventListener('click', function(event){
33
- event.stopImmediatePropagation();
40
+ checkAndToggleActionButtons();
41
+ })
34
42
  })
43
+ }
35
44
 
36
- checkbox.addEventListener('click', function(event) {
37
- event.stopImmediatePropagation();
45
+ function selectedItemIds() {
46
+ var ids = Array.prototype.filter.call(checkboxes, function(checkbox) {
47
+ if (checkbox.checked) { return checkbox }
48
+ }).map(function(checkbox) {
49
+ return 'batch_action_ids[]=' + checkbox.value
50
+ }).join('&');
51
+ return ids;
52
+ }
38
53
 
39
- checkAndToggleActionButtons();
40
- })
41
- })
42
- }
43
-
44
- function selectedItemIds() {
45
- var ids = Array.prototype.filter.call(checkboxes, function(checkbox) {
46
- if (checkbox.checked) { return checkbox }
47
- }).map(function(checkbox) {
48
- return 'batch_action_ids[]=' + checkbox.value
49
- }).join('&');
50
- return ids;
51
- }
52
-
53
- function checkAndToggleActionButtons() {
54
- if (selectedItemIds()) {
55
- buttons.forEach(function(button){
56
- button.classList.remove('disabled');
57
- });
58
- } else {
59
- buttons.forEach(function(button){
60
- button.classList.add('disabled');
61
- });
54
+ function checkAndToggleActionButtons() {
55
+ if (selectedItemIds()) {
56
+ buttons.forEach(function(button){
57
+ button.classList.remove('disabled');
58
+ button.removeAttribute('disabled');
59
+ });
60
+ } else {
61
+ buttons.forEach(function(button){
62
+ button.classList.add('disabled');
63
+ button.setAttribute('disabled', 'disabled');
64
+ });
65
+ }
62
66
  }
63
- }
67
+ };
68
+
69
+ document.addEventListener("DOMContentLoaded", function() { init() });
70
+ document.addEventListener("turbolinks:load", function() { init() });
71
+ document.addEventListener("turbo:load", function() { init() });
data/config/routes.rb CHANGED
@@ -10,19 +10,18 @@ Rails.application.routes.draw do
10
10
  ::Administrate::ApplicationController.descendants
11
11
  end
12
12
 
13
- namespace :admin do
14
- controllers_for(nil).each do |controller|
15
- controller
16
- .instance_methods
17
- .select { |m| m[/.+_batch_action$/] }
18
- .each do |method_name|
19
- resource = controller.name.demodulize.underscore.delete_suffix('_controller')
13
+ controllers_for(nil).each do |controller|
14
+ controller
15
+ .instance_methods
16
+ .select { |m| m[/.+_batch_action$/] }
17
+ .each do |method_name|
18
+ resource = controller.name.demodulize.underscore.delete_suffix('_controller')
20
19
 
21
- resources resource.to_sym do
22
- post method_name.to_sym, on: :collection
23
- end
24
- end
20
+ resources resource.to_sym do
21
+ post method_name.to_sym,
22
+ on: :collection,
23
+ controller: controller.name.underscore.delete_suffix('_controller')
24
+ end
25
25
  end
26
26
  end
27
-
28
27
  end
@@ -1,3 +1,3 @@
1
1
  module AdministrateBatchActions
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate_batch_actions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sourcelabs LLC
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-17 00:00:00.000000000 Z
11
+ date: 2022-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement