activeadmin_addons 1.9.0 → 1.10.1

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: 31434452186d9b02e7d7272b27d06d1e4831b1c4c6de9c068e973cf5311da476
4
- data.tar.gz: 0a43f7f1d45b50c01eeb4b4f7a56f5ff9bcb4329a24adb4f77fc1d1ca28fa0e7
3
+ metadata.gz: 4ce9aaa332970fcc70e6919da7ae647b9c04984d03962b381b7453c7e28db48d
4
+ data.tar.gz: a4b590241dbd498457c52890d3a2626afed5b9d204a12aaafcd4dc586f06b245
5
5
  SHA512:
6
- metadata.gz: 10db20adc03c85569ab16debe8edffd16115b348baf7779e79544fa42a265058cc60d3d24ac77dea5e85591297a6daeb2ede226141cb7dbb4e34d0776966462a
7
- data.tar.gz: b911e25eeb0801b2bbe7857c012f4c93fa71a2bf77d574d552461e39cdedfcdd698673ed625a4034c749852f2d1b47e1387a7b7c0a4f754cdb3311c753beab6a
6
+ metadata.gz: 9e1ddef237466638ce8e01315caa041c024ddf60c620076da537bf93f5b42e57a54bf51fd2d5ead8c8536dd28b64ea3e0f9c1a7855b600934671b413fbd51ce5
7
+ data.tar.gz: e00a22b2e6ab958b5340cbf261e6e5a7d9c0373de5265b91eb6298f700c68692f6b274198702580a0820d576b36a956de8a0ee556c274b5f8c08ab7a80a0bf4c
@@ -171,7 +171,7 @@
171
171
  };
172
172
  };
173
173
  $(initializer$9);
174
- $(document).on("turbolinks:load", initializer$9);
174
+ $(document).on("turbolinks:load turbo:load", initializer$9);
175
175
  var initializer$8 = function() {
176
176
  configureSelect2(document);
177
177
  $(document).on("has_many_add:after", function(event, container) {
@@ -213,7 +213,7 @@
213
213
  }
214
214
  };
215
215
  $(initializer$8);
216
- $(document).on("turbolinks:load", initializer$8);
216
+ $(document).on("turbolinks:load turbo:load", initializer$8);
217
217
  var initializer$7 = function() {
218
218
  setupSearchSelect(document);
219
219
  $(document).on("has_many_add:after", function(event, container) {
@@ -283,7 +283,7 @@
283
283
  }
284
284
  };
285
285
  $(initializer$7);
286
- $(document).on("turbolinks:load", initializer$7);
286
+ $(document).on("turbolinks:load turbo:load", initializer$7);
287
287
  $.fn.select2.amd.define("select2/data/nestedCustomAdapter", [ "select2/data/array", "select2/utils" ], function(ArrayData, Utils) {
288
288
  function CustomData($element, options) {
289
289
  CustomData.__super__.constructor.call(this, $element, options);
@@ -429,7 +429,7 @@
429
429
  }
430
430
  };
431
431
  $(initializer$6);
432
- $(document).on("turbolinks:load", initializer$6);
432
+ $(document).on("turbolinks:load turbo:load", initializer$6);
433
433
  var initializer$5 = function() {
434
434
  setupTags(document);
435
435
  $(document).on("has_many_add:after", function(event, container) {
@@ -495,7 +495,7 @@
495
495
  }
496
496
  };
497
497
  $(initializer$5);
498
- $(document).on("turbolinks:load", initializer$5);
498
+ $(document).on("turbolinks:load turbo:load", initializer$5);
499
499
  var initializer$4 = function() {
500
500
  setupSelectedList(document);
501
501
  $(document).on("has_many_add:after", function(event, container) {
@@ -589,7 +589,7 @@
589
589
  }
590
590
  };
591
591
  $(initializer$4);
592
- $(document).on("turbolinks:load", initializer$4);
592
+ $(document).on("turbolinks:load turbo:load", initializer$4);
593
593
  var initializer$3 = function() {
594
594
  setupDateTimePicker(document);
595
595
  $(document).on("has_many_add:after", ".has_many_container", function(event, fieldset) {
@@ -613,7 +613,7 @@
613
613
  }
614
614
  };
615
615
  $(initializer$3);
616
- $(document).on("turbolinks:load", initializer$3);
616
+ $(document).on("turbolinks:load turbo:load", initializer$3);
617
617
  var initializer$2 = function() {
618
618
  setupColorPicker();
619
619
  $(document).on("has_many_add:after", setupColorPicker);
@@ -626,7 +626,7 @@
626
626
  }
627
627
  };
628
628
  $(initializer$2);
629
- $(document).on("turbolinks:load", initializer$2);
629
+ $(document).on("turbolinks:load turbo:load", initializer$2);
630
630
  var initializer$1 = function() {
631
631
  $(".toggle-bool-switch").click(function(e) {
632
632
  var boolSwitch = $(e.target);
@@ -665,7 +665,7 @@
665
665
  });
666
666
  };
667
667
  $(initializer$1);
668
- $(document).on("turbolinks:load", initializer$1);
668
+ $(document).on("turbolinks:load turbo:load", initializer$1);
669
669
  var initializer = function() {
670
670
  configureInteractiveSelect(document);
671
671
  $(document).on("has_many_add:after", function(event, container) {
@@ -749,5 +749,5 @@
749
749
  });
750
750
  };
751
751
  $(initializer);
752
- $(document).on("turbolinks:load", initializer);
752
+ $(document).on("turbolinks:load turbo:load", initializer);
753
753
  });
@@ -16,7 +16,7 @@ class NestedLevelInput < ActiveAdminAddons::InputBase
16
16
  def load_control_attributes
17
17
  load_class(@options[:class])
18
18
  load_data_attr(:fields, default: ["name"], formatter: :to_json)
19
- load_data_attr(:predicate, default: "contains")
19
+ load_data_attr(:predicate, default: "cont")
20
20
  load_data_attr(:filters)
21
21
  load_data_attr(:model, value: model_name)
22
22
  load_data_attr(:display_name, default: "name")
@@ -14,7 +14,7 @@ class SearchSelectInput < ActiveAdminAddons::InputBase
14
14
  def load_control_attributes
15
15
  load_class(@options[:class])
16
16
  load_data_attr(:fields, default: ["name"], formatter: :to_json)
17
- load_data_attr(:predicate, default: "contains")
17
+ load_data_attr(:predicate, default: "cont")
18
18
  load_data_attr(:url, default: url_from_method)
19
19
  load_data_attr(:response_root, default: tableize_method)
20
20
  load_data_attr(:display_name, default: "name")
@@ -11,7 +11,7 @@ class SelectedListInput < ActiveAdminAddons::InputBase
11
11
  load_data_attr(:url, default: url_from_method)
12
12
  load_data_attr(:response_root, default: tableize_method)
13
13
  load_data_attr(:fields, default: ["name"], formatter: :to_json)
14
- load_data_attr(:predicate, default: "contains")
14
+ load_data_attr(:predicate, default: "cont")
15
15
  load_data_attr(:display_name, default: "name")
16
16
  load_data_attr(:minimum_input_length, default: 1)
17
17
  load_data_attr(:width, default: "100%")
@@ -92,4 +92,4 @@ var initializer = function() {
92
92
  };
93
93
 
94
94
  $(initializer);
95
- $(document).on('turbolinks:load', initializer);
95
+ $(document).on('turbolinks:load turbo:load', initializer);
@@ -36,4 +36,4 @@ var initializer = function() {
36
36
  };
37
37
 
38
38
  $(initializer);
39
- $(document).on('turbolinks:load', initializer);
39
+ $(document).on('turbolinks:load turbo:load', initializer);
@@ -7,4 +7,4 @@ var initializer = function() {
7
7
  };
8
8
 
9
9
  $(initializer);
10
- $(document).on('turbolinks:load', initializer);
10
+ $(document).on('turbolinks:load turbo:load', initializer);
@@ -13,4 +13,4 @@ var initializer = function() {
13
13
  };
14
14
 
15
15
  $(initializer);
16
- $(document).on('turbolinks:load', initializer);
16
+ $(document).on('turbolinks:load turbo:load', initializer);
@@ -25,4 +25,4 @@ var initializer = function() {
25
25
  };
26
26
 
27
27
  $(initializer);
28
- $(document).on('turbolinks:load', initializer);
28
+ $(document).on('turbolinks:load turbo:load', initializer);
@@ -167,4 +167,4 @@ var initializer = function() {
167
167
  };
168
168
 
169
169
  $(initializer);
170
- $(document).on('turbolinks:load', initializer);
170
+ $(document).on('turbolinks:load turbo:load', initializer);
@@ -73,4 +73,4 @@ var initializer = function() {
73
73
  };
74
74
 
75
75
  $(initializer);
76
- $(document).on('turbolinks:load', initializer);
76
+ $(document).on('turbolinks:load turbo:load', initializer);
@@ -49,4 +49,4 @@ var initializer = function() {
49
49
  };
50
50
 
51
51
  $(initializer);
52
- $(document).on('turbolinks:load', initializer);
52
+ $(document).on('turbolinks:load turbo:load', initializer);
@@ -104,4 +104,4 @@ var initializer = function() {
104
104
  };
105
105
 
106
106
  $(initializer);
107
- $(document).on('turbolinks:load', initializer);
107
+ $(document).on('turbolinks:load turbo:load', initializer);
@@ -73,4 +73,4 @@ var initializer = function() {
73
73
  };
74
74
 
75
75
  $(initializer);
76
- $(document).on('turbolinks:load', initializer);
76
+ $(document).on('turbolinks:load turbo:load', initializer);
@@ -2,10 +2,35 @@ module ActiveAdminAddons
2
2
  class ImageBuilder < CustomBuilder
3
3
  def render
4
4
  return nil if data.nil?
5
- raise "you need to pass a paperclip image attribute" unless data.respond_to?(:url)
5
+
6
+ if Object.const_defined?('Paperclip::Attachment') && data.is_a?(Paperclip::Attachment)
7
+ paperclip_data
8
+ elsif Object.const_defined?('Shrine::UploadedFile') && data.is_a?(Shrine::UploadedFile)
9
+ shrine_data
10
+ else
11
+ raise "you need to pass a paperclip or shrine image attribute"
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def paperclip_data
6
18
  style = options.fetch(:style, :original)
7
19
  context.image_tag(data.url(style)) if data.file?
8
20
  end
21
+
22
+ def shrine_data
23
+ image_options = options[:image_options].presence || {}
24
+ if options[:style] && derivatives.include?(options[:style])
25
+ context.image_tag(model.send("#{attribute}_url", options[:style]), image_options)
26
+ else
27
+ context.image_tag(data.url, image_options)
28
+ end
29
+ end
30
+
31
+ def derivatives
32
+ model.send("#{attribute}_derivatives")
33
+ end
9
34
  end
10
35
  end
11
36
 
@@ -0,0 +1,38 @@
1
+ require 'redcarpet'
2
+
3
+ module ActiveAdminAddons
4
+ class MarkdownBuilder < CustomBuilder
5
+ def render
6
+ return if data.blank?
7
+
8
+ Redcarpet::Markdown.new(renderer, extensions).render(@data).html_safe
9
+ end
10
+
11
+ private
12
+
13
+ def extensions_default
14
+ { fenced_code_blocks: true,
15
+ no_intra_emphasis: true,
16
+ strikethrough: true,
17
+ superscript: true }
18
+ end
19
+
20
+ def renderer_options_default
21
+ { filter_html: true, hard_wrap: true }
22
+ end
23
+
24
+ def extensions
25
+ @extensions ||= extensions_default.merge(options[:extensions] || {})
26
+ end
27
+
28
+ def render_options
29
+ @render_options ||= renderer_options_default.merge(options[:render_options] || {})
30
+ end
31
+
32
+ def renderer
33
+ @renderer ||= Redcarpet::Render::HTML.new(render_options)
34
+ end
35
+ end
36
+ end
37
+
38
+ ActiveAdminAddons::MarkdownBuilder.create_view_methods
@@ -25,9 +25,9 @@ module ActiveAdminAddons
25
25
 
26
26
  context.div(interactive_tag_select_params) do
27
27
  context.select do
28
- possible_values.each do |val|
29
- context.option(value: val, selected: val == data) do
30
- context.text_node val.capitalize
28
+ possible_values.each do |label, value|
29
+ context.option(value: value, selected: value == data) do
30
+ context.text_node label
31
31
  end
32
32
  end
33
33
  end
@@ -36,7 +36,11 @@ module ActiveAdminAddons
36
36
  end
37
37
 
38
38
  def display_data
39
- @enum_attr == :enumerize ? data.text : data
39
+ if @enum_attr == :enumerize
40
+ data.text
41
+ else
42
+ EnumUtils.translate_enum_option(model.class, attribute.to_s, data)
43
+ end
40
44
  end
41
45
 
42
46
  def interactive_params(klass)
@@ -69,9 +73,9 @@ module ActiveAdminAddons
69
73
  def possible_values
70
74
  klass = model.class
71
75
  if @enum_attr == :enumerize
72
- klass.enumerized_attributes[attribute.to_s].values
76
+ klass.enumerized_attributes[attribute.to_s].values.map { |value| [value.capitalize, value] }
73
77
  else
74
- klass.defined_enums[attribute.to_s].keys
78
+ EnumUtils.options_for_select(klass, attribute.to_s)
75
79
  end
76
80
  end
77
81
 
@@ -0,0 +1,19 @@
1
+ module ActiveAdminAddons
2
+ class EnumUtils
3
+ def self.options_for_select(klass, enum_name, use_db_value: false)
4
+ enum_options_hash = klass.defined_enums[enum_name]
5
+ enum_options_hash.map do |enum_option_name, db_value|
6
+ value = use_db_value ? db_value : enum_option_name
7
+ [translate_enum_option(klass, enum_name, enum_option_name), value]
8
+ end
9
+ end
10
+
11
+ def self.translate_enum_option(klass, enum_name, enum_option_name)
12
+ return if enum_option_name.blank?
13
+
14
+ klass_key = klass.model_name.i18n_key
15
+ key = "activerecord.attributes.#{klass_key}.#{enum_name.pluralize}.#{enum_option_name}"
16
+ I18n.t(key, default: enum_option_name)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module ActiveAdminAddons
2
+ module SelectFilterInputExtension
3
+ def collection_from_enum?
4
+ klass.respond_to?(:defined_enums) && klass.defined_enums.has_key?(method.to_s)
5
+ end
6
+
7
+ def collection
8
+ if !options[:collection] && collection_from_enum?
9
+ EnumUtils.options_for_select(klass, method.to_s, use_db_value: true)
10
+ else
11
+ super
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ ::ActiveAdmin::Inputs::Filters::SelectInput.send(
18
+ :prepend, ActiveAdminAddons::SelectFilterInputExtension
19
+ )
@@ -1,3 +1,3 @@
1
1
  module ActiveadminAddons
2
- VERSION = "1.9.0"
2
+ VERSION = "1.10.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_addons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platanus
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-11-24 00:00:00.000000000 Z
14
+ date: 2023-08-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: active_material
@@ -41,6 +41,20 @@ dependencies:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: redcarpet
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
44
58
  - !ruby/object:Gem::Dependency
45
59
  name: require_all
46
60
  requirement: !ruby/object:Gem::Requirement
@@ -112,7 +126,7 @@ dependencies:
112
126
  - !ruby/object:Gem::Version
113
127
  version: '0'
114
128
  - !ruby/object:Gem::Dependency
115
- name: capybara-selenium
129
+ name: capybara
116
130
  requirement: !ruby/object:Gem::Requirement
117
131
  requirements:
118
132
  - - ">="
@@ -195,6 +209,34 @@ dependencies:
195
209
  - - ">="
196
210
  - !ruby/object:Gem::Version
197
211
  version: '0'
212
+ - !ruby/object:Gem::Dependency
213
+ name: image_processing
214
+ requirement: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: '0'
219
+ type: :development
220
+ prerelease: false
221
+ version_requirements: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ version: '0'
226
+ - !ruby/object:Gem::Dependency
227
+ name: matrix
228
+ requirement: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ type: :development
234
+ prerelease: false
235
+ version_requirements: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - ">="
238
+ - !ruby/object:Gem::Version
239
+ version: '0'
198
240
  - !ruby/object:Gem::Dependency
199
241
  name: paperclip
200
242
  requirement: !ruby/object:Gem::Requirement
@@ -243,20 +285,34 @@ dependencies:
243
285
  requirements:
244
286
  - - "~>"
245
287
  - !ruby/object:Gem::Version
246
- version: '5.2'
288
+ version: '6.1'
247
289
  - - ">="
248
290
  - !ruby/object:Gem::Version
249
- version: 5.2.4.1
291
+ version: 6.1.4.4
250
292
  type: :development
251
293
  prerelease: false
252
294
  version_requirements: !ruby/object:Gem::Requirement
253
295
  requirements:
254
296
  - - "~>"
255
297
  - !ruby/object:Gem::Version
256
- version: '5.2'
298
+ version: '6.1'
299
+ - - ">="
300
+ - !ruby/object:Gem::Version
301
+ version: 6.1.4.4
302
+ - !ruby/object:Gem::Dependency
303
+ name: rexml
304
+ requirement: !ruby/object:Gem::Requirement
305
+ requirements:
306
+ - - ">="
307
+ - !ruby/object:Gem::Version
308
+ version: '0'
309
+ type: :development
310
+ prerelease: false
311
+ version_requirements: !ruby/object:Gem::Requirement
312
+ requirements:
257
313
  - - ">="
258
314
  - !ruby/object:Gem::Version
259
- version: 5.2.4.1
315
+ version: '0'
260
316
  - !ruby/object:Gem::Dependency
261
317
  name: rspec-rails
262
318
  requirement: !ruby/object:Gem::Requirement
@@ -299,6 +355,20 @@ dependencies:
299
355
  - - "~>"
300
356
  - !ruby/object:Gem::Version
301
357
  version: 0.65.0
358
+ - !ruby/object:Gem::Dependency
359
+ name: selenium-webdriver
360
+ requirement: !ruby/object:Gem::Requirement
361
+ requirements:
362
+ - - "~>"
363
+ - !ruby/object:Gem::Version
364
+ version: '4.10'
365
+ type: :development
366
+ prerelease: false
367
+ version_requirements: !ruby/object:Gem::Requirement
368
+ requirements:
369
+ - - "~>"
370
+ - !ruby/object:Gem::Version
371
+ version: '4.10'
302
372
  - !ruby/object:Gem::Dependency
303
373
  name: shoulda-matchers
304
374
  requirement: !ruby/object:Gem::Requirement
@@ -314,21 +384,21 @@ dependencies:
314
384
  - !ruby/object:Gem::Version
315
385
  version: '0'
316
386
  - !ruby/object:Gem::Dependency
317
- name: sqlite3
387
+ name: shrine
318
388
  requirement: !ruby/object:Gem::Requirement
319
389
  requirements:
320
- - - ">="
390
+ - - "~>"
321
391
  - !ruby/object:Gem::Version
322
- version: '0'
392
+ version: '3.0'
323
393
  type: :development
324
394
  prerelease: false
325
395
  version_requirements: !ruby/object:Gem::Requirement
326
396
  requirements:
327
- - - ">="
397
+ - - "~>"
328
398
  - !ruby/object:Gem::Version
329
- version: '0'
399
+ version: '3.0'
330
400
  - !ruby/object:Gem::Dependency
331
- name: webdrivers
401
+ name: sqlite3
332
402
  requirement: !ruby/object:Gem::Requirement
333
403
  requirements:
334
404
  - - ">="
@@ -509,12 +579,14 @@ files:
509
579
  - lib/activeadmin_addons/addons/bool_builder.rb
510
580
  - lib/activeadmin_addons/addons/image_builder.rb
511
581
  - lib/activeadmin_addons/addons/list_builder.rb
582
+ - lib/activeadmin_addons/addons/markdown_builder.rb
512
583
  - lib/activeadmin_addons/addons/number_builder.rb
513
584
  - lib/activeadmin_addons/addons/state_builder.rb
514
585
  - lib/activeadmin_addons/addons/tag_builder.rb
515
586
  - lib/activeadmin_addons/addons/toggle_bool_builder.rb
516
587
  - lib/activeadmin_addons/engine.rb
517
588
  - lib/activeadmin_addons/support/custom_builder.rb
589
+ - lib/activeadmin_addons/support/enum_utils.rb
518
590
  - lib/activeadmin_addons/support/enumerize_formtastic_support.rb
519
591
  - lib/activeadmin_addons/support/input_base.rb
520
592
  - lib/activeadmin_addons/support/input_helpers/filter_input.rb
@@ -523,6 +595,7 @@ files:
523
595
  - lib/activeadmin_addons/support/input_helpers/input_methods.rb
524
596
  - lib/activeadmin_addons/support/input_helpers/input_options_handler.rb
525
597
  - lib/activeadmin_addons/support/input_helpers/select_helpers.rb
598
+ - lib/activeadmin_addons/support/select_filter_input_extension.rb
526
599
  - lib/activeadmin_addons/support/set_datepicker.rb
527
600
  - lib/activeadmin_addons/version.rb
528
601
  - lib/generators/activeadmin_addons/assets/assets_generator.rb
@@ -551,7 +624,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
551
624
  - !ruby/object:Gem::Version
552
625
  version: '0'
553
626
  requirements: []
554
- rubygems_version: 3.1.6
627
+ rubygems_version: 3.4.10
555
628
  signing_key:
556
629
  specification_version: 4
557
630
  summary: Set of addons to help with the activeadmin ui