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
@@ -0,0 +1,75 @@
1
+ import SlimSelect from 'slim-select';
2
+ import merge from 'lodash.merge';
3
+
4
+ import * as searchSelect from './slim-select-search';
5
+ import * as simpleTagsSelect from './slim-select-simple-tags';
6
+ import * as nestedSelect from './slim-select-nested';
7
+ import * as selectedListSelect from './slim-select-selected-list';
8
+ import * as tagsSelect from './slim-select-tags';
9
+
10
+ const SELECT_CLASS = 'select:not(.default-select)';
11
+ const SLIM_SELECT_CLASS = 'select.slim-select';
12
+
13
+ const selectTypes = {
14
+ searchSelect,
15
+ simpleTagsSelect,
16
+ nestedSelect,
17
+ selectedListSelect,
18
+ tagsSelect,
19
+ };
20
+
21
+ // eslint-disable-next-line max-statements
22
+ function setupSelect(el) {
23
+ const emptyOption = el.querySelector('option[value=""]');
24
+ if (!emptyOption) {
25
+ el.insertAdjacentHTML('afterbegin', '<option value=""></option>');
26
+ }
27
+ el.querySelector('option[value=""]').dataset.placeholder = true;
28
+
29
+ el.style.width = el.dataset.width;
30
+ let settings = {
31
+ select: el,
32
+ settings: {
33
+ allowDeselect: true,
34
+ placeholderText: 'Select Value',
35
+ },
36
+ };
37
+
38
+ Object.keys(selectTypes).forEach((type) => {
39
+ if (selectTypes[type].classes.some((className) => el.classList.contains(className))) {
40
+ settings = merge({}, settings, selectTypes[type].settings(el));
41
+ if (selectTypes[type].init) {
42
+ selectTypes[type].init(el);
43
+ }
44
+ }
45
+ });
46
+
47
+ const slim = new SlimSelect(settings);
48
+ el.dataset.slimSelectId = slim.settings.id;
49
+ }
50
+
51
+ function initSelects(node = document) {
52
+ if (document.querySelector('body').dataset.defaultSelect === 'slim-select') {
53
+ node.querySelectorAll(SELECT_CLASS).forEach(setupSelect);
54
+ }
55
+
56
+ node.querySelectorAll(SLIM_SELECT_CLASS).forEach(setupSelect);
57
+ }
58
+
59
+ // mutation observer to add slim select to new elements
60
+ const observer = new MutationObserver((mutations) => {
61
+ mutations.forEach((mutation) => {
62
+ if (mutation.type === 'childList') {
63
+ mutation.addedNodes.forEach((node) => {
64
+ if (node instanceof Element) {
65
+ initSelects(node);
66
+ }
67
+ });
68
+ }
69
+ });
70
+ });
71
+
72
+ window.addEventListener('load', () => {
73
+ initSelects();
74
+ observer.observe(document.querySelector('body'), { attributes: false, childList: true, subtree: true });
75
+ });
@@ -1,20 +1,14 @@
1
- @import 'select2';
2
- @import 'imports/jquery-datepicker';
1
+ @import 'jquery-datetimepicker/build/jquery.datetimepicker.min.css';
3
2
  @import 'vendor/palette-color-picker';
3
+ @import 'imports/slimselect';
4
+
5
+ $error-color: #932419;
4
6
 
5
7
  @import 'inputs/numeric-range-filter';
6
8
  @import 'inputs/date-time-picker-filter';
7
9
  @import 'inputs/color-picker';
8
10
  @import 'inputs/date-time-picker';
9
- @import 'inputs/select2';
10
11
  @import 'inputs/selected-list';
12
+ @import 'inputs/slim-select';
11
13
  @import 'addons/toggle_bool';
12
14
  @import 'addons/interactive_select_tag';
13
-
14
- $error-color: #932419;
15
-
16
- li.error {
17
- .select2-selection {
18
- border-color: $error-color;
19
- }
20
- }
@@ -0,0 +1 @@
1
+ :root{--ss-primary-color: #5897fb;--ss-bg-color: #ffffff;--ss-font-color: #4d4d4d;--ss-font-placeholder-color: #8d8d8d;--ss-disabled-color: #dcdee2;--ss-border-color: #dcdee2;--ss-highlight-color: #fffb8c;--ss-success-color: #00b755;--ss-error-color: #dc3545;--ss-main-height: 30px;--ss-content-height: 300px;--ss-spacing-l: 7px;--ss-spacing-m: 5px;--ss-spacing-s: 3px;--ss-animation-timing: 0.2s;--ss-border-radius: 4px}@keyframes ss-valueIn{0%{transform:scale(0);opacity:0}100%{transform:scale(1);opacity:1}}@keyframes ss-valueOut{0%{transform:scale(1);opacity:1}100%{transform:scale(0);opacity:0}}.ss-hide{display:none !important}.ss-main{display:flex;flex-direction:row;position:relative;user-select:none;color:var(--ss-font-color);min-height:var(--ss-main-height);width:100%;padding:var(--ss-spacing-s);cursor:pointer;border:1px solid var(--ss-border-color);border-radius:var(--ss-border-radius);background-color:var(--ss-bg-color);outline:0;box-sizing:border-box;transition:background-color var(--ss-animation-timing)}.ss-main:focus{box-shadow:0 0 5px var(--ss-primary-color)}.ss-main.ss-disabled{background-color:var(--ss-disabled-color);cursor:not-allowed}.ss-main.ss-disabled .ss-values .ss-disabled{color:var(--ss-font-color)}.ss-main.ss-disabled .ss-values .ss-value .ss-value-delete{cursor:not-allowed}.ss-main.ss-open-above{border-top-left-radius:0px;border-top-right-radius:0px}.ss-main.ss-open-below{border-bottom-left-radius:0px;border-bottom-right-radius:0px}.ss-main .ss-values{display:inline-flex;flex-wrap:wrap;gap:var(--ss-spacing-m);flex:1 1 100%}.ss-main .ss-values .ss-placeholder{display:flex;padding:var(--ss-spacing-s) var(--ss-spacing-m) var(--ss-spacing-s) var(--ss-spacing-m);margin:auto 0px auto 0px;line-height:1em;align-items:center;width:100%;color:var(--ss-font-placeholder-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ss-main .ss-values .ss-max{display:flex;user-select:none;align-items:center;width:fit-content;font-size:12px;color:var(--ss-bg-color);line-height:1;padding:var(--ss-spacing-s) var(--ss-spacing-m);background-color:var(--ss-primary-color);border-radius:var(--ss-border-radius)}.ss-main .ss-values .ss-single{display:flex;margin:auto 0px auto var(--ss-spacing-s)}.ss-main .ss-values .ss-value{display:flex;user-select:none;align-items:center;width:fit-content;background-color:var(--ss-primary-color);border-radius:var(--ss-border-radius);animation-name:ss-valueIn;animation-duration:var(--ss-animation-timing);animation-timing-function:ease-out;animation-fill-mode:both}.ss-main .ss-values .ss-value.ss-value-out{animation-name:ss-valueOut;animation-duration:var(--ss-animation-timing);animation-timing-function:ease-out}.ss-main .ss-values .ss-value .ss-value-text{font-size:12px;color:var(--ss-bg-color);line-height:1;padding:var(--ss-spacing-s) var(--ss-spacing-m)}.ss-main .ss-values .ss-value .ss-value-delete{display:flex;align-items:center;height:var(--ss-spacing-l);width:var(--ss-spacing-l);padding:var(--ss-spacing-s) var(--ss-spacing-m);cursor:pointer;border-left:solid 1px var(--ss-bg-color)}.ss-main .ss-values .ss-value .ss-value-delete svg{height:var(--ss-spacing-l);width:var(--ss-spacing-l)}.ss-main .ss-values .ss-value .ss-value-delete svg path{fill:none;stroke:var(--ss-bg-color);stroke-width:18;stroke-linecap:round;stroke-linejoin:round}.ss-main .ss-deselect{display:flex;align-self:center;justify-content:flex-end;flex:0 1 auto;width:8px;height:8px;margin:0 var(--ss-spacing-m) 0 var(--ss-spacing-m)}.ss-main .ss-deselect svg{width:8px;height:8px}.ss-main .ss-deselect svg path{fill:none;stroke:var(--ss-font-color);stroke-width:20;stroke-linecap:round;stroke-linejoin:round}.ss-main .ss-arrow{display:flex;align-items:center;justify-content:flex-end;flex:0 1 auto;width:12px;height:12px;margin:auto var(--ss-spacing-m) auto var(--ss-spacing-m)}.ss-main .ss-arrow path{fill:none;stroke:var(--ss-font-color);stroke-width:18;stroke-linecap:round;stroke-linejoin:round;transition-timing-function:ease-out;transition:var(--ss-animation-timing)}.ss-content{position:absolute;display:flex;height:auto;flex-direction:column;width:auto;max-height:var(--ss-content-height);box-sizing:border-box;border:solid 1px var(--ss-border-color);background-color:var(--ss-bg-color);transition:transform var(--ss-animation-timing),opacity var(--ss-animation-timing);opacity:0;transform:scaleY(0);transform-origin:center top;overflow:hidden;z-index:10000}.ss-content.ss-relative{position:relative;height:100%}.ss-content.ss-open-above{flex-direction:column-reverse;opacity:1;transform:scaleY(1);transform-origin:center bottom;border-top-left-radius:var(--ss-border-radius);border-top-right-radius:var(--ss-border-radius)}.ss-content.ss-open-below{opacity:1;transform:scaleY(1);transform-origin:center top;border-bottom-left-radius:var(--ss-border-radius);border-bottom-right-radius:var(--ss-border-radius)}.ss-content .ss-search{flex:0 1 auto;display:flex;flex-direction:row;padding:var(--ss-spacing-l) var(--ss-spacing-l) var(--ss-spacing-m) var(--ss-spacing-l)}.ss-content .ss-search input{display:inline-flex;font-size:inherit;line-height:inherit;flex:1 1 auto;width:100%;min-width:0px;padding:var(--ss-spacing-m) var(--ss-spacing-l);margin:0;border:1px solid var(--ss-border-color);border-radius:var(--ss-border-radius);background-color:var(--ss-bg-color);outline:0;text-align:left;box-sizing:border-box}.ss-content .ss-search input::placeholder{color:var(--ss-font-placeholder-color);vertical-align:middle}.ss-content .ss-search input:focus{box-shadow:0 0 5px var(--ss-primary-color)}.ss-content .ss-search .ss-addable{display:inline-flex;justify-content:center;align-items:center;cursor:pointer;flex:0 0 auto;height:auto;margin:0 0 0 var(--ss-spacing-m);border:1px solid var(--ss-border-color);border-radius:var(--ss-border-radius)}.ss-content .ss-search .ss-addable svg{display:flex;align-items:center;justify-content:flex-end;flex:0 1 auto;width:12px;height:12px;margin:auto var(--ss-spacing-m) auto var(--ss-spacing-m)}.ss-content .ss-search .ss-addable svg path{fill:none;stroke:var(--ss-font-color);stroke-width:18;stroke-linecap:round;stroke-linejoin:round}.ss-content .ss-list{flex:1 1 auto;height:auto;overflow-x:hidden;overflow-y:auto}.ss-content .ss-list .ss-error{color:var(--ss-error-color);padding:var(--ss-spacing-l)}.ss-content .ss-list .ss-searching{color:var(--ss-font-color);padding:var(--ss-spacing-l)}.ss-content .ss-list .ss-optgroup.ss-close .ss-option{display:none !important}.ss-content .ss-list .ss-optgroup .ss-optgroup-label{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:var(--ss-spacing-m) var(--ss-spacing-l) var(--ss-spacing-m) var(--ss-spacing-l)}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-label-text{flex:1 1 auto;font-weight:bold;color:var(--ss-font-color)}.ss-content .ss-list .ss-optgroup .ss-optgroup-label:has(.ss-arrow){cursor:pointer}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions{flex:0 1 auto;display:flex;flex-direction:row;align-items:center;justify-content:center;gap:var(--ss-spacing-m)}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-selectall{flex:0 0 auto;display:flex;flex-direction:row;cursor:pointer}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-selectall:hover{opacity:.5}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-selectall.ss-selected svg path{stroke:var(--ss-error-color)}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-selectall span{flex:0 1 auto;display:flex;align-items:center;justify-content:center;font-size:60%;text-align:center;padding:0 var(--ss-spacing-s) 0 0}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-selectall svg{flex:0 1 auto;width:13px;height:13px}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-selectall svg path{fill:none;stroke:var(--ss-success-color);stroke-linecap:round;stroke-linejoin:round}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-selectall svg:first-child{stroke-width:5}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-selectall svg:last-child{stroke-width:11}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-closable{flex:0 1 auto;display:flex;flex-direction:row;cursor:pointer}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-closable .ss-arrow{flex:1 1 auto;width:10px;height:10px}.ss-content .ss-list .ss-optgroup .ss-optgroup-label .ss-optgroup-actions .ss-closable .ss-arrow path{fill:none;stroke:var(--ss-font-color);stroke-width:18;stroke-linecap:round;stroke-linejoin:round;transition-timing-function:ease-out;transition:var(--ss-animation-timing)}.ss-content .ss-list .ss-optgroup .ss-option{padding:var(--ss-spacing-s) var(--ss-spacing-s) var(--ss-spacing-s) calc(var(--ss-spacing-l)*3)}.ss-content .ss-list .ss-option{display:flex;padding:var(--ss-spacing-m) var(--ss-spacing-l) var(--ss-spacing-m) var(--ss-spacing-l);color:var(--ss-font-color);cursor:pointer;user-select:none}.ss-content .ss-list .ss-option:hover{color:var(--ss-bg-color);background-color:var(--ss-primary-color)}.ss-content .ss-list .ss-option.ss-highlighted,.ss-content .ss-list .ss-option:not(.ss-disabled).ss-selected{color:var(--ss-bg-color);background-color:var(--ss-primary-color)}.ss-content .ss-list .ss-option.ss-disabled{cursor:not-allowed;background-color:var(--ss-disabled-color)}.ss-content .ss-list .ss-option.ss-disabled:hover{color:var(--ss-font-color)}.ss-content .ss-list .ss-option .ss-search-highlight{background-color:var(--ss-highlight-color)}
@@ -3,7 +3,6 @@ $selected-list-btn-hover-color: #333;
3
3
 
4
4
  .selected-list-container {
5
5
  display: inline-block;
6
- width: 80%;
7
6
 
8
7
  .selected-item {
9
8
  height: 25px;
@@ -0,0 +1,9 @@
1
+ .ss-main {
2
+ width: auto;
3
+ }
4
+
5
+ li.error {
6
+ .ss-main {
7
+ border-color: $error-color;
8
+ }
9
+ }
@@ -2,9 +2,27 @@ 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)
6
- style = options.fetch(:style, :original)
7
- context.image_tag(data.url(style)) if data.file?
5
+
6
+ if Object.const_defined?('Shrine::UploadedFile') && data.is_a?(Shrine::UploadedFile)
7
+ shrine_data
8
+ else
9
+ raise "you need to pass a shrine image attribute"
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def shrine_data
16
+ image_options = options[:image_options].presence || {}
17
+ if options[:style] && derivatives.include?(options[:style])
18
+ context.image_tag(model.send("#{attribute}_url", options[:style]), image_options)
19
+ else
20
+ context.image_tag(data.url, image_options)
21
+ end
22
+ end
23
+
24
+ def derivatives
25
+ model.send("#{attribute}_derivatives")
8
26
  end
9
27
  end
10
28
  end
@@ -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
@@ -1,13 +1,8 @@
1
1
  module ActiveAdminAddons
2
2
  class TagBuilder < CustomBuilder
3
3
  def render
4
- @enum_attr = if enumerize_attr?
5
- :enumerize
6
- elsif rails_enum_attr?
7
- :enum
8
- end
4
+ raise "you need to pass an enum attribute" unless rails_enum_attr?
9
5
 
10
- raise "you need to pass an enumerize or enum attribute" unless @enum_attr
11
6
  append_tag
12
7
  end
13
8
 
@@ -25,9 +20,9 @@ module ActiveAdminAddons
25
20
 
26
21
  context.div(interactive_tag_select_params) do
27
22
  context.select do
28
- possible_values.each do |val|
29
- context.option(value: val, selected: val == data) do
30
- context.text_node val.capitalize
23
+ possible_values.each do |label, value|
24
+ context.option(value: value, selected: value == data) do
25
+ context.text_node label
31
26
  end
32
27
  end
33
28
  end
@@ -36,7 +31,7 @@ module ActiveAdminAddons
36
31
  end
37
32
 
38
33
  def display_data
39
- @enum_attr == :enumerize ? data.text : data
34
+ EnumUtils.translate_enum_option(model.class, attribute.to_s, data)
40
35
  end
41
36
 
42
37
  def interactive_params(klass)
@@ -68,17 +63,7 @@ module ActiveAdminAddons
68
63
 
69
64
  def possible_values
70
65
  klass = model.class
71
- if @enum_attr == :enumerize
72
- klass.enumerized_attributes[attribute.to_s].values
73
- else
74
- klass.defined_enums[attribute.to_s].keys
75
- end
76
- end
77
-
78
- def enumerize_attr?
79
- data.is_a?("Enumerize::Value".constantize)
80
- rescue NameError
81
- false
66
+ EnumUtils.options_for_select(klass, attribute.to_s)
82
67
  end
83
68
 
84
69
  def rails_enum_attr?
@@ -1,18 +1,13 @@
1
1
  module ActiveAdminAddons
2
2
  module Rails
3
3
  class Engine < ::Rails::Engine
4
- require 'sassc'
5
- require 'sassc-rails'
6
4
  require "xdan-datetimepicker-rails"
7
5
  require "require_all"
8
- require "active_material"
9
6
 
10
7
  initializer "initialize addons" do |app|
11
8
  require_rel "support"
12
9
  require_rel "addons"
13
10
  require_rel "active_admin_config"
14
- app.config.assets.precompile += %w(select.scss fileicons/*.png switches/switch_*.png
15
- material/icons *.svg)
16
11
  end
17
12
  end
18
13
  end
@@ -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
@@ -14,7 +14,7 @@ module ActiveAdminAddons
14
14
  end
15
15
 
16
16
  def initial_collection_to_select_options
17
- initial_options = [[nil]] # add blank option
17
+ initial_options = [] # add blank option
18
18
  selected = selected_item
19
19
 
20
20
  if selected
@@ -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 = "2.0.0.beta.0"
3
3
  end
@@ -4,7 +4,7 @@ module ActiveadminAddons
4
4
  attr_writer :default_select, :datetime_picker_default_options, :datetime_picker_input_format
5
5
 
6
6
  def default_select
7
- return "select2" unless @default_select
7
+ return "slim-select" unless @default_select
8
8
  @default_select
9
9
  end
10
10
 
@@ -11,7 +11,8 @@ module ActiveadminAddons
11
11
  if use_webpacker?
12
12
  generate "activeadmin_addons:webpacker"
13
13
  else
14
- generate "activeadmin_addons:assets"
14
+ puts "ActiveAdmin Addons requires ActiveAdmin installed with webpacker. "\
15
+ "Please run 'rails generate active_admin:install --webpacker' and then 'rails generate activeadmin_addons:install'"
15
16
  end
16
17
  end
17
18
 
@@ -1,6 +1,6 @@
1
1
  ActiveadminAddons.setup do |config|
2
2
  # Change to "default" if you want to use ActiveAdmin's default select control.
3
- # config.default_select = "select2"
3
+ # config.default_select = "slim-select"
4
4
 
5
5
  # Set default options for DateTimePickerInput. The options you can provide are the same as in
6
6
  # xdan's datetimepicker library (https://github.com/xdan/datetimepicker/tree/2.5.4). Yo need to
@@ -17,7 +17,7 @@ module ActiveadminAddons
17
17
  end
18
18
 
19
19
  def install_package
20
- run "yarn add activeadmin_addons"
20
+ run "yarn add activeadmin_addons@beta"
21
21
  end
22
22
 
23
23
  private