activeadmin_addons 1.9.0 → 2.0.0.beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -17
  3. data/app/inputs/active_admin/inputs/select_input.rb +5 -1
  4. data/app/inputs/nested_level_input.rb +2 -1
  5. data/app/inputs/search_select_input.rb +1 -1
  6. data/app/inputs/tags_input.rb +1 -1
  7. data/app/javascript/activeadmin_addons/addons/slim-select-interactive-tag.js +78 -0
  8. data/app/javascript/activeadmin_addons/addons/toggle_bool.js +1 -1
  9. data/app/javascript/activeadmin_addons/all.js +2 -7
  10. data/app/javascript/activeadmin_addons/config.js +8 -5
  11. data/app/javascript/activeadmin_addons/inputs/color-picker.js +1 -1
  12. data/app/javascript/activeadmin_addons/inputs/date-time-picker.js +1 -1
  13. data/app/javascript/activeadmin_addons/inputs/slim-select-nested.js +93 -0
  14. data/app/javascript/activeadmin_addons/inputs/slim-select-search.js +37 -0
  15. data/app/javascript/activeadmin_addons/inputs/slim-select-selected-list.js +103 -0
  16. data/app/javascript/activeadmin_addons/inputs/slim-select-simple-tags.js +22 -0
  17. data/app/javascript/activeadmin_addons/inputs/slim-select-tags.js +67 -0
  18. data/app/javascript/activeadmin_addons/inputs/slim-select-utils.js +70 -0
  19. data/app/javascript/activeadmin_addons/inputs/slim-select.js +75 -0
  20. data/app/{assets/stylesheets/activeadmin_addons → javascript/activeadmin_addons/stylesheets}/all.scss +5 -11
  21. data/app/javascript/activeadmin_addons/stylesheets/imports/slimselect.css +1 -0
  22. data/app/{assets/stylesheets/activeadmin_addons → javascript/activeadmin_addons/stylesheets}/inputs/selected-list.scss +0 -1
  23. data/app/javascript/activeadmin_addons/stylesheets/inputs/slim-select.scss +9 -0
  24. data/lib/activeadmin_addons/addons/image_builder.rb +21 -3
  25. data/lib/activeadmin_addons/addons/markdown_builder.rb +38 -0
  26. data/lib/activeadmin_addons/addons/tag_builder.rb +6 -21
  27. data/lib/activeadmin_addons/engine.rb +0 -5
  28. data/lib/activeadmin_addons/support/enum_utils.rb +19 -0
  29. data/lib/activeadmin_addons/support/input_helpers/select_helpers.rb +1 -1
  30. data/lib/activeadmin_addons/support/select_filter_input_extension.rb +19 -0
  31. data/lib/activeadmin_addons/version.rb +1 -1
  32. data/lib/activeadmin_addons.rb +1 -1
  33. data/lib/generators/activeadmin_addons/install/install_generator.rb +2 -1
  34. data/lib/generators/activeadmin_addons/install/templates/initializer.rb +1 -1
  35. data/lib/generators/activeadmin_addons/webpacker/webpacker_generator.rb +1 -1
  36. metadata +83 -181
  37. data/app/assets/images/fileicons/file_extension_3gp.png +0 -0
  38. data/app/assets/images/fileicons/file_extension_7z.png +0 -0
  39. data/app/assets/images/fileicons/file_extension_ace.png +0 -0
  40. data/app/assets/images/fileicons/file_extension_ai.png +0 -0
  41. data/app/assets/images/fileicons/file_extension_aif.png +0 -0
  42. data/app/assets/images/fileicons/file_extension_aiff.png +0 -0
  43. data/app/assets/images/fileicons/file_extension_amr.png +0 -0
  44. data/app/assets/images/fileicons/file_extension_asf.png +0 -0
  45. data/app/assets/images/fileicons/file_extension_asx.png +0 -0
  46. data/app/assets/images/fileicons/file_extension_bat.png +0 -0
  47. data/app/assets/images/fileicons/file_extension_bin.png +0 -0
  48. data/app/assets/images/fileicons/file_extension_bmp.png +0 -0
  49. data/app/assets/images/fileicons/file_extension_bup.png +0 -0
  50. data/app/assets/images/fileicons/file_extension_cab.png +0 -0
  51. data/app/assets/images/fileicons/file_extension_cbr.png +0 -0
  52. data/app/assets/images/fileicons/file_extension_cda.png +0 -0
  53. data/app/assets/images/fileicons/file_extension_cdl.png +0 -0
  54. data/app/assets/images/fileicons/file_extension_cdr.png +0 -0
  55. data/app/assets/images/fileicons/file_extension_chm.png +0 -0
  56. data/app/assets/images/fileicons/file_extension_dat.png +0 -0
  57. data/app/assets/images/fileicons/file_extension_divx.png +0 -0
  58. data/app/assets/images/fileicons/file_extension_dll.png +0 -0
  59. data/app/assets/images/fileicons/file_extension_dmg.png +0 -0
  60. data/app/assets/images/fileicons/file_extension_doc.png +0 -0
  61. data/app/assets/images/fileicons/file_extension_docx.png +0 -0
  62. data/app/assets/images/fileicons/file_extension_dss.png +0 -0
  63. data/app/assets/images/fileicons/file_extension_dvf.png +0 -0
  64. data/app/assets/images/fileicons/file_extension_dwg.png +0 -0
  65. data/app/assets/images/fileicons/file_extension_eml.png +0 -0
  66. data/app/assets/images/fileicons/file_extension_eps.png +0 -0
  67. data/app/assets/images/fileicons/file_extension_exe.png +0 -0
  68. data/app/assets/images/fileicons/file_extension_fla.png +0 -0
  69. data/app/assets/images/fileicons/file_extension_flv.png +0 -0
  70. data/app/assets/images/fileicons/file_extension_gif.png +0 -0
  71. data/app/assets/images/fileicons/file_extension_gz.png +0 -0
  72. data/app/assets/images/fileicons/file_extension_hqx.png +0 -0
  73. data/app/assets/images/fileicons/file_extension_htm.png +0 -0
  74. data/app/assets/images/fileicons/file_extension_html.png +0 -0
  75. data/app/assets/images/fileicons/file_extension_ifo.png +0 -0
  76. data/app/assets/images/fileicons/file_extension_indd.png +0 -0
  77. data/app/assets/images/fileicons/file_extension_iso.png +0 -0
  78. data/app/assets/images/fileicons/file_extension_jar.png +0 -0
  79. data/app/assets/images/fileicons/file_extension_jpeg.png +0 -0
  80. data/app/assets/images/fileicons/file_extension_jpg.png +0 -0
  81. data/app/assets/images/fileicons/file_extension_lnk.png +0 -0
  82. data/app/assets/images/fileicons/file_extension_log.png +0 -0
  83. data/app/assets/images/fileicons/file_extension_m4a.png +0 -0
  84. data/app/assets/images/fileicons/file_extension_m4b.png +0 -0
  85. data/app/assets/images/fileicons/file_extension_m4p.png +0 -0
  86. data/app/assets/images/fileicons/file_extension_m4v.png +0 -0
  87. data/app/assets/images/fileicons/file_extension_mcd.png +0 -0
  88. data/app/assets/images/fileicons/file_extension_mdb.png +0 -0
  89. data/app/assets/images/fileicons/file_extension_mid.png +0 -0
  90. data/app/assets/images/fileicons/file_extension_mov.png +0 -0
  91. data/app/assets/images/fileicons/file_extension_mp2.png +0 -0
  92. data/app/assets/images/fileicons/file_extension_mp3.png +0 -0
  93. data/app/assets/images/fileicons/file_extension_mp4.png +0 -0
  94. data/app/assets/images/fileicons/file_extension_mpeg.png +0 -0
  95. data/app/assets/images/fileicons/file_extension_mpg.png +0 -0
  96. data/app/assets/images/fileicons/file_extension_msi.png +0 -0
  97. data/app/assets/images/fileicons/file_extension_mswmm.png +0 -0
  98. data/app/assets/images/fileicons/file_extension_ogg.png +0 -0
  99. data/app/assets/images/fileicons/file_extension_pdf.png +0 -0
  100. data/app/assets/images/fileicons/file_extension_png.png +0 -0
  101. data/app/assets/images/fileicons/file_extension_pps.png +0 -0
  102. data/app/assets/images/fileicons/file_extension_ppt.png +0 -0
  103. data/app/assets/images/fileicons/file_extension_pptx.png +0 -0
  104. data/app/assets/images/fileicons/file_extension_ps.png +0 -0
  105. data/app/assets/images/fileicons/file_extension_psd.png +0 -0
  106. data/app/assets/images/fileicons/file_extension_pst.png +0 -0
  107. data/app/assets/images/fileicons/file_extension_ptb.png +0 -0
  108. data/app/assets/images/fileicons/file_extension_pub.png +0 -0
  109. data/app/assets/images/fileicons/file_extension_qbb.png +0 -0
  110. data/app/assets/images/fileicons/file_extension_qbw.png +0 -0
  111. data/app/assets/images/fileicons/file_extension_qxd.png +0 -0
  112. data/app/assets/images/fileicons/file_extension_ram.png +0 -0
  113. data/app/assets/images/fileicons/file_extension_rar.png +0 -0
  114. data/app/assets/images/fileicons/file_extension_rm.png +0 -0
  115. data/app/assets/images/fileicons/file_extension_rmvb.png +0 -0
  116. data/app/assets/images/fileicons/file_extension_rtf.png +0 -0
  117. data/app/assets/images/fileicons/file_extension_sea.png +0 -0
  118. data/app/assets/images/fileicons/file_extension_ses.png +0 -0
  119. data/app/assets/images/fileicons/file_extension_sit.png +0 -0
  120. data/app/assets/images/fileicons/file_extension_sitx.png +0 -0
  121. data/app/assets/images/fileicons/file_extension_ss.png +0 -0
  122. data/app/assets/images/fileicons/file_extension_swf.png +0 -0
  123. data/app/assets/images/fileicons/file_extension_tgz.png +0 -0
  124. data/app/assets/images/fileicons/file_extension_thm.png +0 -0
  125. data/app/assets/images/fileicons/file_extension_tif.png +0 -0
  126. data/app/assets/images/fileicons/file_extension_tmp.png +0 -0
  127. data/app/assets/images/fileicons/file_extension_torrent.png +0 -0
  128. data/app/assets/images/fileicons/file_extension_ttf.png +0 -0
  129. data/app/assets/images/fileicons/file_extension_txt.png +0 -0
  130. data/app/assets/images/fileicons/file_extension_unknown.png +0 -0
  131. data/app/assets/images/fileicons/file_extension_vcd.png +0 -0
  132. data/app/assets/images/fileicons/file_extension_vob.png +0 -0
  133. data/app/assets/images/fileicons/file_extension_wav.png +0 -0
  134. data/app/assets/images/fileicons/file_extension_wma.png +0 -0
  135. data/app/assets/images/fileicons/file_extension_wmv.png +0 -0
  136. data/app/assets/images/fileicons/file_extension_wps.png +0 -0
  137. data/app/assets/images/fileicons/file_extension_xls.png +0 -0
  138. data/app/assets/images/fileicons/file_extension_xlsx.png +0 -0
  139. data/app/assets/images/fileicons/file_extension_xpi.png +0 -0
  140. data/app/assets/images/fileicons/file_extension_zip.png +0 -0
  141. data/app/assets/images/material/icons/keyboard_arrow_down.svg +0 -4
  142. data/app/assets/images/material/icons/keyboard_arrow_left.svg +0 -4
  143. data/app/assets/images/material/icons/keyboard_arrow_right.svg +0 -4
  144. data/app/assets/images/material/icons/keyboard_arrow_up.svg +0 -4
  145. data/app/assets/images/material/icons/today.svg +0 -4
  146. data/app/assets/javascripts/activeadmin_addons/all.js +0 -753
  147. data/app/assets/stylesheets/activeadmin_addons/addons/material-datepicker.scss +0 -173
  148. data/app/assets/stylesheets/activeadmin_addons/addons/material-toggle_bool.scss +0 -52
  149. data/app/assets/stylesheets/activeadmin_addons/inputs/select2.scss +0 -3
  150. data/app/assets/stylesheets/activeadmin_addons/material.scss +0 -53
  151. data/app/javascript/activeadmin_addons/addons/interactive_select_tag.js +0 -95
  152. data/app/javascript/activeadmin_addons/inputs/nested-select.js +0 -170
  153. data/app/javascript/activeadmin_addons/inputs/search-select.js +0 -76
  154. data/app/javascript/activeadmin_addons/inputs/select2.js +0 -52
  155. data/app/javascript/activeadmin_addons/inputs/selected-list.js +0 -107
  156. data/app/javascript/activeadmin_addons/inputs/tags.js +0 -76
  157. data/lib/activeadmin_addons/addons/attachment_builder.rb +0 -60
  158. data/lib/activeadmin_addons/support/enumerize_formtastic_support.rb +0 -18
  159. data/lib/generators/activeadmin_addons/assets/assets_generator.rb +0 -53
  160. data/vendor/assets/select2/select2.css +0 -481
  161. data/vendor/assets/select2/select2.full.js +0 -6820
  162. /data/app/{assets/stylesheets/activeadmin_addons → javascript/activeadmin_addons/stylesheets}/addons/interactive_select_tag.scss +0 -0
  163. /data/app/{assets/stylesheets/activeadmin_addons → javascript/activeadmin_addons/stylesheets}/addons/toggle_bool.scss +0 -0
  164. /data/app/{assets/stylesheets/activeadmin_addons → javascript/activeadmin_addons/stylesheets}/imports/jquery-datepicker.scss +0 -0
  165. /data/app/{assets/stylesheets/activeadmin_addons → javascript/activeadmin_addons/stylesheets}/inputs/color-picker.scss +0 -0
  166. /data/app/{assets/stylesheets/activeadmin_addons → javascript/activeadmin_addons/stylesheets}/inputs/date-time-picker-filter.scss +0 -0
  167. /data/app/{assets/stylesheets/activeadmin_addons → javascript/activeadmin_addons/stylesheets}/inputs/date-time-picker.scss +0 -0
  168. /data/app/{assets/stylesheets/activeadmin_addons → javascript/activeadmin_addons/stylesheets}/inputs/numeric-range-filter.scss +0 -0
  169. /data/app/{assets/stylesheets/activeadmin_addons → javascript/activeadmin_addons/stylesheets}/vendor/palette-color-picker.scss +0 -0
@@ -1,107 +0,0 @@
1
- var initializer = function() {
2
- setupSelectedList(document);
3
-
4
- $(document).on('has_many_add:after', function(event, container) {
5
- setupSelectedList(container);
6
- });
7
-
8
- function setupSelectedList(container) {
9
- $('.selected-list-container').click(function(event) {
10
- var item = $(event.target);
11
- if (item.hasClass('selected-item')) {
12
- item.remove();
13
- }
14
- });
15
-
16
- $('.selected-list-input', container).each(function(i, el) {
17
- var element = $(el);
18
- var url = element.data('url');
19
- var fields = element.data('fields');
20
- var predicate = element.data('predicate');
21
- var displayName = element.data('display-name');
22
- var method = element.data('method');
23
- var model = element.data('model');
24
- var prefix = model + '_' + method;
25
- var responseRoot = element.data('response-root');
26
- var minimumInputLength = element.data('minimum-input-length');
27
- var order = element.data('order');
28
-
29
- var selectOptions = {
30
- minimumInputLength: minimumInputLength,
31
- allowClear: true,
32
- ajax: {
33
- url: url,
34
- dataType: 'json',
35
- delay: 250,
36
- cache: true,
37
- data: function(params) {
38
- var textQuery = { m: 'or' };
39
- fields.forEach(function(field) {
40
- textQuery[field + '_' + predicate] = params.term;
41
- });
42
-
43
- var query = {
44
- order: order,
45
- q: {
46
- groupings: [textQuery],
47
- combinator: 'and',
48
- },
49
- };
50
-
51
- return query;
52
- },
53
- processResults: function(data) {
54
- if (data.constructor == Object) {
55
- data = data[responseRoot];
56
- }
57
-
58
- return {
59
- results: jQuery.map(data, function(resource) {
60
- return {
61
- id: resource.id,
62
- text: resource[displayName].toString(),
63
- };
64
- }),
65
- };
66
- },
67
- },
68
- };
69
-
70
- $(el).on('select2:select', onItemSelected);
71
- $(el).on('select2:close', onSelectClosed);
72
- $(el).select2(selectOptions);
73
-
74
- function onItemSelected(event) {
75
- var data = event.params.data;
76
- var selectedItemsContainer = $("[id='" + prefix + "_selected_values']");
77
- var itemName = model + '[' + method + '][]';
78
- var itemId = prefix + '_' + data.id;
79
-
80
- if ($('#' + itemId).length > 0) {
81
- return;
82
- }
83
-
84
- var item = $('<div>' + data.text + '</div>').attr({
85
- class: 'selected-item',
86
- id: itemId,
87
- });
88
-
89
- var hiddenInput = $('<input>').attr({
90
- name: itemName,
91
- type: 'hidden',
92
- value: data.id,
93
- });
94
-
95
- item.appendTo(selectedItemsContainer);
96
- hiddenInput.appendTo(item);
97
- }
98
-
99
- function onSelectClosed() {
100
- $(el).val(null).trigger('change');
101
- }
102
- });
103
- }
104
- };
105
-
106
- $(initializer);
107
- $(document).on('turbolinks:load', initializer);
@@ -1,76 +0,0 @@
1
- var initializer = function() {
2
- setupTags(document);
3
-
4
- $(document).on('has_many_add:after', function(event, container) {
5
- setupTags(container);
6
- });
7
-
8
- function setupTags(container) {
9
- $('.tags-input', container).each(function(i, el) {
10
- var model = $(el).data('model');
11
- var method = $(el).data('method');
12
- var prefix = model + '_' + method;
13
- var isRelation = !!$(el).data('relation');
14
- var collection = $(el).data('collection');
15
- var width = $(el).data('width');
16
- var selectOptions = {
17
- width: width,
18
- multiple: true,
19
- tags: true,
20
- data: collection,
21
- };
22
-
23
- if (!!isRelation) {
24
- selectOptions.createTag = function() {
25
- return undefined;
26
- };
27
- }
28
-
29
- $(el).on('select2:select', onItemAdded);
30
- $(el).on('select2:unselect', onItemRemoved);
31
- $(el).select2(selectOptions);
32
-
33
- function getSelectedItems() {
34
- var choices = $(el).parent('li.input').find('.select2-selection__choice');
35
- return $.map(choices, function(item) {
36
- return $(item).attr('title');
37
- });
38
- }
39
-
40
- function fillHiddenInput() {
41
- var hiddenInput = $('#' + prefix);
42
- hiddenInput.val(getSelectedItems().join());
43
- }
44
-
45
- function onItemRemoved(event) {
46
- if (isRelation) {
47
- var itemId = '[id=\'' + prefix + '_' + event.params.data.id + '\']';
48
- $(itemId).remove();
49
- } else {
50
- fillHiddenInput();
51
- }
52
- }
53
-
54
- function onItemAdded(event) {
55
- if (isRelation) {
56
- var value = event.params.data.id;
57
- var selectedItemsContainer = $("[id='" + prefix + "_selected_values']");
58
- var itemName = model + '[' + method + '][]';
59
- var itemId = prefix + '_' + value;
60
-
61
- $('<input>').attr({
62
- id: itemId,
63
- name: itemName,
64
- type: 'hidden',
65
- value: value,
66
- }).appendTo(selectedItemsContainer);
67
- } else {
68
- fillHiddenInput();
69
- }
70
- }
71
- });
72
- }
73
- };
74
-
75
- $(initializer);
76
- $(document).on('turbolinks:load', initializer);
@@ -1,60 +0,0 @@
1
- module ActiveAdminAddons
2
- class AttachmentBuilder < CustomBuilder
3
- KNOWN_EXTENSIONS = %w{
4
- 3gp 7z ace ai aif aiff amr asf asx bat bin bmp bup cab cbr cda cdl cdr chm
5
- dat divx dll dmg doc docx dss dvf dwg eml eps exe fla flv gif gz hqx htm html
6
- ifo indd iso jar jpeg jpg lnk log m4a m4b m4p m4v mcd mdb mid mov mp2 mp3 mp4
7
- mpeg mpg msi mswmm ogg pdf png pps ppt pptx ps psd pst ptb pub qbb qbw qxd ram
8
- rar rm rmvb rtf sea ses sit sitx ss swf tgz thm tif tmp torrent ttf txt
9
- vcd vob wav wma wmv wps xls xlsx xpi zip
10
- }
11
-
12
- def icon_for_filename(filename)
13
- for_ext File.extname(filename.to_s)
14
- end
15
-
16
- def for_ext(file_extension)
17
- ext = file_extension.start_with?(".") ? file_extension[1..-1] : file_extension
18
- ext.downcase!
19
- ext = "unknown" unless KNOWN_EXTENSIONS.include?(ext)
20
- "fileicons/file_extension_#{ext}.png"
21
- end
22
-
23
- def build_label
24
- icon = icon_for_filename(file.original_filename)
25
- style = { width: "20", height: "20", style: "margin-right: 5px; vertical-align: middle;" }
26
- icon_img = context.image_tag(icon, style)
27
- text = label_text
28
-
29
- context.content_tag(:span) do
30
- context.concat(icon_img)
31
- context.safe_concat(text)
32
- end
33
- end
34
-
35
- def label_text
36
- label = if options[:label].nil?
37
- file.original_filename
38
- elsif options[:label].is_a? Proc
39
- options[:label].call(model).to_s
40
- else
41
- options[:label].to_s
42
- end
43
-
44
- options[:truncate] ? context.truncate(label) : label
45
- end
46
-
47
- def render
48
- raise "you need to pass a paperclip attribute" unless file.respond_to?(:url)
49
- options[:truncate] = options.fetch(:truncate, true)
50
- return nil unless file.file?
51
- context.link_to(build_label, file.url, target: "_blank", class: "attachment-link")
52
- end
53
-
54
- def file
55
- model.send(attribute)
56
- end
57
- end
58
- end
59
-
60
- ActiveAdminAddons::AttachmentBuilder.create_view_methods
@@ -1,18 +0,0 @@
1
- module ActiveAdminAddons
2
- module RansackFormBuilderExtension
3
- def input(method, options = {})
4
- if object.is_a?(::Ransack::Search)
5
- klass = object.klass
6
-
7
- if klass.respond_to?(:enumerized_attributes) && (attr = klass.enumerized_attributes[method])
8
- options[:collection] ||= attr.options
9
- options[:as] = :select
10
- end
11
- end
12
-
13
- super(method, options)
14
- end
15
- end
16
- end
17
-
18
- ::Formtastic::FormBuilder.send :prepend, ActiveAdminAddons::RansackFormBuilderExtension
@@ -1,53 +0,0 @@
1
- module ActiveadminAddons
2
- module Generators
3
- class AssetsGenerator < Rails::Generators::Base
4
- class_option :theme, type: :string, default: '', desc: "Use default or 'material' theme"
5
-
6
- def add_javascripts
7
- file_path = 'app/assets/javascripts/active_admin'
8
- reference = "#= require active_admin/base\n"
9
-
10
- begin
11
- inject_into_file("#{file_path}.js.coffee", coffee_assets, after: reference)
12
- rescue
13
- reference = "//= require active_admin/base\n"
14
- inject_into_file("#{file_path}.js", js_assets, after: reference)
15
- end
16
- end
17
-
18
- def add_stylesheets
19
- file_path = 'app/assets/stylesheets/active_admin'
20
-
21
- begin
22
- prepend_file("#{file_path}.scss", css_assets)
23
- rescue
24
- prepend_file("#{file_path}.css.scss", css_assets)
25
- end
26
- end
27
-
28
- private
29
-
30
- def js_assets
31
- to_add = "//= require activeadmin_addons/all\n"
32
- to_add += "//= require active_material\n" if options['theme'] == "material"
33
- to_add
34
- end
35
-
36
- def coffee_assets
37
- to_add = "#= require activeadmin_addons/all\n"
38
- to_add += "#= require active_material\n" if options['theme'] == "material"
39
- to_add
40
- end
41
-
42
- def css_assets
43
- if options['theme'] == "material"
44
- to_add = "$am-theme-primary: #342e48;\n"
45
- to_add += "@import 'activeadmin_addons/all';\n"
46
- to_add + "@import 'activeadmin_addons/material';\n"
47
- else
48
- "@import 'activeadmin_addons/all';\n"
49
- end
50
- end
51
- end
52
- end
53
- end