administrate_batch_actions 0.2.0 → 0.3.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7ba01dc33c559c35b0b7a3a1121edc34faacc91ce7083b3d638d285c16880f6
|
4
|
+
data.tar.gz: 9b18c836b879efad973cb3e7487cac118307e31a77fc6654a59f82d0e3f97402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45035d8d3ba5485659aafe52adc564be0c1dc028913332ff5c06db6d47fde3c8b33053fb628abfbbacd883f610b94cdc6bc899ec7a85712ce07b624f67f0422a
|
7
|
+
data.tar.gz: 644c56ba9400a37c50d71bea381d86db68bfab7542afdd4612246069b805d32f516b7ff960544d849287378e88f56f2158a52590755d7148ff607fe972efbe2c
|
@@ -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.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sourcelabs LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|