administrate_batch_actions 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +218 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/administrate_batch_actions.gemspec +38 -0
- data/app/assets/javascripts/administrate_batch_actions/script.js +33 -0
- data/app/views/shared/administrate_batch_actions/_button.html.erb +1 -0
- data/app/views/shared/administrate_batch_actions/_checkbox.html.erb +3 -0
- data/app/views/shared/administrate_batch_actions/_select_all.html.erb +3 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/initializers/administrate_batch_actions.rb +1 -0
- data/config/routes.rb +28 -0
- data/lib/administrate_batch_actions.rb +19 -0
- data/lib/administrate_batch_actions/helpers.rb +17 -0
- data/lib/administrate_batch_actions/version.rb +3 -0
- metadata +162 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2aad9212d68311a11e3fd64d580a0b10d329cc14c02805f59c1c85587e32c555
|
4
|
+
data.tar.gz: dc7aa8df9038cc92de28c597be45169cc725026a532dc83a2efa069b83b573cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5f3fd76300782922b1a72fc5e05e513ca5c50c112b844779bd8d81eb83300c1ef1604468e4c0394077c3f0f77466cdc6d06e246afa6104c015b9b60a8f941c0e
|
7
|
+
data.tar.gz: 0e9bee44d6050f25d98f129deb207ad8c6d8d2d3409c0f15f5eb6c9bb411a4aeb6e7862a6287789dce67a3e8df3518c4df5ae47bde23777708a2f31bd11d6a32
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at andrerpbts@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in administrate_batch_actions.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
|
10
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
administrate_batch_actions (0.1.0)
|
5
|
+
administrate
|
6
|
+
rails (>= 5.2)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actioncable (6.1.4)
|
12
|
+
actionpack (= 6.1.4)
|
13
|
+
activesupport (= 6.1.4)
|
14
|
+
nio4r (~> 2.0)
|
15
|
+
websocket-driver (>= 0.6.1)
|
16
|
+
actionmailbox (6.1.4)
|
17
|
+
actionpack (= 6.1.4)
|
18
|
+
activejob (= 6.1.4)
|
19
|
+
activerecord (= 6.1.4)
|
20
|
+
activestorage (= 6.1.4)
|
21
|
+
activesupport (= 6.1.4)
|
22
|
+
mail (>= 2.7.1)
|
23
|
+
actionmailer (6.1.4)
|
24
|
+
actionpack (= 6.1.4)
|
25
|
+
actionview (= 6.1.4)
|
26
|
+
activejob (= 6.1.4)
|
27
|
+
activesupport (= 6.1.4)
|
28
|
+
mail (~> 2.5, >= 2.5.4)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
actionpack (6.1.4)
|
31
|
+
actionview (= 6.1.4)
|
32
|
+
activesupport (= 6.1.4)
|
33
|
+
rack (~> 2.0, >= 2.0.9)
|
34
|
+
rack-test (>= 0.6.3)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
+
actiontext (6.1.4)
|
38
|
+
actionpack (= 6.1.4)
|
39
|
+
activerecord (= 6.1.4)
|
40
|
+
activestorage (= 6.1.4)
|
41
|
+
activesupport (= 6.1.4)
|
42
|
+
nokogiri (>= 1.8.5)
|
43
|
+
actionview (6.1.4)
|
44
|
+
activesupport (= 6.1.4)
|
45
|
+
builder (~> 3.1)
|
46
|
+
erubi (~> 1.4)
|
47
|
+
rails-dom-testing (~> 2.0)
|
48
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
49
|
+
activejob (6.1.4)
|
50
|
+
activesupport (= 6.1.4)
|
51
|
+
globalid (>= 0.3.6)
|
52
|
+
activemodel (6.1.4)
|
53
|
+
activesupport (= 6.1.4)
|
54
|
+
activerecord (6.1.4)
|
55
|
+
activemodel (= 6.1.4)
|
56
|
+
activesupport (= 6.1.4)
|
57
|
+
activestorage (6.1.4)
|
58
|
+
actionpack (= 6.1.4)
|
59
|
+
activejob (= 6.1.4)
|
60
|
+
activerecord (= 6.1.4)
|
61
|
+
activesupport (= 6.1.4)
|
62
|
+
marcel (~> 1.0.0)
|
63
|
+
mini_mime (>= 1.1.0)
|
64
|
+
activesupport (6.1.4)
|
65
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
66
|
+
i18n (>= 1.6, < 2)
|
67
|
+
minitest (>= 5.1)
|
68
|
+
tzinfo (~> 2.0)
|
69
|
+
zeitwerk (~> 2.3)
|
70
|
+
administrate (0.16.0)
|
71
|
+
actionpack (>= 5.0)
|
72
|
+
actionview (>= 5.0)
|
73
|
+
activerecord (>= 5.0)
|
74
|
+
datetime_picker_rails (~> 0.0.7)
|
75
|
+
jquery-rails (>= 4.0)
|
76
|
+
kaminari (>= 1.0)
|
77
|
+
momentjs-rails (~> 2.8)
|
78
|
+
sassc-rails (~> 2.1)
|
79
|
+
selectize-rails (~> 0.6)
|
80
|
+
builder (3.2.4)
|
81
|
+
coderay (1.1.3)
|
82
|
+
concurrent-ruby (1.1.9)
|
83
|
+
crass (1.0.6)
|
84
|
+
datetime_picker_rails (0.0.7)
|
85
|
+
momentjs-rails (>= 2.8.1)
|
86
|
+
diff-lcs (1.3)
|
87
|
+
erubi (1.10.0)
|
88
|
+
ffi (1.15.3)
|
89
|
+
globalid (0.5.2)
|
90
|
+
activesupport (>= 5.0)
|
91
|
+
i18n (1.8.10)
|
92
|
+
concurrent-ruby (~> 1.0)
|
93
|
+
jquery-rails (4.4.0)
|
94
|
+
rails-dom-testing (>= 1, < 3)
|
95
|
+
railties (>= 4.2.0)
|
96
|
+
thor (>= 0.14, < 2.0)
|
97
|
+
kaminari (1.2.1)
|
98
|
+
activesupport (>= 4.1.0)
|
99
|
+
kaminari-actionview (= 1.2.1)
|
100
|
+
kaminari-activerecord (= 1.2.1)
|
101
|
+
kaminari-core (= 1.2.1)
|
102
|
+
kaminari-actionview (1.2.1)
|
103
|
+
actionview
|
104
|
+
kaminari-core (= 1.2.1)
|
105
|
+
kaminari-activerecord (1.2.1)
|
106
|
+
activerecord
|
107
|
+
kaminari-core (= 1.2.1)
|
108
|
+
kaminari-core (1.2.1)
|
109
|
+
loofah (2.12.0)
|
110
|
+
crass (~> 1.0.2)
|
111
|
+
nokogiri (>= 1.5.9)
|
112
|
+
mail (2.7.1)
|
113
|
+
mini_mime (>= 0.1.1)
|
114
|
+
marcel (1.0.1)
|
115
|
+
method_source (1.0.0)
|
116
|
+
mini_mime (1.1.0)
|
117
|
+
mini_portile2 (2.6.1)
|
118
|
+
minitest (5.14.4)
|
119
|
+
momentjs-rails (2.20.1)
|
120
|
+
railties (>= 3.1)
|
121
|
+
nio4r (2.5.8)
|
122
|
+
nokogiri (1.12.3)
|
123
|
+
mini_portile2 (~> 2.6.1)
|
124
|
+
racc (~> 1.4)
|
125
|
+
pry (0.14.1)
|
126
|
+
coderay (~> 1.1)
|
127
|
+
method_source (~> 1.0)
|
128
|
+
racc (1.5.2)
|
129
|
+
rack (2.2.3)
|
130
|
+
rack-test (1.1.0)
|
131
|
+
rack (>= 1.0, < 3)
|
132
|
+
rails (6.1.4)
|
133
|
+
actioncable (= 6.1.4)
|
134
|
+
actionmailbox (= 6.1.4)
|
135
|
+
actionmailer (= 6.1.4)
|
136
|
+
actionpack (= 6.1.4)
|
137
|
+
actiontext (= 6.1.4)
|
138
|
+
actionview (= 6.1.4)
|
139
|
+
activejob (= 6.1.4)
|
140
|
+
activemodel (= 6.1.4)
|
141
|
+
activerecord (= 6.1.4)
|
142
|
+
activestorage (= 6.1.4)
|
143
|
+
activesupport (= 6.1.4)
|
144
|
+
bundler (>= 1.15.0)
|
145
|
+
railties (= 6.1.4)
|
146
|
+
sprockets-rails (>= 2.0.0)
|
147
|
+
rails-dom-testing (2.0.3)
|
148
|
+
activesupport (>= 4.2.0)
|
149
|
+
nokogiri (>= 1.6)
|
150
|
+
rails-html-sanitizer (1.3.0)
|
151
|
+
loofah (~> 2.3)
|
152
|
+
railties (6.1.4)
|
153
|
+
actionpack (= 6.1.4)
|
154
|
+
activesupport (= 6.1.4)
|
155
|
+
method_source
|
156
|
+
rake (>= 0.13)
|
157
|
+
thor (~> 1.0)
|
158
|
+
rake (10.5.0)
|
159
|
+
rspec (3.8.0)
|
160
|
+
rspec-core (~> 3.8.0)
|
161
|
+
rspec-expectations (~> 3.8.0)
|
162
|
+
rspec-mocks (~> 3.8.0)
|
163
|
+
rspec-core (3.8.0)
|
164
|
+
rspec-support (~> 3.8.0)
|
165
|
+
rspec-expectations (3.8.1)
|
166
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
167
|
+
rspec-support (~> 3.8.0)
|
168
|
+
rspec-mocks (3.8.0)
|
169
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
170
|
+
rspec-support (~> 3.8.0)
|
171
|
+
rspec-rails (3.8.3)
|
172
|
+
actionpack (>= 3.0)
|
173
|
+
activesupport (>= 3.0)
|
174
|
+
railties (>= 3.0)
|
175
|
+
rspec-core (~> 3.8.0)
|
176
|
+
rspec-expectations (~> 3.8.0)
|
177
|
+
rspec-mocks (~> 3.8.0)
|
178
|
+
rspec-support (~> 3.8.0)
|
179
|
+
rspec-support (3.8.0)
|
180
|
+
sassc (2.4.0)
|
181
|
+
ffi (~> 1.9)
|
182
|
+
sassc-rails (2.1.2)
|
183
|
+
railties (>= 4.0.0)
|
184
|
+
sassc (>= 2.0)
|
185
|
+
sprockets (> 3.0)
|
186
|
+
sprockets-rails
|
187
|
+
tilt
|
188
|
+
selectize-rails (0.12.6)
|
189
|
+
sprockets (4.0.2)
|
190
|
+
concurrent-ruby (~> 1.0)
|
191
|
+
rack (> 1, < 3)
|
192
|
+
sprockets-rails (3.2.2)
|
193
|
+
actionpack (>= 4.0)
|
194
|
+
activesupport (>= 4.0)
|
195
|
+
sprockets (>= 3.0.0)
|
196
|
+
thor (1.1.0)
|
197
|
+
tilt (2.0.10)
|
198
|
+
tzinfo (2.0.4)
|
199
|
+
concurrent-ruby (~> 1.0)
|
200
|
+
websocket-driver (0.7.5)
|
201
|
+
websocket-extensions (>= 0.1.0)
|
202
|
+
websocket-extensions (0.1.5)
|
203
|
+
zeitwerk (2.4.2)
|
204
|
+
|
205
|
+
PLATFORMS
|
206
|
+
ruby
|
207
|
+
|
208
|
+
DEPENDENCIES
|
209
|
+
administrate_batch_actions!
|
210
|
+
bundler (~> 1.16)
|
211
|
+
pry
|
212
|
+
rake (~> 10.0)
|
213
|
+
rspec (~> 3.0)
|
214
|
+
rspec-rails (~> 3.0)
|
215
|
+
tzinfo-data
|
216
|
+
|
217
|
+
BUNDLED WITH
|
218
|
+
2.2.26
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 André Rodrigues
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# AdministrateBatchActions
|
2
|
+
|
3
|
+
This gem allows you to quickly embed a UI on resources' list page, by using the UI, you are able to do batch actions, such as batch deletion or batch approval etc.
|
4
|
+
|
5
|
+
The helper addes checkboxes and batch action button which allows you to integrate some customized actions in `administrate` way.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'administrate_batch_actions'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install administrate_batch_actions
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
The gem introduces three helper methods below:
|
26
|
+
```
|
27
|
+
administrate_batch_actions_select_all() # renders Select All checkbox
|
28
|
+
```
|
29
|
+
```
|
30
|
+
administrate_batch_actions_checkbox(resource.id) # individual row checkbox
|
31
|
+
```
|
32
|
+
```
|
33
|
+
administrate_batch_actions_button(batch_action_name, target_handling_path) # batch action submit button
|
34
|
+
```
|
35
|
+
|
36
|
+
You need to create custom Administrate views and insert the helpers above.
|
37
|
+
|
38
|
+
Afterwards-- define your custom controller actions named as `*_batch_action` e.g.:
|
39
|
+
* `def delete_batch_action ; ...; end`
|
40
|
+
* `def approve_batch_action; ...; end`
|
41
|
+
* etc
|
42
|
+
|
43
|
+
The gem will auto-generate route entries for controller actions matches to this pattern. For instance-- if I have an action below:
|
44
|
+
|
45
|
+
```
|
46
|
+
def delete_batch_action
|
47
|
+
User.find(params[:batch_action_ids]).each(&:destroy)
|
48
|
+
redirect_to :admin_users, notice: "Successfully deleted #{params[:batch_action_ids].size} users"
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
The gem will auto-generate the following route:
|
53
|
+
```
|
54
|
+
delete_batch_action_admin_users POST /admin/users/delete_batch_action(.:format) admin/users#delete_batch_action
|
55
|
+
```
|
56
|
+
|
57
|
+
## Development
|
58
|
+
|
59
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
60
|
+
|
61
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/administrate_batch_actions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
70
|
+
|
71
|
+
## Code of Conduct
|
72
|
+
|
73
|
+
Everyone interacting in the AdministrateBatchActions project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/administrate_batch_actions/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'administrate_batch_actions/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'administrate_batch_actions'
|
7
|
+
spec.version = AdministrateBatchActions::VERSION
|
8
|
+
spec.authors = ['Sourcelabs LLC']
|
9
|
+
spec.email = ['andrei@sourcelabs.io']
|
10
|
+
spec.homepage = 'https://github.com/SourceLabsLLC/administrate-batch-actions'
|
11
|
+
spec.summary = 'Batch Actions plugin for Administrate'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
# if spec.respond_to?(:metadata)
|
18
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
19
|
+
# else
|
20
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
21
|
+
# "public gem pushes."
|
22
|
+
# end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
+
spec.add_development_dependency 'rspec-rails', '~> 3.0'
|
35
|
+
spec.add_development_dependency 'pry'
|
36
|
+
spec.add_dependency 'administrate'
|
37
|
+
spec.add_dependency 'rails', '>= 5.2'
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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']");
|
4
|
+
|
5
|
+
if (selectAllCheckboxes) {
|
6
|
+
selectAllCheckboxes.addEventListener('click', function(){
|
7
|
+
checkboxes.forEach(function(checkbox) {
|
8
|
+
checkbox.checked = selectAllCheckboxes.checked;
|
9
|
+
});
|
10
|
+
});
|
11
|
+
|
12
|
+
buttons.forEach(function(button){
|
13
|
+
button.addEventListener('click', function(event){
|
14
|
+
var ids = Array.prototype.filter.call(checkboxes, function(checkbox) {
|
15
|
+
if (checkbox.checked) { return checkbox }
|
16
|
+
}).map(function(checkbox) {
|
17
|
+
return 'batch_action_ids[]=' + checkbox.value
|
18
|
+
}).join('&');
|
19
|
+
|
20
|
+
button.href += '?' + ids
|
21
|
+
});
|
22
|
+
});
|
23
|
+
|
24
|
+
checkboxes.forEach(function(checkbox){
|
25
|
+
checkbox.closest('td').addEventListener('click', function(event){
|
26
|
+
event.stopImmediatePropagation();
|
27
|
+
})
|
28
|
+
|
29
|
+
checkbox.addEventListener('click', function(event) {
|
30
|
+
event.stopImmediatePropagation();
|
31
|
+
})
|
32
|
+
})
|
33
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= link_to name, path, class: "button", data: { batch_action_option: 'button', confirm: 'Are you sure to do this?' }, method: :post %>
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "administrate_batch_actions"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.assets.precompile += %w( administrate_batch_actions/script.js )
|
data/config/routes.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
def controllers_for(path)
|
4
|
+
path ||= Rails.root.join('app', 'controllers', 'admin', '**/*.rb')
|
5
|
+
|
6
|
+
Dir[path].each do |file|
|
7
|
+
require_dependency file
|
8
|
+
end
|
9
|
+
|
10
|
+
::Administrate::ApplicationController.descendants
|
11
|
+
end
|
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')
|
20
|
+
|
21
|
+
resources resource.to_sym do
|
22
|
+
post method_name.to_sym, on: :collection
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'active_support'
|
3
|
+
require 'active_support/core_ext'
|
4
|
+
require 'active_support/dependencies'
|
5
|
+
require 'administrate/engine'
|
6
|
+
|
7
|
+
require 'administrate_batch_actions/helpers'
|
8
|
+
require 'administrate_batch_actions/version'
|
9
|
+
|
10
|
+
module AdministrateBatchActions
|
11
|
+
class Engine < ::Rails::Engine
|
12
|
+
Administrate::Engine.add_javascript 'administrate_batch_actions/script'
|
13
|
+
|
14
|
+
initializer "administrate_batch_actions.engine" do |app|
|
15
|
+
ActionView::Base.send :include, AdministrateBatchActions::Helpers
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module AdministrateBatchActions
|
2
|
+
module Helpers
|
3
|
+
def administrate_batch_actions_button(name, path)
|
4
|
+
render partial: 'shared/administrate_batch_actions/button',
|
5
|
+
locals: { name: name, path: path }
|
6
|
+
end
|
7
|
+
|
8
|
+
def administrate_batch_actions_select_all
|
9
|
+
render partial: 'shared/administrate_batch_actions/select_all'
|
10
|
+
end
|
11
|
+
|
12
|
+
def administrate_batch_actions_checkbox(value)
|
13
|
+
render partial: 'shared/administrate_batch_actions/checkbox',
|
14
|
+
locals: { value: value }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: administrate_batch_actions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sourcelabs LLC
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: administrate
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '5.2'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '5.2'
|
111
|
+
description: Batch Actions plugin for Administrate
|
112
|
+
email:
|
113
|
+
- andrei@sourcelabs.io
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- CODE_OF_CONDUCT.md
|
122
|
+
- Gemfile
|
123
|
+
- Gemfile.lock
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- administrate_batch_actions.gemspec
|
128
|
+
- app/assets/javascripts/administrate_batch_actions/script.js
|
129
|
+
- app/views/shared/administrate_batch_actions/_button.html.erb
|
130
|
+
- app/views/shared/administrate_batch_actions/_checkbox.html.erb
|
131
|
+
- app/views/shared/administrate_batch_actions/_select_all.html.erb
|
132
|
+
- bin/console
|
133
|
+
- bin/setup
|
134
|
+
- config/initializers/administrate_batch_actions.rb
|
135
|
+
- config/routes.rb
|
136
|
+
- lib/administrate_batch_actions.rb
|
137
|
+
- lib/administrate_batch_actions/helpers.rb
|
138
|
+
- lib/administrate_batch_actions/version.rb
|
139
|
+
homepage: https://github.com/SourceLabsLLC/administrate-batch-actions
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubygems_version: 3.2.3
|
159
|
+
signing_key:
|
160
|
+
specification_version: 4
|
161
|
+
summary: Batch Actions plugin for Administrate
|
162
|
+
test_files: []
|