administrate_batch_actions 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/administrate_batch_actions/script.js +38 -8
- data/app/views/shared/administrate_batch_actions/_button.html.erb +1 -1
- data/app/views/shared/administrate_batch_actions/_checkbox.html.erb +1 -1
- data/lib/administrate_batch_actions/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a33ac2550f09f1b8cb9a9bae773380bf14c55d7d5422835a2b170e31c716f983
|
4
|
+
data.tar.gz: 3ee144b51a5b9a404421c34a9113395a8975fc2cee971025c89ea6df614b924c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2385cd89b2487180784f61766d531666d95d5b31f192744a2d35553672477676cb2e03a4872d2d8b58f45f94df2d60084bc3d15ce514cc5cc2d317082e4a30b7
|
7
|
+
data.tar.gz: bdf87209596907b29b653c66e18b056b393dce3b3775184f0d4b5f00c4870a52e4ac63bacf055b0d62d3755d07ea832018c03b3f39eac8fc6466941f8083b34f
|
@@ -2,22 +2,29 @@ var buttons = document.querySelectorAll("[data-batch-action-option='button']");
|
|
2
2
|
var checkboxes = document.querySelectorAll("[data-batch-action-option='checkbox']");
|
3
3
|
var selectAllCheckboxes = document.querySelector("[data-batch-action-option='select_all']");
|
4
4
|
|
5
|
-
if (selectAllCheckboxes) {
|
5
|
+
if (selectAllCheckboxes && checkboxes && buttons) {
|
6
|
+
|
7
|
+
window.onpageshow = function(event) {
|
8
|
+
if (selectedItemIds()) {
|
9
|
+
checkboxes.forEach(function(checkbox) {
|
10
|
+
checkbox.checked = false;
|
11
|
+
});
|
12
|
+
|
13
|
+
selectAllCheckboxes.checked = false;
|
14
|
+
}
|
15
|
+
};
|
16
|
+
|
6
17
|
selectAllCheckboxes.addEventListener('click', function(){
|
7
18
|
checkboxes.forEach(function(checkbox) {
|
8
19
|
checkbox.checked = selectAllCheckboxes.checked;
|
9
20
|
});
|
21
|
+
|
22
|
+
checkAndToggleActionButtons();
|
10
23
|
});
|
11
24
|
|
12
25
|
buttons.forEach(function(button){
|
13
26
|
button.addEventListener('click', function(event){
|
14
|
-
|
15
|
-
if (checkbox.checked) { return checkbox }
|
16
|
-
}).map(function(checkbox) {
|
17
|
-
return 'batch_action_ids[]=' + checkbox.value
|
18
|
-
}).join('&');
|
19
|
-
|
20
|
-
button.href += '?' + ids
|
27
|
+
button.href += '?' + selectedItemIds()
|
21
28
|
});
|
22
29
|
});
|
23
30
|
|
@@ -28,6 +35,29 @@ if (selectAllCheckboxes) {
|
|
28
35
|
|
29
36
|
checkbox.addEventListener('click', function(event) {
|
30
37
|
event.stopImmediatePropagation();
|
38
|
+
|
39
|
+
checkAndToggleActionButtons();
|
31
40
|
})
|
32
41
|
})
|
33
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
|
+
});
|
62
|
+
}
|
63
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
<%= link_to name, path, class: html_options[:class], data: { batch_action_option: 'button', confirm: html_options[:confirm] }, method: :post %>
|
1
|
+
<%= link_to name, path, class: "btn disabled #{html_options[:class]}", data: { batch_action_option: 'button', confirm: html_options[:confirm] }, method: :post %>
|
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.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sourcelabs LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|