activeadmin-tom_select 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. checksums.yaml +7 -0
  2. data/.actrc +20 -0
  3. data/.claude/commands/fix-tests.md +203 -0
  4. data/.github/workflows/ci.yml +174 -0
  5. data/.github/workflows/npm-publish.yml +50 -0
  6. data/.gitignore +35 -0
  7. data/.npmignore +58 -0
  8. data/.rspec +1 -0
  9. data/.rubocop.yml +75 -0
  10. data/.yardopts +2 -0
  11. data/AGENTS.md +39 -0
  12. data/Appraisals +9 -0
  13. data/CHANGELOG.md +64 -0
  14. data/CLAUDE.md +157 -0
  15. data/Gemfile +12 -0
  16. data/Gemfile.lock +368 -0
  17. data/LICENSE.txt +25 -0
  18. data/README.md +483 -0
  19. data/Rakefile +4 -0
  20. data/activeadmin-tom_select.gemspec +43 -0
  21. data/bin/rspec +17 -0
  22. data/config/database.yml +16 -0
  23. data/docs/activeadmin-4-detailed-reference.md +932 -0
  24. data/docs/activeadmin-4-gem-migration-guide.md +313 -0
  25. data/docs/combustion.md +213 -0
  26. data/docs/fail.png +0 -0
  27. data/docs/guide-update-your-app.md +283 -0
  28. data/docs/normal.png +0 -0
  29. data/docs/propshaft-readme.md +320 -0
  30. data/docs/propshaft-upgrade.md +484 -0
  31. data/docs/setup-activeadmin-app.md +552 -0
  32. data/docs/setup-activeadmin-gem.md +535 -0
  33. data/docs/tailwind/blog-page.md +341 -0
  34. data/docs/tailwind/upgrade-guide-enhanced.md +438 -0
  35. data/docs/tailwind/upgrade-guide.md +416 -0
  36. data/docs/tailwind-4/active_admin.rake +38 -0
  37. data/docs/tailwind-4/active_admin.tailwind.css +415 -0
  38. data/docs/tailwind-4/tailwind-active_admin.config.js +18 -0
  39. data/docs/test-app-change.md +154 -0
  40. data/docs/test-environment-fixes.md +58 -0
  41. data/docs/update-tom-select.md +184 -0
  42. data/docs/upload-system.md +225 -0
  43. data/gemfiles/rails_7.x_active_admin_4.x.gemfile +10 -0
  44. data/gemfiles/rails_7.x_active_admin_4.x.gemfile.lock +377 -0
  45. data/gemfiles/rails_8.x_active_admin_4.x.gemfile +10 -0
  46. data/gemfiles/rails_8.x_active_admin_4.x.gemfile.lock +372 -0
  47. data/lefthook.yml +17 -0
  48. data/lib/activeadmin/inputs/filters/searchable_select_input.rb +19 -0
  49. data/lib/activeadmin/inputs/searchable_select_input.rb +16 -0
  50. data/lib/activeadmin/tom_select/engine.rb +17 -0
  51. data/lib/activeadmin/tom_select/option_collection.rb +128 -0
  52. data/lib/activeadmin/tom_select/resource_dsl_extension.rb +56 -0
  53. data/lib/activeadmin/tom_select/resource_extension.rb +10 -0
  54. data/lib/activeadmin/tom_select/select_input_extension.rb +168 -0
  55. data/lib/activeadmin/tom_select/version.rb +5 -0
  56. data/lib/activeadmin/tom_select.rb +20 -0
  57. data/lib/activeadmin-tom_select.rb +5 -0
  58. data/lib/generators/active_admin/tom_select/install/install_generator.rb +180 -0
  59. data/npm-package/package-lock.json +51 -0
  60. data/npm-package/package.json +43 -0
  61. data/npm-package/src/index.js +153 -0
  62. data/npm-package/src/tom-select-tailwind.css +392 -0
  63. data/sonar-project.properties +25 -0
  64. data/spec/features/ajax_params_spec.rb +31 -0
  65. data/spec/features/asset_pipeline_diagnostic_spec.rb +155 -0
  66. data/spec/features/end_to_end_spec.rb +273 -0
  67. data/spec/features/filter_input_spec.rb +144 -0
  68. data/spec/features/form_input_spec.rb +122 -0
  69. data/spec/features/inline_ajax_setting_spec.rb +26 -0
  70. data/spec/features/input_errors_spec.rb +76 -0
  71. data/spec/features/input_html_options_spec.rb +30 -0
  72. data/spec/features/options_dsl_spec.rb +230 -0
  73. data/spec/features/production_build_spec.rb +108 -0
  74. data/spec/internal/.node-version +1 -0
  75. data/spec/internal/Gemfile +43 -0
  76. data/spec/internal/Gemfile.lock +333 -0
  77. data/spec/internal/Procfile.dev +3 -0
  78. data/spec/internal/README.md +24 -0
  79. data/spec/internal/Rakefile +6 -0
  80. data/spec/internal/app/admin/categories.rb +26 -0
  81. data/spec/internal/app/admin/dashboard.rb +29 -0
  82. data/spec/internal/app/admin/option_types.rb +19 -0
  83. data/spec/internal/app/admin/option_values.rb +30 -0
  84. data/spec/internal/app/admin/posts.rb +27 -0
  85. data/spec/internal/app/admin/products.rb +22 -0
  86. data/spec/internal/app/admin/rgb_colors.rb +25 -0
  87. data/spec/internal/app/admin/tag_names.rb +21 -0
  88. data/spec/internal/app/admin/test_ajax_params_category.rb +10 -0
  89. data/spec/internal/app/admin/test_ajax_params_post.rb +20 -0
  90. data/spec/internal/app/admin/test_form_post_class.rb +7 -0
  91. data/spec/internal/app/admin/test_form_post_custom.rb +11 -0
  92. data/spec/internal/app/admin/test_form_post_resource.rb +11 -0
  93. data/spec/internal/app/admin/test_form_post_resource_custom.rb +12 -0
  94. data/spec/internal/app/admin/test_inline_ajax_post.rb +9 -0
  95. data/spec/internal/app/admin/test_input_html_post.rb +11 -0
  96. data/spec/internal/app/admin/test_posts_display_text.rb +9 -0
  97. data/spec/internal/app/admin/test_posts_filter.rb +9 -0
  98. data/spec/internal/app/admin/test_posts_named.rb +9 -0
  99. data/spec/internal/app/admin/test_posts_pagination.rb +9 -0
  100. data/spec/internal/app/admin/test_posts_payload_lambda.rb +11 -0
  101. data/spec/internal/app/admin/test_posts_payload_proc.rb +9 -0
  102. data/spec/internal/app/admin/test_posts_scope_lambda.rb +8 -0
  103. data/spec/internal/app/admin/test_posts_scope_params.rb +8 -0
  104. data/spec/internal/app/admin/test_posts_scope_user.rb +8 -0
  105. data/spec/internal/app/admin/test_posts_text_attr.rb +5 -0
  106. data/spec/internal/app/admin/users.rb +23 -0
  107. data/spec/internal/app/admin/variants.rb +31 -0
  108. data/spec/internal/app/assets/config/manifest.js +2 -0
  109. data/spec/internal/app/assets/images/.keep +0 -0
  110. data/spec/internal/app/assets/stylesheets/active_admin.tailwind.css +16 -0
  111. data/spec/internal/app/assets/stylesheets/application.tailwind.css +15 -0
  112. data/spec/internal/app/controllers/application_controller.rb +9 -0
  113. data/spec/internal/app/controllers/concerns/.keep +0 -0
  114. data/spec/internal/app/helpers/application_helper.rb +2 -0
  115. data/spec/internal/app/javascript/active_admin.js +19 -0
  116. data/spec/internal/app/javascript/application.js +2 -0
  117. data/spec/internal/app/jobs/application_job.rb +7 -0
  118. data/spec/internal/app/mailers/application_mailer.rb +4 -0
  119. data/spec/internal/app/models/admin_user.rb +9 -0
  120. data/spec/internal/app/models/application_record.rb +3 -0
  121. data/spec/internal/app/models/article.rb +12 -0
  122. data/spec/internal/app/models/category.rb +12 -0
  123. data/spec/internal/app/models/color.rb +9 -0
  124. data/spec/internal/app/models/concerns/.keep +0 -0
  125. data/spec/internal/app/models/internal/tag_name.rb +14 -0
  126. data/spec/internal/app/models/internal_tag_name.rb +11 -0
  127. data/spec/internal/app/models/option_type.rb +12 -0
  128. data/spec/internal/app/models/option_value.rb +4 -0
  129. data/spec/internal/app/models/post.rb +15 -0
  130. data/spec/internal/app/models/product.rb +12 -0
  131. data/spec/internal/app/models/rgb_color.rb +16 -0
  132. data/spec/internal/app/models/tag.rb +12 -0
  133. data/spec/internal/app/models/tagging.rb +12 -0
  134. data/spec/internal/app/models/user.rb +12 -0
  135. data/spec/internal/app/models/variant.rb +12 -0
  136. data/spec/internal/app/views/layouts/application.html.erb +28 -0
  137. data/spec/internal/app/views/layouts/mailer.html.erb +13 -0
  138. data/spec/internal/app/views/layouts/mailer.text.erb +1 -0
  139. data/spec/internal/app/views/pwa/manifest.json.erb +22 -0
  140. data/spec/internal/app/views/pwa/service-worker.js +26 -0
  141. data/spec/internal/bin/bundle +117 -0
  142. data/spec/internal/bin/dev +11 -0
  143. data/spec/internal/bin/rackup +27 -0
  144. data/spec/internal/bin/rails +4 -0
  145. data/spec/internal/bin/rake +4 -0
  146. data/spec/internal/bin/setup +37 -0
  147. data/spec/internal/config/application.rb +50 -0
  148. data/spec/internal/config/boot.rb +3 -0
  149. data/spec/internal/config/credentials.yml.enc +1 -0
  150. data/spec/internal/config/database.yml +32 -0
  151. data/spec/internal/config/environment.rb +5 -0
  152. data/spec/internal/config/environments/development.rb +63 -0
  153. data/spec/internal/config/environments/production.rb +86 -0
  154. data/spec/internal/config/environments/test.rb +50 -0
  155. data/spec/internal/config/initializers/active_admin.rb +54 -0
  156. data/spec/internal/config/initializers/assets.rb +8 -0
  157. data/spec/internal/config/initializers/content_security_policy.rb +25 -0
  158. data/spec/internal/config/initializers/devise.rb +315 -0
  159. data/spec/internal/config/initializers/filter_parameter_logging.rb +8 -0
  160. data/spec/internal/config/initializers/inflections.rb +16 -0
  161. data/spec/internal/config/initializers/searchable_select.rb +6 -0
  162. data/spec/internal/config/locales/devise.en.yml +65 -0
  163. data/spec/internal/config/locales/en.yml +31 -0
  164. data/spec/internal/config/master.key +1 -0
  165. data/spec/internal/config/puma.rb +38 -0
  166. data/spec/internal/config/routes.rb +17 -0
  167. data/spec/internal/config.ru +6 -0
  168. data/spec/internal/db/schema.rb +174 -0
  169. data/spec/internal/db/seeds.rb +167 -0
  170. data/spec/internal/esbuild.config.js +34 -0
  171. data/spec/internal/lib/tasks/.keep +0 -0
  172. data/spec/internal/lib/tasks/active_admin.rake +55 -0
  173. data/spec/internal/log/.keep +0 -0
  174. data/spec/internal/package-lock.json +1954 -0
  175. data/spec/internal/package.json +21 -0
  176. data/spec/internal/public/400.html +114 -0
  177. data/spec/internal/public/404.html +114 -0
  178. data/spec/internal/public/406-unsupported-browser.html +114 -0
  179. data/spec/internal/public/422.html +114 -0
  180. data/spec/internal/public/500.html +114 -0
  181. data/spec/internal/public/icon.png +0 -0
  182. data/spec/internal/public/icon.svg +3 -0
  183. data/spec/internal/public/robots.txt +1 -0
  184. data/spec/internal/script/.keep +0 -0
  185. data/spec/internal/storage/.keep +0 -0
  186. data/spec/internal/tailwind.config.js +23 -0
  187. data/spec/internal/vendor/.keep +0 -0
  188. data/spec/internal/yarn.lock +824 -0
  189. data/spec/rails_helper.rb +62 -0
  190. data/spec/spec_helper.rb +138 -0
  191. data/spec/support/active_admin_helpers.rb +17 -0
  192. data/spec/support/capybara.rb +8 -0
  193. data/spec/support/models.rb +11 -0
  194. data/spec/support/pluck_polyfill.rb +12 -0
  195. data/spec/support/reset_settings.rb +5 -0
  196. metadata +497 -0
@@ -0,0 +1,372 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ activeadmin-tom_select (4.1.0)
5
+ activeadmin (>= 3.0, < 5)
6
+ ransack (>= 1.8, < 5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (8.0.2.1)
12
+ actionpack (= 8.0.2.1)
13
+ activesupport (= 8.0.2.1)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ zeitwerk (~> 2.6)
17
+ actionmailbox (8.0.2.1)
18
+ actionpack (= 8.0.2.1)
19
+ activejob (= 8.0.2.1)
20
+ activerecord (= 8.0.2.1)
21
+ activestorage (= 8.0.2.1)
22
+ activesupport (= 8.0.2.1)
23
+ mail (>= 2.8.0)
24
+ actionmailer (8.0.2.1)
25
+ actionpack (= 8.0.2.1)
26
+ actionview (= 8.0.2.1)
27
+ activejob (= 8.0.2.1)
28
+ activesupport (= 8.0.2.1)
29
+ mail (>= 2.8.0)
30
+ rails-dom-testing (~> 2.2)
31
+ actionpack (8.0.2.1)
32
+ actionview (= 8.0.2.1)
33
+ activesupport (= 8.0.2.1)
34
+ nokogiri (>= 1.8.5)
35
+ rack (>= 2.2.4)
36
+ rack-session (>= 1.0.1)
37
+ rack-test (>= 0.6.3)
38
+ rails-dom-testing (~> 2.2)
39
+ rails-html-sanitizer (~> 1.6)
40
+ useragent (~> 0.16)
41
+ actiontext (8.0.2.1)
42
+ actionpack (= 8.0.2.1)
43
+ activerecord (= 8.0.2.1)
44
+ activestorage (= 8.0.2.1)
45
+ activesupport (= 8.0.2.1)
46
+ globalid (>= 0.6.0)
47
+ nokogiri (>= 1.8.5)
48
+ actionview (8.0.2.1)
49
+ activesupport (= 8.0.2.1)
50
+ builder (~> 3.1)
51
+ erubi (~> 1.11)
52
+ rails-dom-testing (~> 2.2)
53
+ rails-html-sanitizer (~> 1.6)
54
+ activeadmin (4.0.0.beta16)
55
+ arbre (~> 2.0)
56
+ csv
57
+ formtastic (>= 5.0)
58
+ formtastic_i18n (>= 0.7)
59
+ inherited_resources (~> 2.0)
60
+ kaminari (>= 1.2.1)
61
+ railties (>= 7.0)
62
+ ransack (>= 4.0)
63
+ activejob (8.0.2.1)
64
+ activesupport (= 8.0.2.1)
65
+ globalid (>= 0.3.6)
66
+ activemodel (8.0.2.1)
67
+ activesupport (= 8.0.2.1)
68
+ activerecord (8.0.2.1)
69
+ activemodel (= 8.0.2.1)
70
+ activesupport (= 8.0.2.1)
71
+ timeout (>= 0.4.0)
72
+ activestorage (8.0.2.1)
73
+ actionpack (= 8.0.2.1)
74
+ activejob (= 8.0.2.1)
75
+ activerecord (= 8.0.2.1)
76
+ activesupport (= 8.0.2.1)
77
+ marcel (~> 1.0)
78
+ activesupport (8.0.2.1)
79
+ base64
80
+ benchmark (>= 0.3)
81
+ bigdecimal
82
+ concurrent-ruby (~> 1.0, >= 1.3.1)
83
+ connection_pool (>= 2.2.5)
84
+ drb
85
+ i18n (>= 1.6, < 2)
86
+ logger (>= 1.4.2)
87
+ minitest (>= 5.1)
88
+ securerandom (>= 0.3)
89
+ tzinfo (~> 2.0, >= 2.0.5)
90
+ uri (>= 0.13.1)
91
+ addressable (2.8.7)
92
+ public_suffix (>= 2.0.2, < 7.0)
93
+ appraisal (2.5.0)
94
+ bundler
95
+ rake
96
+ thor (>= 0.14.0)
97
+ arbre (2.2.0)
98
+ activesupport (>= 7.0)
99
+ ast (2.4.3)
100
+ base64 (0.3.0)
101
+ bcrypt (3.1.20)
102
+ benchmark (0.4.1)
103
+ bigdecimal (3.2.3)
104
+ builder (3.3.0)
105
+ capybara (3.40.0)
106
+ addressable
107
+ matrix
108
+ mini_mime (>= 0.1.3)
109
+ nokogiri (~> 1.11)
110
+ rack (>= 1.6.0)
111
+ rack-test (>= 0.6.3)
112
+ regexp_parser (>= 1.5, < 3.0)
113
+ xpath (~> 3.2)
114
+ capybara-playwright-driver (0.5.7)
115
+ addressable
116
+ capybara
117
+ playwright-ruby-client (>= 1.16.0)
118
+ combustion (1.5.0)
119
+ activesupport (>= 3.0.0)
120
+ railties (>= 3.0.0)
121
+ thor (>= 0.14.6)
122
+ concurrent-ruby (1.3.5)
123
+ connection_pool (2.5.4)
124
+ crass (1.0.6)
125
+ csv (3.3.5)
126
+ database_cleaner-active_record (2.2.2)
127
+ activerecord (>= 5.a)
128
+ database_cleaner-core (~> 2.0)
129
+ database_cleaner-core (2.0.1)
130
+ date (3.4.1)
131
+ devise (4.9.4)
132
+ bcrypt (~> 3.0)
133
+ orm_adapter (~> 0.1)
134
+ railties (>= 4.1.0)
135
+ responders
136
+ warden (~> 1.2.3)
137
+ diff-lcs (1.6.2)
138
+ docile (1.4.1)
139
+ drb (2.2.3)
140
+ erb (5.0.2)
141
+ erubi (1.13.1)
142
+ formtastic (5.0.0)
143
+ actionpack (>= 6.0.0)
144
+ formtastic_i18n (0.7.0)
145
+ globalid (1.2.1)
146
+ activesupport (>= 6.1)
147
+ has_scope (0.8.2)
148
+ actionpack (>= 5.2)
149
+ activesupport (>= 5.2)
150
+ i18n (1.14.7)
151
+ concurrent-ruby (~> 1.0)
152
+ inherited_resources (2.1.0)
153
+ actionpack (>= 7.0)
154
+ has_scope (>= 0.6)
155
+ railties (>= 7.0)
156
+ responders (>= 2)
157
+ io-console (0.8.1)
158
+ irb (1.15.2)
159
+ pp (>= 0.6.0)
160
+ rdoc (>= 4.0.0)
161
+ reline (>= 0.4.2)
162
+ json (2.13.2)
163
+ kaminari (1.2.2)
164
+ activesupport (>= 4.1.0)
165
+ kaminari-actionview (= 1.2.2)
166
+ kaminari-activerecord (= 1.2.2)
167
+ kaminari-core (= 1.2.2)
168
+ kaminari-actionview (1.2.2)
169
+ actionview
170
+ kaminari-core (= 1.2.2)
171
+ kaminari-activerecord (1.2.2)
172
+ activerecord
173
+ kaminari-core (= 1.2.2)
174
+ kaminari-core (1.2.2)
175
+ language_server-protocol (3.17.0.5)
176
+ lint_roller (1.1.0)
177
+ logger (1.7.0)
178
+ loofah (2.24.1)
179
+ crass (~> 1.0.2)
180
+ nokogiri (>= 1.12.0)
181
+ mail (2.8.1)
182
+ mini_mime (>= 0.1.1)
183
+ net-imap
184
+ net-pop
185
+ net-smtp
186
+ marcel (1.0.4)
187
+ matrix (0.4.3)
188
+ mime-types (3.7.0)
189
+ logger
190
+ mime-types-data (~> 3.2025, >= 3.2025.0507)
191
+ mime-types-data (3.2025.0909)
192
+ mini_mime (1.1.5)
193
+ minitest (5.25.5)
194
+ net-imap (0.5.10)
195
+ date
196
+ net-protocol
197
+ net-pop (0.1.2)
198
+ net-protocol
199
+ net-protocol (0.2.2)
200
+ timeout
201
+ net-smtp (0.5.1)
202
+ net-protocol
203
+ nio4r (2.7.4)
204
+ nokogiri (1.18.10-x86_64-linux-gnu)
205
+ racc (~> 1.4)
206
+ orm_adapter (0.5.0)
207
+ parallel (1.27.0)
208
+ parser (3.3.9.0)
209
+ ast (~> 2.4.1)
210
+ racc
211
+ playwright-ruby-client (1.55.0)
212
+ concurrent-ruby (>= 1.1.6)
213
+ mime-types (>= 3.0)
214
+ pp (0.6.2)
215
+ prettyprint
216
+ prettyprint (0.2.0)
217
+ prism (1.5.1)
218
+ propshaft (1.2.1)
219
+ actionpack (>= 7.0.0)
220
+ activesupport (>= 7.0.0)
221
+ rack
222
+ psych (5.2.6)
223
+ date
224
+ stringio
225
+ public_suffix (6.0.2)
226
+ puma (6.6.1)
227
+ nio4r (~> 2.0)
228
+ racc (1.8.1)
229
+ rack (3.2.1)
230
+ rack-session (2.1.1)
231
+ base64 (>= 0.1.0)
232
+ rack (>= 3.0.0)
233
+ rack-test (2.2.0)
234
+ rack (>= 1.3)
235
+ rackup (2.2.1)
236
+ rack (>= 3)
237
+ rails (8.0.2.1)
238
+ actioncable (= 8.0.2.1)
239
+ actionmailbox (= 8.0.2.1)
240
+ actionmailer (= 8.0.2.1)
241
+ actionpack (= 8.0.2.1)
242
+ actiontext (= 8.0.2.1)
243
+ actionview (= 8.0.2.1)
244
+ activejob (= 8.0.2.1)
245
+ activemodel (= 8.0.2.1)
246
+ activerecord (= 8.0.2.1)
247
+ activestorage (= 8.0.2.1)
248
+ activesupport (= 8.0.2.1)
249
+ bundler (>= 1.15.0)
250
+ railties (= 8.0.2.1)
251
+ rails-dom-testing (2.3.0)
252
+ activesupport (>= 5.0.0)
253
+ minitest
254
+ nokogiri (>= 1.6)
255
+ rails-html-sanitizer (1.6.2)
256
+ loofah (~> 2.21)
257
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
258
+ railties (8.0.2.1)
259
+ actionpack (= 8.0.2.1)
260
+ activesupport (= 8.0.2.1)
261
+ irb (~> 1.13)
262
+ rackup (>= 1.0.0)
263
+ rake (>= 12.2)
264
+ thor (~> 1.0, >= 1.2.2)
265
+ zeitwerk (~> 2.6)
266
+ rainbow (3.1.1)
267
+ rake (13.3.0)
268
+ ransack (4.3.0)
269
+ activerecord (>= 6.1.5)
270
+ activesupport (>= 6.1.5)
271
+ i18n
272
+ rdoc (6.14.2)
273
+ erb
274
+ psych (>= 4.0.0)
275
+ regexp_parser (2.11.3)
276
+ reline (0.6.2)
277
+ io-console (~> 0.5)
278
+ responders (3.1.1)
279
+ actionpack (>= 5.2)
280
+ railties (>= 5.2)
281
+ rspec-core (3.13.5)
282
+ rspec-support (~> 3.13.0)
283
+ rspec-expectations (3.13.5)
284
+ diff-lcs (>= 1.2.0, < 2.0)
285
+ rspec-support (~> 3.13.0)
286
+ rspec-mocks (3.13.5)
287
+ diff-lcs (>= 1.2.0, < 2.0)
288
+ rspec-support (~> 3.13.0)
289
+ rspec-rails (6.1.5)
290
+ actionpack (>= 6.1)
291
+ activesupport (>= 6.1)
292
+ railties (>= 6.1)
293
+ rspec-core (~> 3.13)
294
+ rspec-expectations (~> 3.13)
295
+ rspec-mocks (~> 3.13)
296
+ rspec-support (~> 3.13)
297
+ rspec-support (3.13.5)
298
+ rspec_junit_formatter (0.6.0)
299
+ rspec-core (>= 2, < 4, != 2.12.0)
300
+ rubocop (1.80.2)
301
+ json (~> 2.3)
302
+ language_server-protocol (~> 3.17.0.2)
303
+ lint_roller (~> 1.1.0)
304
+ parallel (~> 1.10)
305
+ parser (>= 3.3.0.2)
306
+ rainbow (>= 2.2.2, < 4.0)
307
+ regexp_parser (>= 2.9.3, < 3.0)
308
+ rubocop-ast (>= 1.46.0, < 2.0)
309
+ ruby-progressbar (~> 1.7)
310
+ unicode-display_width (>= 2.4.0, < 4.0)
311
+ rubocop-ast (1.46.0)
312
+ parser (>= 3.3.7.2)
313
+ prism (~> 1.4)
314
+ rubocop-rspec (3.7.0)
315
+ lint_roller (~> 1.1)
316
+ rubocop (~> 1.72, >= 1.72.1)
317
+ ruby-progressbar (1.13.0)
318
+ securerandom (0.4.1)
319
+ simplecov (0.22.0)
320
+ docile (~> 1.1)
321
+ simplecov-html (~> 0.11)
322
+ simplecov_json_formatter (~> 0.1)
323
+ simplecov-html (0.13.2)
324
+ simplecov_json_formatter (0.1.4)
325
+ sqlite3 (2.7.3-x86_64-linux-gnu)
326
+ stringio (3.1.7)
327
+ thor (1.4.0)
328
+ timeout (0.4.3)
329
+ tzinfo (2.0.6)
330
+ concurrent-ruby (~> 1.0)
331
+ unicode-display_width (3.2.0)
332
+ unicode-emoji (~> 4.1)
333
+ unicode-emoji (4.1.0)
334
+ uri (1.0.3)
335
+ useragent (0.16.11)
336
+ warden (1.2.9)
337
+ rack (>= 2.0.9)
338
+ websocket-driver (0.8.0)
339
+ base64
340
+ websocket-extensions (>= 0.1.0)
341
+ websocket-extensions (0.1.5)
342
+ xpath (3.2.0)
343
+ nokogiri (~> 1.8)
344
+ zeitwerk (2.7.3)
345
+
346
+ PLATFORMS
347
+ x86_64-linux
348
+
349
+ DEPENDENCIES
350
+ activeadmin (= 4.0.0.beta16)
351
+ activeadmin-tom_select!
352
+ appraisal (~> 2.2)
353
+ bundler (>= 1.5, < 3)
354
+ capybara (~> 3.39)
355
+ capybara-playwright-driver (~> 0.5)
356
+ combustion (~> 1.5)
357
+ database_cleaner-active_record (~> 2.1)
358
+ devise (~> 4.9)
359
+ propshaft (~> 1.2)
360
+ puma (~> 6.0)
361
+ rails (~> 8.0)
362
+ rake
363
+ rspec-rails (~> 6.0)
364
+ rspec_junit_formatter
365
+ rubocop (~> 1.50)
366
+ rubocop-ast (~> 1.46.0)
367
+ rubocop-rspec (~> 3.0)
368
+ simplecov
369
+ sqlite3 (~> 2.1)
370
+
371
+ BUNDLED WITH
372
+ 2.4.10
data/lefthook.yml ADDED
@@ -0,0 +1,17 @@
1
+ # Lefthook configuration
2
+ # https://github.com/evilmartians/lefthook
3
+
4
+ pre-commit:
5
+ parallel: true
6
+ commands:
7
+ rubocop:
8
+ tags: style ruby
9
+ glob: "*.{rb,rake}"
10
+ run: bundle exec rubocop --force-exclusion {staged_files}
11
+
12
+ pre-push:
13
+ parallel: true
14
+ commands:
15
+ rspec:
16
+ tags: test ruby
17
+ run: bundle exec rspec --format progress
@@ -0,0 +1,19 @@
1
+ module ActiveAdmin
2
+ module Inputs
3
+ module Filters
4
+ # Searchable select input type for ActiveAdmin filters.
5
+ #
6
+ # @see ActiveAdmin::SearchableSelect::SelectInputExtension
7
+ # SelectInputExtension for list of available options.
8
+ class SearchableSelectInput < SelectInput
9
+ include ActiveAdmin::SearchableSelect::SelectInputExtension
10
+
11
+ # Override to remove the empty "Any" option since we're using
12
+ # Tom Select's clear button plugin instead
13
+ def input_options
14
+ super.merge(include_blank: false)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ module ActiveAdmin
2
+ module Inputs
3
+ # Searchable select input type for ActiveAdmin filters.
4
+ #
5
+ # @see ActiveAdmin::SearchableSelect::SelectInputExtension
6
+ # SelectInputExtension for list of available options.
7
+ class SearchableSelectInput < Formtastic::Inputs::SelectInput
8
+ include ActiveAdmin::SearchableSelect::SelectInputExtension
9
+
10
+ # Override to prevent adding empty options
11
+ def input_options
12
+ super.merge(include_blank: false)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require 'active_admin'
2
+
3
+ module ActiveAdmin
4
+ module SearchableSelect
5
+ # @api private
6
+ class Engine < ::Rails::Engine
7
+ engine_name 'activeadmin_tom_select'
8
+
9
+ initializer 'activeadmin_tom_select.setup' do
10
+ ActiveSupport.on_load(:active_admin) do
11
+ require 'activeadmin/inputs/searchable_select_input'
12
+ require 'activeadmin/inputs/filters/searchable_select_input'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,128 @@
1
+ module ActiveAdmin
2
+ module SearchableSelect
3
+ # @api private
4
+ class OptionCollection
5
+ def initialize(name, options)
6
+ @name = name
7
+ @scope = extract_scope_option(options)
8
+ @display_text = extract_display_text_option(options)
9
+ @filter = extract_filter_option(options)
10
+ @per_page = options.fetch(:per_page, 10)
11
+ @additional_payload = options.fetch(:additional_payload, {})
12
+ end
13
+
14
+ def scope(template, params)
15
+ case @scope
16
+ when Proc
17
+ if @scope.arity.zero?
18
+ template.instance_exec(&@scope)
19
+ else
20
+ template.instance_exec(params, &@scope)
21
+ end
22
+ else
23
+ @scope
24
+ end
25
+ end
26
+
27
+ def display_text(record)
28
+ @display_text.call(record)
29
+ end
30
+
31
+ def collection_action_name
32
+ "#{@name}_options"
33
+ end
34
+
35
+ def as_json(template, params)
36
+ records, more = fetch_records(template, params)
37
+
38
+ results = records.map do |record|
39
+ {
40
+ id: record.id,
41
+ text: display_text(record)
42
+ }.merge(hash_of_additional_payload(record) || {})
43
+ end
44
+
45
+ # Include current page in pagination info (1-based)
46
+ current_page = params[:page].to_i
47
+ current_page = 1 if current_page < 1
48
+
49
+ { results: results, pagination: { more: more, current: current_page } }
50
+ end
51
+
52
+ private
53
+
54
+ attr_reader :per_page
55
+
56
+ def fetch_records(template, params)
57
+ paginate(filter(scope(template, params), params[:term]),
58
+ params[:page])
59
+ end
60
+
61
+ def filter(scope, term)
62
+ term ? @filter.call(term, scope) : scope
63
+ end
64
+
65
+ def paginate(scope, page_index)
66
+ # Use 1-based pagination (page 1 is the first page)
67
+ # Default to page 1 if not specified or invalid
68
+ page_index = page_index.to_i
69
+ page_index = 1 if page_index < 1
70
+
71
+ # Calculate offset for 1-based pagination
72
+ offset = (page_index - 1) * per_page
73
+ records = scope.limit(per_page + 1).offset(offset).to_a
74
+
75
+ [
76
+ records.slice(0, per_page),
77
+ records.size > per_page
78
+ ]
79
+ end
80
+
81
+ def extract_scope_option(options)
82
+ options.fetch(:scope) do
83
+ raise('Missing option: scope. ' \
84
+ 'Pass the collection of items to render options for.')
85
+ end
86
+ end
87
+
88
+ def extract_display_text_option(options)
89
+ options.fetch(:display_text) do
90
+ text_attribute = options.fetch(:text_attribute) do
91
+ raise('Missing option: display_text or text_attribute. ' \
92
+ 'Either pass a proc to determine the display text for a record ' \
93
+ 'or set the text_attribute option.')
94
+ end
95
+
96
+ ->(record) { record.send(text_attribute) }
97
+ end
98
+ end
99
+
100
+ def extract_filter_option(options)
101
+ options.fetch(:filter) do
102
+ text_attribute = options.fetch(:text_attribute) do
103
+ raise('Missing option: filter or text_attribute. ' \
104
+ 'Either pass a proc which filters the scope according to a given ' \
105
+ 'or set the text_attribute option to apply a default Ransack filter.')
106
+ end
107
+
108
+ ->(term, scope) { scope.ransack("#{text_attribute}_cont" => term).result }
109
+ end
110
+ end
111
+
112
+ def build_additional_payload(record)
113
+ case @additional_payload
114
+ when Proc
115
+ @additional_payload.call(record).to_h
116
+ else
117
+ {}
118
+ end
119
+ end
120
+
121
+ def hash_of_additional_payload(record)
122
+ return nil if @additional_payload.nil? && @additional_payload.empty?
123
+
124
+ build_additional_payload(record)
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,56 @@
1
+ module ActiveAdmin
2
+ module SearchableSelect
3
+ # Mixin for ActiveAdmin resource DSL
4
+ module ResourceDSLExtension
5
+ # Define a collection action to serve options JSON data for
6
+ # searchable selects.
7
+ #
8
+ # @param scope [ActiveRecord::Relation, Proc] Either a
9
+ # collection of records to create options for or a proc
10
+ # returning such a collection. Procs are evaluated in the
11
+ # context of the collection action defined by this
12
+ # method. Procs can optionally take a single `params` argument
13
+ # containing data defined under the `params` key of the
14
+ # input's `ajax` option. Required.
15
+ #
16
+ # @param text_attribute [Symbol] Name of attribute to use as
17
+ # display name and to filter by search term.
18
+ #
19
+ # @param display_text [Proc] Takes the record as
20
+ # parameter. Required if `text_attribute` is not present.
21
+ #
22
+ # @param filter [Proc] Takes the search term and an Active
23
+ # Record scope as parameters and needs to return a scope of
24
+ # filtered records. Required if `text_attribute` is not
25
+ # present.
26
+ #
27
+ # @param name [Symbol] Optional collection name if helper is
28
+ # used multiple times within one resource.
29
+ #
30
+ # @param additional_payload [Proc]
31
+ # Adds additional attributes to the results array
32
+ # @example
33
+ #
34
+ # ActiveAdmin.register Tag do
35
+ # searchable_select_options(
36
+ # scope: Color,
37
+ # text_attributes: :title,
38
+ # additional_payload: lambda { |record| { color: record.color } }
39
+ # )
40
+ # end
41
+ # @json
42
+ # {
43
+ # "results": [{ "id": "1", "text": "Red", "color": "#FFF" }],
44
+ # "pagination": { "more": "false" }
45
+ # }
46
+ def searchable_select_options(name: :all, **options)
47
+ option_collection = OptionCollection.new(name, options)
48
+ config.searchable_select_option_collections[name] = option_collection
49
+
50
+ collection_action(option_collection.collection_action_name) do
51
+ render(json: option_collection.as_json(self, params))
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,10 @@
1
+ module ActiveAdmin
2
+ module SearchableSelect
3
+ # @api private
4
+ module ResourceExtension
5
+ def searchable_select_option_collections
6
+ @searchable_select_option_collections ||= {}
7
+ end
8
+ end
9
+ end
10
+ end