administrate_batch_actions 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/administrate_batch_actions.gemspec +1 -1
- data/app/assets/javascripts/administrate_batch_actions/script.js +56 -50
- data/config/routes.rb +11 -12
- data/lib/administrate_batch_actions/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad62aba64f88ca0163f6cbc96f0f5b136f05e6b7d05800bbbf36e84645fc1cb9
|
4
|
+
data.tar.gz: 37d7ba0e169d4f5e39b1b70dffaea7e42b4c42d05057c692109282d3ce1cd44f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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.
|
123
|
-
mini_portile2 (~> 2.
|
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.
|
129
|
-
rack (2.2.
|
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
|
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 (
|
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 (~>
|
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
|
-
|
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', '~>
|
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,65 +1,71 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
var
|
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
|
-
|
8
|
-
|
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 =
|
20
|
+
checkbox.checked = selectAllCheckboxes.checked;
|
11
21
|
});
|
12
22
|
|
13
|
-
|
14
|
-
}
|
15
|
-
};
|
16
|
-
|
17
|
-
selectAllCheckboxes.addEventListener('click', function(){
|
18
|
-
checkboxes.forEach(function(checkbox) {
|
19
|
-
checkbox.checked = selectAllCheckboxes.checked;
|
23
|
+
checkAndToggleActionButtons();
|
20
24
|
});
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
button.addEventListener('click', function(event){
|
27
|
-
button.href += '?' + selectedItemIds()
|
26
|
+
buttons.forEach(function(button){
|
27
|
+
button.addEventListener('click', function(event){
|
28
|
+
button.href += '?' + selectedItemIds()
|
29
|
+
});
|
28
30
|
});
|
29
|
-
});
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
checkboxes.forEach(function(checkbox){
|
33
|
+
checkbox.closest('td').addEventListener('click', function(event){
|
34
|
+
event.stopImmediatePropagation();
|
35
|
+
})
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
checkbox.addEventListener('click', function(event) {
|
38
|
+
event.stopImmediatePropagation();
|
38
39
|
|
39
|
-
|
40
|
+
checkAndToggleActionButtons();
|
41
|
+
})
|
40
42
|
})
|
41
|
-
}
|
42
|
-
}
|
43
|
+
}
|
43
44
|
|
44
|
-
function selectedItemIds() {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
}
|
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
|
+
}
|
52
53
|
|
53
|
-
function checkAndToggleActionButtons() {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
+
}
|
64
66
|
}
|
65
|
-
}
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
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.
|
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-
|
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: '
|
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: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|