activeadmin 2.2.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeadmin might be problematic. Click here for more details.

Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +111 -30
  3. data/CONTRIBUTING.md +50 -44
  4. data/README.md +9 -2
  5. data/app/assets/javascripts/active_admin/base.js +519 -0
  6. data/app/assets/stylesheets/active_admin/_base.scss +29 -29
  7. data/app/assets/stylesheets/active_admin/_header.scss +3 -5
  8. data/app/assets/stylesheets/active_admin/_mixins.scss +1 -1
  9. data/{vendor → app}/assets/stylesheets/active_admin/_normalize.scss +0 -0
  10. data/app/assets/stylesheets/active_admin/components/_tables.scss +1 -2
  11. data/app/assets/stylesheets/active_admin/mixins/_all.scss +8 -8
  12. data/app/assets/stylesheets/active_admin/mixins/_variables.scss +5 -0
  13. data/app/assets/stylesheets/active_admin/print.scss +2 -2
  14. data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +1 -1
  15. data/app/javascript/active_admin/base.js +28 -0
  16. data/app/{assets/javascripts/active_admin/ext/jquery-ui.es6 → javascript/active_admin/ext/jquery-ui.js} +0 -0
  17. data/app/{assets/javascripts/active_admin/ext/jquery.es6 → javascript/active_admin/ext/jquery.js} +0 -0
  18. data/app/{assets/javascripts/active_admin/lib/batch_actions.es6 → javascript/active_admin/initializers/batch-actions.js} +9 -3
  19. data/app/javascript/active_admin/initializers/checkbox-toggler.js +3 -0
  20. data/app/{assets/javascripts/active_admin/initializers/datepicker.es6 → javascript/active_admin/initializers/datepicker.js} +0 -0
  21. data/app/javascript/active_admin/initializers/dropdown-menu.js +9 -0
  22. data/app/javascript/active_admin/initializers/filters.js +10 -0
  23. data/app/{assets/javascripts/active_admin/lib/has_many.es6 → javascript/active_admin/initializers/has-many.js} +0 -0
  24. data/app/javascript/active_admin/initializers/per-page.js +13 -0
  25. data/app/javascript/active_admin/initializers/table-checkbox-toggler.js +3 -0
  26. data/app/{assets/javascripts/active_admin/initializers/tabs.es6 → javascript/active_admin/initializers/tabs.js} +0 -0
  27. data/app/{assets/javascripts/active_admin/lib/checkbox-toggler.es6 → javascript/active_admin/lib/checkbox-toggler.js} +2 -2
  28. data/app/{assets/javascripts/active_admin/lib/dropdown-menu.es6 → javascript/active_admin/lib/dropdown-menu.js} +2 -9
  29. data/app/javascript/active_admin/lib/filters.js +39 -0
  30. data/app/{assets/javascripts/active_admin/lib/modal_dialog.es6 → javascript/active_admin/lib/modal-dialog.js} +3 -1
  31. data/app/javascript/active_admin/lib/per-page.js +38 -0
  32. data/app/{assets/javascripts/active_admin/lib/table-checkbox-toggler.es6 → javascript/active_admin/lib/table-checkbox-toggler.js} +4 -2
  33. data/app/javascript/active_admin/lib/utils.js +40 -0
  34. data/app/views/kaminari/active_admin_countless/_first_page.html.erb +11 -0
  35. data/app/views/kaminari/active_admin_countless/_gap.html.erb +8 -0
  36. data/app/views/kaminari/active_admin_countless/_next_page.html.erb +11 -0
  37. data/app/views/kaminari/active_admin_countless/_page.html.erb +12 -0
  38. data/app/views/kaminari/active_admin_countless/_paginator.html.erb +24 -0
  39. data/app/views/kaminari/active_admin_countless/_prev_page.html.erb +11 -0
  40. data/config/locales/az.yml +138 -0
  41. data/config/locales/ca.yml +0 -1
  42. data/config/locales/de.yml +18 -0
  43. data/config/locales/es.yml +3 -3
  44. data/config/locales/fr.yml +4 -4
  45. data/config/locales/sk.yml +59 -0
  46. data/docs/1-general-configuration.md +20 -0
  47. data/docs/2-resource-customization.md +1 -1
  48. data/docs/3-index-pages.md +1 -1
  49. data/docs/3-index-pages/index-as-table.md +7 -0
  50. data/docs/9-batch-actions.md +2 -2
  51. data/docs/Gemfile +0 -1
  52. data/docs/Gemfile.lock +103 -105
  53. data/docs/_config.yml +2 -0
  54. data/docs/_includes/top-menu.html +2 -2
  55. data/docs/index.html +108 -7
  56. data/docs/stylesheets/main.css +29 -0
  57. data/lib/active_admin.rb +0 -1
  58. data/lib/active_admin/application.rb +1 -1
  59. data/lib/active_admin/csv_builder.rb +1 -2
  60. data/lib/active_admin/filters/active_filter.rb +1 -1
  61. data/lib/active_admin/filters/resource_extension.rb +24 -0
  62. data/lib/active_admin/generators/boilerplate.rb +12 -4
  63. data/lib/active_admin/inputs/filters/date_range_input.rb +15 -12
  64. data/lib/active_admin/namespace_settings.rb +13 -0
  65. data/lib/active_admin/order_clause.rb +1 -1
  66. data/lib/active_admin/resource.rb +14 -1
  67. data/lib/active_admin/resource/belongs_to.rb +3 -0
  68. data/lib/active_admin/resource/model.rb +15 -0
  69. data/lib/active_admin/resource/routes.rb +11 -3
  70. data/lib/active_admin/resource_controller.rb +2 -0
  71. data/lib/active_admin/resource_controller/decorators.rb +2 -2
  72. data/lib/active_admin/resource_controller/polymorphic_routes.rb +37 -0
  73. data/lib/active_admin/version.rb +1 -1
  74. data/lib/active_admin/views/components/paginated_collection.rb +3 -2
  75. data/lib/active_admin/views/components/table_for.rb +1 -0
  76. data/lib/active_admin/views/index_as_table.rb +7 -0
  77. data/lib/active_admin/views/pages/base.rb +5 -3
  78. data/lib/active_admin/views/pages/index.rb +1 -0
  79. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +14 -1
  80. data/lib/generators/active_admin/resource/templates/admin.rb.erb +4 -2
  81. metadata +35 -43
  82. data/app/assets/images/active_admin/nested_menu_arrow.gif +0 -0
  83. data/app/assets/images/active_admin/nested_menu_arrow_dark.gif +0 -0
  84. data/app/assets/images/active_admin/orderable.png +0 -0
  85. data/app/assets/javascripts/active_admin/base.es6 +0 -23
  86. data/app/assets/javascripts/active_admin/initializers/filters.es6 +0 -45
  87. data/app/assets/javascripts/active_admin/lib/active_admin.es6 +0 -41
  88. data/app/assets/javascripts/active_admin/lib/per_page.es6 +0 -47
data/README.md CHANGED
@@ -21,6 +21,11 @@ creating elegant backends for website administration.
21
21
  * Try the [live demo][demo].
22
22
  * The [wiki] includes links to tutorials, articles and sample projects.
23
23
 
24
+ ## For enterprise
25
+
26
+ Active Admin for enterprise is available via the Tidelift subscription. [Learn
27
+ More][tidelift_enterprise].
28
+
24
29
  ## Need help?
25
30
 
26
31
  Please use [StackOverflow][stackoverflow] for help requests and how-to questions.
@@ -39,7 +44,7 @@ to ask.
39
44
  ## Want to support us?
40
45
 
41
46
  If you want to support us financially, you can [help fund the project
42
- through a Tidelift subscription][tidelift]. By buying a Tidelift subscription
47
+ through a Tidelift subscription][tidelift_support]. By buying a Tidelift subscription
43
48
  you make sure your whole dependency stack is properly maintained, while also
44
49
  getting a comprehensive view of outdated dependencies, new releases, security
45
50
  alerts, and licensing compatibility issues.
@@ -88,7 +93,7 @@ Thanks to [Open Collective][opencollective contributors] and all our Open Collec
88
93
 
89
94
  [rubygems_badge]: http://img.shields.io/gem/v/activeadmin.svg
90
95
  [rubygems]: https://rubygems.org/gems/activeadmin
91
- [circle_badge]: https://circleci.com/gh/activeadmin/activeadmin/tree/master.svg
96
+ [circle_badge]: https://circleci.com/gh/activeadmin/activeadmin/tree/master.svg?style=svg
92
97
  [circle]: https://circleci.com/gh/activeadmin/activeadmin/tree/master
93
98
  [coverage_badge]: https://api.codeclimate.com/v1/badges/779e407d22bacff19733/test_coverage
94
99
  [coverage]: https://codeclimate.com/github/activeadmin/activeadmin/test_coverage
@@ -96,6 +101,8 @@ Thanks to [Open Collective][opencollective contributors] and all our Open Collec
96
101
  [inch]: http://inch-ci.org/github/activeadmin/activeadmin
97
102
  [tidelift_badge]: https://tidelift.com/badges/github/activeadmin/activeadmin
98
103
  [tidelift]: https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=readme
104
+ [tidelift_enterprise]: https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=referral&utm_campaign=github&utm_content=enterprise
105
+ [tidelift_support]: https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=referral&utm_campaign=github&utm_content=support
99
106
 
100
107
  [docs]: http://activeadmin.info/0-installation.html
101
108
  [demo]: http://demo.activeadmin.info/admin
@@ -0,0 +1,519 @@
1
+ /**
2
+ * Warning: This file is auto-generated, do not modify. Instead, make your changes in 'app/javascript/active_admin/' and run `yarn build`
3
+ */
4
+ //= require jquery3
5
+ //= require jquery-ui/widgets/datepicker
6
+ //= require jquery-ui/widgets/dialog
7
+ //= require jquery-ui/widgets/sortable
8
+ //= require jquery-ui/widgets/tabs
9
+ //= require jquery-ui/widget
10
+ //= require jquery_ujs
11
+ //= require_self
12
+
13
+ (function(global, factory) {
14
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("jquery"), require("jquery-ui/ui/widgets/datepicker"), require("jquery-ui/ui/widgets/dialog"), require("jquery-ui/ui/widgets/sortable"), require("jquery-ui/ui/widgets/tabs"), require("jquery-ui/ui/widget"), require("jquery-ujs")) : typeof define === "function" && define.amd ? define([ "exports", "jquery", "jquery-ui/ui/widgets/datepicker", "jquery-ui/ui/widgets/dialog", "jquery-ui/ui/widgets/sortable", "jquery-ui/ui/widgets/tabs", "jquery-ui/ui/widget", "jquery-ujs" ], factory) : (global = global || self,
15
+ factory(global.ActiveAdmin = {}));
16
+ })(this, function(exports) {
17
+ "use strict";
18
+ $.fn.serializeObject = function() {
19
+ return this.serializeArray().reduce(function(obj, item) {
20
+ obj[item.name] = item.value;
21
+ return obj;
22
+ }, {});
23
+ };
24
+ $.ui.dialog.prototype._focusTabbable = function() {
25
+ this.uiDialog.focus();
26
+ };
27
+ function ModalDialog(message, inputs, callback) {
28
+ var html = '<form id="dialog_confirm" title="' + message + '"><ul>';
29
+ for (var name in inputs) {
30
+ var elem, opts, wrapper;
31
+ var type = inputs[name];
32
+ if (/^(datepicker|checkbox|text|number)$/.test(type)) {
33
+ wrapper = "input";
34
+ } else if (type === "textarea") {
35
+ wrapper = "textarea";
36
+ } else if ($.isArray(type)) {
37
+ var _ref = [ "select", "option", type, "" ];
38
+ wrapper = _ref[0];
39
+ elem = _ref[1];
40
+ opts = _ref[2];
41
+ type = _ref[3];
42
+ } else {
43
+ throw new Error("Unsupported input type: {" + name + ": " + type + "}");
44
+ }
45
+ var klass = type === "datepicker" ? type : "";
46
+ html += "<li>\n <label>" + (name.charAt(0).toUpperCase() + name.slice(1)) + "</label>\n <" + wrapper + ' name="' + name + '" class="' + klass + '" type="' + type + '">' + (opts ? function() {
47
+ var result = [];
48
+ opts.forEach(function(v) {
49
+ var $elem = $("<" + elem + "/>");
50
+ if ($.isArray(v)) {
51
+ $elem.text(v[0]).val(v[1]);
52
+ } else {
53
+ $elem.text(v);
54
+ }
55
+ result.push($elem.wrap("<div>").parent().html());
56
+ });
57
+ return result;
58
+ }().join("") : "") + ("</" + wrapper + ">") + "</li>";
59
+ var _ref2 = [];
60
+ wrapper = _ref2[0];
61
+ elem = _ref2[1];
62
+ opts = _ref2[2];
63
+ type = _ref2[3];
64
+ klass = _ref2[4];
65
+ }
66
+ html += "</ul></form>";
67
+ var form = $(html).appendTo("body");
68
+ $("body").trigger("modal_dialog:before_open", [ form ]);
69
+ form.dialog({
70
+ modal: true,
71
+ open: function open(event, ui) {
72
+ $("body").trigger("modal_dialog:after_open", [ form ]);
73
+ },
74
+ dialogClass: "active_admin_dialog",
75
+ buttons: {
76
+ OK: function OK() {
77
+ callback($(this).serializeObject());
78
+ $(this).dialog("close");
79
+ },
80
+ Cancel: function Cancel() {
81
+ $(this).dialog("close").remove();
82
+ }
83
+ }
84
+ });
85
+ }
86
+ var onDOMReady = function onDOMReady() {
87
+ $(".batch_actions_selector li a").off("click confirm:complete");
88
+ $(".batch_actions_selector li a").on("click", function(event) {
89
+ var _this = this;
90
+ var message;
91
+ event.stopPropagation();
92
+ event.preventDefault();
93
+ if (message = $(this).data("confirm")) {
94
+ ModalDialog(message, $(this).data("inputs"), function(inputs) {
95
+ $(_this).trigger("confirm:complete", inputs);
96
+ });
97
+ } else {
98
+ $(this).trigger("confirm:complete");
99
+ }
100
+ });
101
+ $(".batch_actions_selector li a").on("confirm:complete", function(event, inputs) {
102
+ var val;
103
+ if (val = JSON.stringify(inputs)) {
104
+ $("#batch_action_inputs").removeAttr("disabled").val(val);
105
+ } else {
106
+ $("#batch_action_inputs").attr("disabled", "disabled");
107
+ }
108
+ $("#batch_action").val($(this).data("action"));
109
+ $("#collection_selection").submit();
110
+ });
111
+ if ($(".batch_actions_selector").length && $(":checkbox.toggle_all").length) {
112
+ if ($(".paginated_collection table.index_table").length) {
113
+ $(".paginated_collection table.index_table").tableCheckboxToggler();
114
+ } else {
115
+ $(".paginated_collection").checkboxToggler();
116
+ }
117
+ $(document).on("change", ".paginated_collection :checkbox", function() {
118
+ if ($(".paginated_collection :checkbox:checked").length && $(".dropdown_menu_list").children().length) {
119
+ $(".batch_actions_selector").each(function() {
120
+ $(this).aaDropdownMenu("enable");
121
+ });
122
+ } else {
123
+ $(".batch_actions_selector").each(function() {
124
+ $(this).aaDropdownMenu("disable");
125
+ });
126
+ }
127
+ });
128
+ }
129
+ };
130
+ $(document).ready(onDOMReady).on("page:load turbolinks:load", onDOMReady);
131
+ var CheckboxToggler = function() {
132
+ function CheckboxToggler(options, container) {
133
+ this.options = options;
134
+ this.container = container;
135
+ this._init();
136
+ this._bind();
137
+ }
138
+ var _proto = CheckboxToggler.prototype;
139
+ _proto.option = function option(key, value) {};
140
+ _proto._init = function _init() {
141
+ if (!this.container) {
142
+ throw new Error("Container element not found");
143
+ } else {
144
+ this.$container = $(this.container);
145
+ }
146
+ if (!this.$container.find(".toggle_all").length) {
147
+ throw new Error('"toggle all" checkbox not found');
148
+ } else {
149
+ this.toggle_all_checkbox = this.$container.find(".toggle_all");
150
+ }
151
+ this.checkboxes = this.$container.find(":checkbox").not(this.toggle_all_checkbox);
152
+ };
153
+ _proto._bind = function _bind() {
154
+ var _this = this;
155
+ this.checkboxes.change(function(event) {
156
+ return _this._didChangeCheckbox(event.target);
157
+ });
158
+ this.toggle_all_checkbox.change(function() {
159
+ return _this._didChangeToggleAllCheckbox();
160
+ });
161
+ };
162
+ _proto._didChangeCheckbox = function _didChangeCheckbox(checkbox) {
163
+ var numChecked = this.checkboxes.filter(":checked").length;
164
+ var allChecked = numChecked === this.checkboxes.length;
165
+ var someChecked = numChecked > 0 && numChecked < this.checkboxes.length;
166
+ this.toggle_all_checkbox.prop({
167
+ checked: allChecked,
168
+ indeterminate: someChecked
169
+ });
170
+ };
171
+ _proto._didChangeToggleAllCheckbox = function _didChangeToggleAllCheckbox() {
172
+ var setting = this.toggle_all_checkbox.prop("checked");
173
+ this.checkboxes.prop({
174
+ checked: setting
175
+ });
176
+ return setting;
177
+ };
178
+ return CheckboxToggler;
179
+ }();
180
+ $.widget.bridge("checkboxToggler", CheckboxToggler);
181
+ (function($) {
182
+ $(document).on("focus", "input.datepicker:not(.hasDatepicker)", function() {
183
+ var input = $(this);
184
+ if (input[0].type === "date") {
185
+ return;
186
+ }
187
+ var defaults = {
188
+ dateFormat: "yy-mm-dd"
189
+ };
190
+ var options = input.data("datepicker-options");
191
+ input.datepicker($.extend(defaults, options));
192
+ });
193
+ })(jQuery);
194
+ var DropdownMenu = function() {
195
+ function DropdownMenu(options, element) {
196
+ this.options = options;
197
+ this.element = element;
198
+ this.$element = $(this.element);
199
+ var defaults = {
200
+ fadeInDuration: 20,
201
+ fadeOutDuration: 100,
202
+ onClickActionItemCallback: null
203
+ };
204
+ this.options = $.extend(defaults, this.options);
205
+ this.isOpen = false;
206
+ this.$menuButton = this.$element.find(".dropdown_menu_button");
207
+ this.$menuList = this.$element.find(".dropdown_menu_list_wrapper");
208
+ this._buildMenuList();
209
+ this._bind();
210
+ }
211
+ var _proto = DropdownMenu.prototype;
212
+ _proto.open = function open() {
213
+ this.isOpen = true;
214
+ this.$menuList.fadeIn(this.options.fadeInDuration);
215
+ this._position();
216
+ return this;
217
+ };
218
+ _proto.close = function close() {
219
+ this.isOpen = false;
220
+ this.$menuList.fadeOut(this.options.fadeOutDuration);
221
+ return this;
222
+ };
223
+ _proto.destroy = function destroy() {
224
+ this.$element = null;
225
+ return this;
226
+ };
227
+ _proto.isDisabled = function isDisabled() {
228
+ return this.$menuButton.hasClass("disabled");
229
+ };
230
+ _proto.disable = function disable() {
231
+ this.$menuButton.addClass("disabled");
232
+ };
233
+ _proto.enable = function enable() {
234
+ this.$menuButton.removeClass("disabled");
235
+ };
236
+ _proto.option = function option(key, value) {
237
+ if ($.isPlainObject(key)) {
238
+ return this.options = $.extend(true, this.options, key);
239
+ } else if (key != null) {
240
+ return this.options[key];
241
+ } else {
242
+ return this.options[key] = value;
243
+ }
244
+ };
245
+ _proto._buildMenuList = function _buildMenuList() {
246
+ this.$nipple = $('<div class="dropdown_menu_nipple"></div>');
247
+ this.$menuList.prepend(this.$nipple);
248
+ this.$menuList.hide();
249
+ };
250
+ _proto._bind = function _bind() {
251
+ var _this = this;
252
+ $("body").click(function() {
253
+ if (_this.isOpen) {
254
+ _this.close();
255
+ }
256
+ });
257
+ this.$menuButton.click(function() {
258
+ if (!_this.isDisabled()) {
259
+ if (_this.isOpen) {
260
+ _this.close();
261
+ } else {
262
+ _this.open();
263
+ }
264
+ }
265
+ return false;
266
+ });
267
+ };
268
+ _proto._position = function _position() {
269
+ this.$menuList.css("top", this.$menuButton.position().top + this.$menuButton.outerHeight() + 10);
270
+ var button_left = this.$menuButton.position().left;
271
+ var button_center = this.$menuButton.outerWidth() / 2;
272
+ var button_right = button_left + button_center * 2;
273
+ var menu_center = this.$menuList.outerWidth() / 2;
274
+ var nipple_center = this.$nipple.outerWidth() / 2;
275
+ var window_right = $(window).width();
276
+ var centered_menu_left = button_left + button_center - menu_center;
277
+ var centered_menu_right = button_left + button_center + menu_center;
278
+ if (centered_menu_left < 0) {
279
+ this.$menuList.css("left", button_left);
280
+ this.$nipple.css("left", button_center - nipple_center);
281
+ } else if (centered_menu_right > window_right) {
282
+ this.$menuList.css("right", window_right - button_right);
283
+ this.$nipple.css("right", button_center - nipple_center);
284
+ } else {
285
+ this.$menuList.css("left", centered_menu_left);
286
+ this.$nipple.css("left", menu_center - nipple_center);
287
+ }
288
+ };
289
+ return DropdownMenu;
290
+ }();
291
+ $.widget.bridge("aaDropdownMenu", DropdownMenu);
292
+ var onDOMReady$1 = function onDOMReady() {
293
+ return $(".dropdown_menu").aaDropdownMenu();
294
+ };
295
+ $(document).ready(onDOMReady$1).on("page:load turbolinks:load", onDOMReady$1);
296
+ function hasTurbolinks() {
297
+ return typeof Turbolinks !== "undefined" && Turbolinks.supported;
298
+ }
299
+ function turbolinksVisit(params) {
300
+ var path = [ window.location.pathname, "?", toQueryString(params) ].join("");
301
+ Turbolinks.visit(path);
302
+ }
303
+ function queryString() {
304
+ return (window.location.search || "").replace(/^\?/, "");
305
+ }
306
+ function queryStringToParams() {
307
+ var decode = function decode(value) {
308
+ return decodeURIComponent((value || "").replace(/\+/g, "%20"));
309
+ };
310
+ return queryString().split("&").map(function(pair) {
311
+ return pair.split("=");
312
+ }).map(function(_ref) {
313
+ var key = _ref[0], value = _ref[1];
314
+ return {
315
+ name: decode(key),
316
+ value: decode(value)
317
+ };
318
+ });
319
+ }
320
+ function toQueryString(params) {
321
+ var encode = function encode(value) {
322
+ return encodeURIComponent(value || "");
323
+ };
324
+ return params.map(function(_ref2) {
325
+ var name = _ref2.name, value = _ref2.value;
326
+ return [ encode(name), encode(value) ];
327
+ }).map(function(pair) {
328
+ return pair.join("=");
329
+ }).join("&");
330
+ }
331
+ var Filters = function() {
332
+ function Filters() {}
333
+ Filters._clearForm = function _clearForm(event) {
334
+ var regex = /^(q\[|q%5B|q%5b|page|utf8|commit)/;
335
+ var params = queryStringToParams().filter(function(_ref) {
336
+ var name = _ref.name;
337
+ return !name.match(regex);
338
+ });
339
+ event.preventDefault();
340
+ if (hasTurbolinks()) {
341
+ turbolinksVisit(params);
342
+ } else {
343
+ window.location.search = toQueryString(params);
344
+ }
345
+ };
346
+ Filters._disableEmptyInputFields = function _disableEmptyInputFields(event) {
347
+ var params = $(this).find(":input").filter(function(i, input) {
348
+ return input.value === "";
349
+ }).prop({
350
+ disabled: true
351
+ }).end().serializeArray();
352
+ if (hasTurbolinks()) {
353
+ event.preventDefault();
354
+ turbolinksVisit(params);
355
+ }
356
+ };
357
+ Filters._setSearchType = function _setSearchType() {
358
+ $(this).siblings("input").prop({
359
+ name: "q[" + this.value + "]"
360
+ });
361
+ };
362
+ return Filters;
363
+ }();
364
+ (function($) {
365
+ $(document).on("click", ".clear_filters_btn", Filters._clearForm).on("submit", ".filter_form", Filters._disableEmptyInputFields).on("change", ".filter_form_field.select_and_search select", Filters._setSearchType);
366
+ })(jQuery);
367
+ $(function() {
368
+ $(document).on("click", "a.button.has_many_remove", function(event) {
369
+ event.preventDefault();
370
+ var parent = $(this).closest(".has_many_container");
371
+ var to_remove = $(this).closest("fieldset");
372
+ recompute_positions(parent);
373
+ parent.trigger("has_many_remove:before", [ to_remove, parent ]);
374
+ to_remove.remove();
375
+ return parent.trigger("has_many_remove:after", [ to_remove, parent ]);
376
+ });
377
+ $(document).on("click", "a.button.has_many_add", function(event) {
378
+ var before_add;
379
+ event.preventDefault();
380
+ var parent = $(this).closest(".has_many_container");
381
+ parent.trigger(before_add = $.Event("has_many_add:before"), [ parent ]);
382
+ if (!before_add.isDefaultPrevented()) {
383
+ var index = parent.data("has_many_index") || parent.children("fieldset").length - 1;
384
+ parent.data({
385
+ has_many_index: ++index
386
+ });
387
+ var regex = new RegExp($(this).data("placeholder"), "g");
388
+ var html = $(this).data("html").replace(regex, index);
389
+ var fieldset = $(html).insertBefore(this);
390
+ recompute_positions(parent);
391
+ return parent.trigger("has_many_add:after", [ fieldset, parent ]);
392
+ }
393
+ });
394
+ $(document).on("change", '.has_many_container[data-sortable] :input[name$="[_destroy]"]', function() {
395
+ recompute_positions($(this).closest(".has_many"));
396
+ });
397
+ init_sortable();
398
+ $(document).on("has_many_add:after", ".has_many_container", init_sortable);
399
+ });
400
+ var init_sortable = function init_sortable() {
401
+ var elems = $(".has_many_container[data-sortable]:not(.ui-sortable)");
402
+ elems.sortable({
403
+ items: "> fieldset",
404
+ handle: "> ol > .handle",
405
+ start: function start(ev, ui) {
406
+ ui.item.css({
407
+ opacity: .3
408
+ });
409
+ },
410
+ stop: function stop(ev, ui) {
411
+ ui.item.css({
412
+ opacity: 1
413
+ });
414
+ recompute_positions($(this));
415
+ }
416
+ });
417
+ elems.each(recompute_positions);
418
+ };
419
+ var recompute_positions = function recompute_positions(parent) {
420
+ parent = parent instanceof jQuery ? parent : $(this);
421
+ var input_name = parent.data("sortable");
422
+ var position = parseInt(parent.data("sortable-start") || 0, 10);
423
+ parent.children("fieldset").each(function() {
424
+ var destroy_input = $(this).find("> ol > .input > :input[name$='[_destroy]']");
425
+ var sortable_input = $(this).find("> ol > .input > :input[name$='[" + input_name + "]']");
426
+ if (sortable_input.length) {
427
+ sortable_input.val(destroy_input.is(":checked") ? "" : position++);
428
+ }
429
+ });
430
+ };
431
+ var PerPage = function() {
432
+ function PerPage(element) {
433
+ this.element = element;
434
+ }
435
+ var _proto = PerPage.prototype;
436
+ _proto.update = function update() {
437
+ var params = queryStringToParams().filter(function(_ref) {
438
+ var name = _ref.name;
439
+ return name != "per_page" || name != "page";
440
+ });
441
+ params.push({
442
+ name: "per_page",
443
+ value: this.element.value
444
+ });
445
+ if (hasTurbolinks()) {
446
+ turbolinksVisit(params);
447
+ } else {
448
+ window.location.search = toQueryString(params);
449
+ }
450
+ };
451
+ PerPage._jQueryInterface = function _jQueryInterface(config) {
452
+ return this.each(function() {
453
+ var $this = $(this);
454
+ var data = $this.data("perPage");
455
+ if (!data) {
456
+ data = new PerPage(this);
457
+ $this.data("perPage", data);
458
+ }
459
+ if (config === "update") {
460
+ data[config]();
461
+ }
462
+ });
463
+ };
464
+ return PerPage;
465
+ }();
466
+ (function($) {
467
+ $(document).on("change", ".pagination_per_page > select", function(event) {
468
+ PerPage._jQueryInterface.call($(this), "update");
469
+ });
470
+ $.fn["perPage"] = PerPage._jQueryInterface;
471
+ $.fn["perPage"].Constructor = PerPage;
472
+ })(jQuery);
473
+ function _inheritsLoose(subClass, superClass) {
474
+ subClass.prototype = Object.create(superClass.prototype);
475
+ subClass.prototype.constructor = subClass;
476
+ subClass.__proto__ = superClass;
477
+ }
478
+ var TableCheckboxToggler = function(_CheckboxToggler) {
479
+ _inheritsLoose(TableCheckboxToggler, _CheckboxToggler);
480
+ function TableCheckboxToggler() {
481
+ return _CheckboxToggler.apply(this, arguments) || this;
482
+ }
483
+ var _proto = TableCheckboxToggler.prototype;
484
+ _proto._bind = function _bind() {
485
+ var _this = this;
486
+ _CheckboxToggler.prototype._bind.apply(this, arguments);
487
+ this.$container.find("tbody td").click(function(event) {
488
+ if (event.target.type !== "checkbox") {
489
+ _this._didClickCell(event.target);
490
+ }
491
+ });
492
+ };
493
+ _proto._didChangeCheckbox = function _didChangeCheckbox(checkbox) {
494
+ _CheckboxToggler.prototype._didChangeCheckbox.apply(this, arguments);
495
+ $(checkbox).parents("tr").toggleClass("selected", checkbox.checked);
496
+ };
497
+ _proto._didChangeToggleAllCheckbox = function _didChangeToggleAllCheckbox() {
498
+ this.$container.find("tbody tr").toggleClass("selected", _CheckboxToggler.prototype._didChangeToggleAllCheckbox.apply(this, arguments));
499
+ };
500
+ _proto._didClickCell = function _didClickCell(cell) {
501
+ $(cell).parent("tr").find(":checkbox").click();
502
+ };
503
+ return TableCheckboxToggler;
504
+ }(CheckboxToggler);
505
+ $.widget.bridge("tableCheckboxToggler", TableCheckboxToggler);
506
+ var onDOMReady$2 = function onDOMReady() {
507
+ return $("#active_admin_content .tabs").tabs();
508
+ };
509
+ $(document).ready(onDOMReady$2).on("page:load turbolinks:load", onDOMReady$2);
510
+ function modal_dialog(message, inputs, callback) {
511
+ console.warn("ActiveAdmin.modal_dialog is deprecated in favor of ActiveAdmin.ModalDialog, please update usage.");
512
+ return ModalDialog(message, inputs, callback);
513
+ }
514
+ exports.ModalDialog = ModalDialog;
515
+ exports.modal_dialog = modal_dialog;
516
+ Object.defineProperty(exports, "__esModule", {
517
+ value: true
518
+ });
519
+ });