active_admin_scoped_collection_actions 0.3.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +20 -6
- data/CHANGELOG.md +4 -0
- data/Gemfile +11 -10
- data/README.md +1 -1
- data/active_admin_scoped_collection_actions.gemspec +1 -2
- data/lib/active_admin_scoped_collection_actions/version.rb +1 -1
- data/tasks/test.rake +11 -3
- data/vendor/assets/javascripts/active_admin_scoped_collection_actions.js +29 -0
- data/vendor/assets/javascripts/lib/dialog_mass_fields_update.js +73 -0
- metadata +16 -25
- data/vendor/assets/javascripts/active_admin_scoped_collection_actions.js.coffee +0 -25
- data/vendor/assets/javascripts/lib/dialog_mass_fields_update.js.coffee +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f9192c809349fab7e5444cea16d61270bd75e2a113c8cc79d1567ebea4c1dd75
|
4
|
+
data.tar.gz: f6fd7507751f7c7297f861fce239fb42a055703c619bea1292d0d98deb6ece6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a46f91dd43671741a6491ba4e8c5188094bb803f2df0c0a8821d4b0a900b26dd75acf5e2d7c86534b9c03b5ae80a9b472482bf5b1998d61112de01117b255e6c
|
7
|
+
data.tar.gz: 234f4d2c251e0d48c3db9b1241c5628e32d2a57bf817e4b3884a41a5e150e5f06273aedd0a0ec999d5ba6d669f34caba9d12d0723cbf063a9f540942bdf4855d
|
data/.travis.yml
CHANGED
@@ -1,8 +1,22 @@
|
|
1
|
+
sudo: required
|
2
|
+
|
3
|
+
language: ruby
|
4
|
+
|
5
|
+
addons:
|
6
|
+
chrome: stable
|
7
|
+
|
8
|
+
before_install:
|
9
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
10
|
+
- gem install bundler -v '< 2'
|
11
|
+
|
1
12
|
script: bundle exec rspec spec
|
13
|
+
|
14
|
+
env:
|
15
|
+
matrix:
|
16
|
+
- RAILS=4.2.0 AA=1.1.0
|
17
|
+
- RAILS=5.2.0 AA=1.4.0
|
18
|
+
- RAILS=5.2.0 AA=2.0.0
|
19
|
+
|
2
20
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.3
|
5
|
-
before_install:
|
6
|
-
- gem install bundler -v '= 1.9.3'
|
7
|
-
- gem update --system
|
8
|
-
- gem --version
|
21
|
+
- 2.4.6
|
22
|
+
- 2.6.3
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in activeadmin_scoped_collection_actions.gemspec
|
4
3
|
gemspec
|
4
|
+
|
5
5
|
group :test do
|
6
|
-
gem '
|
7
|
-
gem 'rails',
|
8
|
-
|
6
|
+
gem 'activeadmin', "~> #{ENV['AA'] || '2.0.0'}"
|
7
|
+
gem 'rails', "~> #{ENV['RAILS'] || '5.2.0'}"
|
8
|
+
|
9
|
+
gem 'capybara'
|
10
|
+
gem 'chromedriver-helper'
|
11
|
+
gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
|
12
|
+
gem 'database_cleaner'
|
9
13
|
gem 'draper'
|
10
|
-
gem 'activeadmin', '1.0.0'
|
11
|
-
gem 'sass-rails'
|
12
|
-
gem 'sqlite3'
|
13
14
|
gem 'launchy'
|
14
|
-
gem '
|
15
|
-
gem '
|
15
|
+
gem 'rspec-rails'
|
16
|
+
gem 'sass-rails'
|
16
17
|
gem 'selenium-webdriver'
|
17
|
-
gem '
|
18
|
+
gem 'sqlite3', '~> 1.3.6'
|
18
19
|
end
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ And then execute:
|
|
29
29
|
$ bundle
|
30
30
|
```
|
31
31
|
|
32
|
-
Add the following line at the end of "app/assets/javascript/active_admin.js
|
32
|
+
Add the following line at the end of "app/assets/javascript/active_admin.js":
|
33
33
|
|
34
34
|
```javascript
|
35
35
|
//= require active_admin_scoped_collection_actions
|
@@ -17,6 +17,5 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.
|
21
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
20
|
+
spec.add_dependency "activeadmin", ">= 1.1", "< 3.a"
|
22
21
|
end
|
data/tasks/test.rake
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
-
desc
|
1
|
+
desc 'Creates a test rails app for the specs to run against'
|
2
2
|
task :setup do
|
3
3
|
require 'rails/version'
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
rails_new_args = %w[
|
6
|
+
--skip-turbolinks
|
7
|
+
--skip-spring
|
8
|
+
--skip-bootsnap
|
9
|
+
-m
|
10
|
+
spec/support/rails_template.rb
|
11
|
+
].join(' ')
|
12
|
+
|
13
|
+
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} #{rails_new_args}"
|
6
14
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
//= require ./lib/dialog_mass_fields_update
|
2
|
+
|
3
|
+
$(document).ready(() =>
|
4
|
+
|
5
|
+
$(document).on('click', '.scoped_collection_action_button', function(e) {
|
6
|
+
e.preventDefault();
|
7
|
+
const fields = JSON.parse( $(this).attr('data') );
|
8
|
+
|
9
|
+
return ActiveAdmin.dialogMassFieldsUpdate(fields['confirm'], fields['inputs'],
|
10
|
+
inputs=> {
|
11
|
+
const url = window.location.pathname + '/batch_action' + window.location.search;
|
12
|
+
const form_data = {
|
13
|
+
changes: inputs,
|
14
|
+
collection_selection: [],
|
15
|
+
authenticity_token: fields['auth_token'],
|
16
|
+
batch_action: fields['batch_action']
|
17
|
+
};
|
18
|
+
$('.paginated_collection').find('input.collection_selection:checked').each((i, el) => form_data["collection_selection"].push($(el).val()));
|
19
|
+
|
20
|
+
return $.post(url, form_data).always(function(data, textStatus, jqXHR) {
|
21
|
+
if (jqXHR.getResponseHeader('Location')) {
|
22
|
+
return window.location.assign(jqXHR.getResponseHeader('Location'));
|
23
|
+
} else {
|
24
|
+
return window.location.reload();
|
25
|
+
}
|
26
|
+
});
|
27
|
+
});
|
28
|
+
})
|
29
|
+
);
|
@@ -0,0 +1,73 @@
|
|
1
|
+
ActiveAdmin.dialogMassFieldsUpdate = function(message, inputs, callback){
|
2
|
+
let html = `<form id="dialog_confirm" title="${message}"><div stype="padding-right:4px;padding-left:1px;margin-right:2px"><ul>`;
|
3
|
+
for (let name in inputs) {
|
4
|
+
var elem, opts, wrapper;
|
5
|
+
let type = inputs[name];
|
6
|
+
if (/^(datepicker|checkbox|text)$/.test(type)) {
|
7
|
+
wrapper = 'input';
|
8
|
+
} else if ($.isArray(type)) {
|
9
|
+
[wrapper, elem, opts, type] = Array.from(['select', 'option', type, '']);
|
10
|
+
} else {
|
11
|
+
throw new Error(`Unsupported input type: {${name}: ${type}}`);
|
12
|
+
}
|
13
|
+
|
14
|
+
let klass = type === 'datepicker' ? type : '';
|
15
|
+
html += `<li>
|
16
|
+
<input type='checkbox' class='mass_update_protect_fild_flag' value='Y' id="mass_update_dialog_${name}" />
|
17
|
+
<label for="mass_update_dialog_${name}"> ${name.charAt(0).toUpperCase() + name.slice(1)}</label>
|
18
|
+
<${wrapper} name="${name}" class="${klass}" type="${type}" disabled="disabled">` +
|
19
|
+
(opts ? ((() => {
|
20
|
+
const result = [];
|
21
|
+
|
22
|
+
for (let v of Array.from(opts)) {
|
23
|
+
const $elem = $(`<${elem}/>`);
|
24
|
+
if ($.isArray(v)) {
|
25
|
+
$elem.text(v[0]).val(v[1]);
|
26
|
+
} else {
|
27
|
+
$elem.text(v);
|
28
|
+
}
|
29
|
+
result.push($elem.wrap('<div>').parent().html());
|
30
|
+
}
|
31
|
+
|
32
|
+
return result;
|
33
|
+
})()).join('') : '');
|
34
|
+
if (wrapper === 'select') {
|
35
|
+
html += `</${wrapper}>`;
|
36
|
+
}
|
37
|
+
html += "</li>";
|
38
|
+
|
39
|
+
[wrapper, elem, opts, type, klass] = Array.from([]);
|
40
|
+
} // unset any temporary variables
|
41
|
+
|
42
|
+
html += "</ul></div></form>";
|
43
|
+
|
44
|
+
const form = $(html).appendTo('body');
|
45
|
+
|
46
|
+
$('body').trigger('mass_update_modal_dialog:before_open', [form]);
|
47
|
+
|
48
|
+
return form.dialog({
|
49
|
+
modal: true,
|
50
|
+
dialogClass: 'active_admin_dialog active_admin_dialog_mass_update_by_filter',
|
51
|
+
maxHeight: window.innerHeight - (window.innerHeight * 0.1),
|
52
|
+
open() {
|
53
|
+
$('body').trigger('mass_update_modal_dialog:after_open', [form]);
|
54
|
+
return $('.mass_update_protect_fild_flag').on('change', function(e) {
|
55
|
+
if (this.checked) {
|
56
|
+
return $(e.target).next().next().removeAttr('disabled').trigger("chosen:updated");
|
57
|
+
} else {
|
58
|
+
return $(e.target).next().next().attr('disabled', 'disabled').trigger("chosen:updated");
|
59
|
+
}
|
60
|
+
});
|
61
|
+
},
|
62
|
+
buttons: {
|
63
|
+
OK(e){
|
64
|
+
$(e.target).closest('.ui-dialog-buttonset').html('<span>Processing. Please wait...</span>');
|
65
|
+
return callback($(this).serializeObject());
|
66
|
+
},
|
67
|
+
Cancel() {
|
68
|
+
$('.mass_update_protect_fild_flag').off('change');
|
69
|
+
return $(this).dialog('close').remove();
|
70
|
+
}
|
71
|
+
}
|
72
|
+
});
|
73
|
+
};
|
metadata
CHANGED
@@ -1,43 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_admin_scoped_collection_actions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gena M.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activeadmin
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
20
|
-
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.8'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
19
|
+
version: '1.1'
|
20
|
+
- - "<"
|
32
21
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
type: :
|
22
|
+
version: 3.a
|
23
|
+
type: :runtime
|
35
24
|
prerelease: false
|
36
25
|
version_requirements: !ruby/object:Gem::Requirement
|
37
26
|
requirements:
|
38
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.1'
|
30
|
+
- - "<"
|
39
31
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
32
|
+
version: 3.a
|
41
33
|
description: Plugin for ActiveAdmin. Provides batch Update and Delete for scoped_collection
|
42
34
|
(Filters + Scope) across all pages.
|
43
35
|
email:
|
@@ -68,8 +60,8 @@ files:
|
|
68
60
|
- screenshots/pupup.png
|
69
61
|
- screenshots/sidebar.png
|
70
62
|
- tasks/test.rake
|
71
|
-
- vendor/assets/javascripts/active_admin_scoped_collection_actions.js
|
72
|
-
- vendor/assets/javascripts/lib/dialog_mass_fields_update.js
|
63
|
+
- vendor/assets/javascripts/active_admin_scoped_collection_actions.js
|
64
|
+
- vendor/assets/javascripts/lib/dialog_mass_fields_update.js
|
73
65
|
- vendor/assets/stylesheets/active_admin_scoped_collection_actions.scss
|
74
66
|
homepage: https://github.com/activeadmin-plugins/active_admin_scoped_collection_actions
|
75
67
|
licenses:
|
@@ -90,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
82
|
- !ruby/object:Gem::Version
|
91
83
|
version: '0'
|
92
84
|
requirements: []
|
93
|
-
|
94
|
-
rubygems_version: 2.6.13
|
85
|
+
rubygems_version: 3.0.2
|
95
86
|
signing_key:
|
96
87
|
specification_version: 4
|
97
88
|
summary: scoped_collection actions extension for ActiveAdmin
|
@@ -1,25 +0,0 @@
|
|
1
|
-
#= require ./lib/dialog_mass_fields_update
|
2
|
-
|
3
|
-
$(document).ready ->
|
4
|
-
|
5
|
-
$(document).on 'click', '.scoped_collection_action_button', (e) ->
|
6
|
-
e.preventDefault()
|
7
|
-
fields = JSON.parse( $(this).attr('data') )
|
8
|
-
|
9
|
-
ActiveAdmin.dialogMassFieldsUpdate fields['confirm'], fields['inputs'],
|
10
|
-
(inputs)=>
|
11
|
-
url = window.location.pathname + '/batch_action' + window.location.search
|
12
|
-
form_data = {
|
13
|
-
changes: inputs,
|
14
|
-
collection_selection: [],
|
15
|
-
authenticity_token: fields['auth_token'],
|
16
|
-
batch_action: fields['batch_action']
|
17
|
-
}
|
18
|
-
$('.paginated_collection').find('input.collection_selection:checked').each (i, el) ->
|
19
|
-
form_data["collection_selection"].push($(el).val())
|
20
|
-
|
21
|
-
$.post(url, form_data).always (data, textStatus, jqXHR) ->
|
22
|
-
if jqXHR.getResponseHeader('Location')
|
23
|
-
window.location.assign jqXHR.getResponseHeader('Location')
|
24
|
-
else
|
25
|
-
window.location.reload()
|
@@ -1,54 +0,0 @@
|
|
1
|
-
ActiveAdmin.dialogMassFieldsUpdate = (message, inputs, callback)->
|
2
|
-
html = """<form id="dialog_confirm" title="#{message}"><div stype="padding-right:4px;padding-left:1px;margin-right:2px"><ul>"""
|
3
|
-
for name, type of inputs
|
4
|
-
if /^(datepicker|checkbox|text)$/.test type
|
5
|
-
wrapper = 'input'
|
6
|
-
else if $.isArray type
|
7
|
-
[wrapper, elem, opts, type] = ['select', 'option', type, '']
|
8
|
-
else
|
9
|
-
throw new Error "Unsupported input type: {#{name}: #{type}}"
|
10
|
-
|
11
|
-
klass = if type is 'datepicker' then type else ''
|
12
|
-
html += """<li>
|
13
|
-
<input type='checkbox' class='mass_update_protect_fild_flag' value='Y' id="mass_update_dialog_#{name}" />
|
14
|
-
<label for="mass_update_dialog_#{name}"> #{name.charAt(0).toUpperCase() + name.slice(1)}</label>
|
15
|
-
<#{wrapper} name="#{name}" class="#{klass}" type="#{type}" disabled="disabled">""" +
|
16
|
-
(if opts then (
|
17
|
-
for v in opts
|
18
|
-
$elem = $("<#{elem}/>")
|
19
|
-
if $.isArray v
|
20
|
-
$elem.text(v[0]).val(v[1])
|
21
|
-
else
|
22
|
-
$elem.text(v)
|
23
|
-
$elem.wrap('<div>').parent().html()
|
24
|
-
).join '' else '')
|
25
|
-
if wrapper == 'select'
|
26
|
-
html += "</#{wrapper}>"
|
27
|
-
html += "</li>"
|
28
|
-
|
29
|
-
[wrapper, elem, opts, type, klass] = [] # unset any temporary variables
|
30
|
-
|
31
|
-
html += "</ul></div></form>"
|
32
|
-
|
33
|
-
form = $(html).appendTo('body')
|
34
|
-
|
35
|
-
$('body').trigger 'mass_update_modal_dialog:before_open', [form]
|
36
|
-
|
37
|
-
form.dialog
|
38
|
-
modal: true
|
39
|
-
dialogClass: 'active_admin_dialog active_admin_dialog_mass_update_by_filter',
|
40
|
-
maxHeight: window.innerHeight - window.innerHeight * 0.1,
|
41
|
-
open: ->
|
42
|
-
$('body').trigger 'mass_update_modal_dialog:after_open', [form]
|
43
|
-
$('.mass_update_protect_fild_flag').on 'change', (e) ->
|
44
|
-
if this.checked
|
45
|
-
$(e.target).next().next().removeAttr('disabled').trigger("chosen:updated")
|
46
|
-
else
|
47
|
-
$(e.target).next().next().attr('disabled', 'disabled').trigger("chosen:updated")
|
48
|
-
buttons:
|
49
|
-
OK: (e)->
|
50
|
-
$(e.target).closest('.ui-dialog-buttonset').html('<span>Processing. Please wait...</span>')
|
51
|
-
callback $(@).serializeObject()
|
52
|
-
Cancel: ->
|
53
|
-
$('.mass_update_protect_fild_flag').off('change')
|
54
|
-
$(@).dialog('close').remove()
|