activeadmin-tom_select 4.1.1 → 4.2.0.beta1
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +10 -7
- data/.gitignore +1 -0
- data/Appraisals +2 -2
- data/CHANGELOG.md +12 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +137 -104
- data/README.md +1 -1
- data/docs/activeadmin-4-asset-setup.md +171 -0
- data/docs/activeadmin-tailwind-4.md +125 -0
- data/docs/guide-update-your-app.md +89 -356
- data/docs/setup-activeadmin-app.md +69 -492
- data/docs/setup-activeadmin-gem.md +83 -449
- data/gemfiles/rails_7.x_active_admin_4.x.gemfile +2 -1
- data/gemfiles/rails_7.x_active_admin_4.x.gemfile.lock +158 -116
- data/gemfiles/rails_8.x_active_admin_4.x.gemfile +2 -1
- data/gemfiles/rails_8.x_active_admin_4.x.gemfile.lock +148 -104
- data/lib/activeadmin/tom_select/option_collection.rb +4 -6
- data/lib/activeadmin/tom_select/select_input_extension.rb +42 -20
- data/lib/activeadmin/tom_select/version.rb +1 -1
- data/npm-package/package.json +1 -1
- data/sonar-project.properties +11 -11
- data/spec/features/ajax_false_input_spec.rb +74 -0
- data/spec/features/end_to_end_spec.rb +33 -20
- data/spec/features/input_errors_spec.rb +1 -3
- data/spec/features/options_dsl_spec.rb +6 -6
- data/spec/internal/Gemfile +1 -0
- data/spec/internal/Gemfile.lock +152 -107
- data/spec/internal/app/admin/option_values.rb +6 -6
- data/spec/internal/app/admin/posts.rb +4 -4
- data/spec/internal/app/admin/test_ajax_false.rb +18 -0
- data/spec/internal/app/admin/variants.rb +2 -2
- data/spec/internal/app/assets/stylesheets/active_admin.tailwind.css +8 -5
- data/spec/internal/app/models/option_value.rb +8 -0
- data/spec/internal/bin/tailwindcss +27 -0
- data/spec/internal/lib/tasks/active_admin.rake +9 -4
- data/spec/internal/package-lock.json +15 -1371
- data/spec/internal/package.json +1 -2
- data/{docs/tailwind-4/tailwind-active_admin.config.js → spec/internal/tailwind-active_admin.config.mjs} +9 -4
- data/spec/internal/yarn.lock +128 -728
- metadata +9 -23
- data/docs/activeadmin-4-detailed-reference.md +0 -932
- data/docs/activeadmin-4-gem-migration-guide.md +0 -313
- data/docs/combustion.md +0 -213
- data/docs/fail.png +0 -0
- data/docs/normal.png +0 -0
- data/docs/propshaft-readme.md +0 -320
- data/docs/propshaft-upgrade.md +0 -484
- data/docs/tailwind/blog-page.md +0 -341
- data/docs/tailwind/upgrade-guide-enhanced.md +0 -438
- data/docs/tailwind/upgrade-guide.md +0 -416
- data/docs/tailwind-4/active_admin.rake +0 -38
- data/docs/tailwind-4/active_admin.tailwind.css +0 -415
- data/docs/test-app-change.md +0 -154
- data/docs/test-environment-fixes.md +0 -58
- data/docs/update-tom-select.md +0 -348
|
@@ -1,52 +1,26 @@
|
|
|
1
|
-
# Setting Up Standalone ActiveAdmin 4
|
|
1
|
+
# Setting Up a Standalone ActiveAdmin 4 App (Tailwind v4)
|
|
2
2
|
|
|
3
|
-
This guide
|
|
3
|
+
This guide creates a new Rails app with ActiveAdmin 4.0.0.beta19, Tailwind CSS v4, and optional AA extension gems.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 1. Create Rails App
|
|
6
6
|
|
|
7
|
-
### For esbuild/webpack users (Modern Setup)
|
|
8
7
|
```bash
|
|
9
|
-
# Install via NPM
|
|
10
|
-
npm install @rocket-sensei/activeadmin_trumbowyg
|
|
11
|
-
|
|
12
|
-
# Import in your JavaScript
|
|
13
|
-
# app/javascript/application.js or app/javascript/active_admin.js
|
|
14
|
-
import '@rocket-sensei/activeadmin_trumbowyg'
|
|
15
|
-
|
|
16
|
-
# No generator needed! The package auto-initializes
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### For Importmap/Propshaft users (Rails Default)
|
|
20
|
-
```bash
|
|
21
|
-
# Add gem to Gemfile
|
|
22
|
-
gem 'activeadmin_trumbowyg'
|
|
23
|
-
|
|
24
|
-
# Run generator
|
|
25
|
-
rails generate activeadmin_trumbowyg:install
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## 1. Create Rails Application
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
# For Rails 8 (Propshaft included by default):
|
|
32
8
|
rails new my_admin_app --css=tailwind --javascript=esbuild
|
|
33
9
|
cd my_admin_app
|
|
34
|
-
|
|
35
|
-
# For Rails 7, we'll add Propshaft in the next step
|
|
36
10
|
```
|
|
37
11
|
|
|
38
|
-
## 2.
|
|
12
|
+
## 2. Gemfile
|
|
39
13
|
|
|
40
14
|
```ruby
|
|
41
|
-
#
|
|
42
|
-
gem
|
|
43
|
-
gem 'importmap-rails', '~> 2.0' # Required for ActiveAdmin 4
|
|
15
|
+
# ActiveAdmin 4 beta
|
|
16
|
+
gem "activeadmin", "4.0.0.beta19"
|
|
44
17
|
|
|
45
|
-
#
|
|
46
|
-
gem
|
|
18
|
+
# Required by ActiveAdmin 4
|
|
19
|
+
gem "importmap-rails", "~> 2.0"
|
|
20
|
+
gem "propshaft"
|
|
47
21
|
|
|
48
|
-
#
|
|
49
|
-
|
|
22
|
+
# Tailwind CLI (v4)
|
|
23
|
+
gem "tailwindcss-rails", "~> 4.4.0"
|
|
50
24
|
```
|
|
51
25
|
|
|
52
26
|
```bash
|
|
@@ -57,496 +31,99 @@ bundle install
|
|
|
57
31
|
|
|
58
32
|
```bash
|
|
59
33
|
rails generate active_admin:install
|
|
60
|
-
|
|
61
|
-
# This creates:
|
|
62
|
-
# - config/initializers/active_admin.rb
|
|
63
|
-
# - app/admin/ directory
|
|
64
|
-
# - db/migrate/xxx_create_active_admin_comments.rb
|
|
34
|
+
rails db:create db:migrate db:seed
|
|
65
35
|
```
|
|
66
36
|
|
|
67
|
-
## 4.
|
|
37
|
+
## 4. Install ActiveAdmin Assets
|
|
68
38
|
|
|
69
39
|
```bash
|
|
70
|
-
rails
|
|
71
|
-
rails db:migrate
|
|
72
|
-
rails db:seed # Creates default admin user if using Devise
|
|
40
|
+
rails generate active_admin:assets
|
|
73
41
|
```
|
|
74
42
|
|
|
75
|
-
|
|
43
|
+
This creates:
|
|
44
|
+
- `app/assets/stylesheets/active_admin.css`
|
|
45
|
+
- `tailwind-active_admin.config.js` (ESM)
|
|
76
46
|
|
|
77
|
-
|
|
78
|
-
# Install ActiveAdmin Tailwind plugin and other dependencies
|
|
79
|
-
npm install --save-dev @activeadmin/activeadmin@^3.3.0
|
|
47
|
+
Rename to `.mjs` for Tailwind v4:
|
|
80
48
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
# Install vendor packages via NPM
|
|
85
|
-
# For activeadmin_trumbowyg gem users with esbuild/webpack:
|
|
86
|
-
npm install @rocket-sensei/activeadmin_trumbowyg
|
|
87
|
-
|
|
88
|
-
# Or install Trumbowyg directly:
|
|
89
|
-
# npm install trumbowyg
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## 6. Configure Tailwind (CRITICAL!)
|
|
93
|
-
|
|
94
|
-
```javascript
|
|
95
|
-
// tailwind.config.js - Convert to ESM format
|
|
96
|
-
// Rename to tailwind.config.mjs
|
|
97
|
-
|
|
98
|
-
import activeAdminPlugin from '@activeadmin/activeadmin/plugin'
|
|
99
|
-
import { execSync } from 'node:child_process'
|
|
100
|
-
|
|
101
|
-
let activeAdminPath = null
|
|
102
|
-
try {
|
|
103
|
-
activeAdminPath = execSync('bundle show activeadmin', { encoding: 'utf8' }).trim()
|
|
104
|
-
} catch (e) {
|
|
105
|
-
console.warn('Could not find activeadmin gem path')
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export default {
|
|
109
|
-
content: [
|
|
110
|
-
'./public/*.html',
|
|
111
|
-
'./app/helpers/**/*.rb',
|
|
112
|
-
'./app/javascript/**/*.js',
|
|
113
|
-
'./app/views/**/*.{erb,haml,html,slim}',
|
|
114
|
-
'./app/admin/**/*.rb',
|
|
115
|
-
// Include ActiveAdmin gem views
|
|
116
|
-
...(activeAdminPath ? [
|
|
117
|
-
`${activeAdminPath}/app/views/**/*.{arb,erb,html,rb}`,
|
|
118
|
-
`${activeAdminPath}/vendor/javascript/flowbite.js`,
|
|
119
|
-
`${activeAdminPath}/plugin.js`,
|
|
120
|
-
] : [])
|
|
121
|
-
],
|
|
122
|
-
darkMode: 'selector',
|
|
123
|
-
theme: {
|
|
124
|
-
extend: {
|
|
125
|
-
fontFamily: {
|
|
126
|
-
sans: ['Inter var', 'sans-serif'],
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
plugins: [
|
|
131
|
-
activeAdminPlugin,
|
|
132
|
-
// Other plugins like forms, typography
|
|
133
|
-
],
|
|
134
|
-
// CRITICAL: Add safelist for ActiveAdmin dynamic classes
|
|
135
|
-
safelist: [
|
|
136
|
-
// Grid and layout
|
|
137
|
-
'grid', 'gap-4', 'gap-6', 'lg:grid-cols-3', 'md:grid-cols-2',
|
|
138
|
-
'col-span-2', 'col-span-3', 'lg:col-span-2', 'lg:col-span-1',
|
|
139
|
-
// Flexbox
|
|
140
|
-
'flex', 'flex-col', 'flex-row', 'flex-wrap', 'items-center',
|
|
141
|
-
'justify-between', 'justify-center', 'items-start', 'items-end',
|
|
142
|
-
// Spacing
|
|
143
|
-
'p-4', 'p-6', 'px-4', 'px-6', 'py-2', 'py-4', 'm-0', 'mx-auto',
|
|
144
|
-
'mt-4', 'mb-4', 'ml-auto', 'mr-auto', 'space-y-4', 'space-x-4',
|
|
145
|
-
// Display
|
|
146
|
-
'block', 'inline-block', 'hidden', 'lg:hidden', 'lg:block', 'lg:flex',
|
|
147
|
-
// Width/Height
|
|
148
|
-
'w-full', 'w-auto', 'w-64', 'h-full', 'min-h-screen', 'max-w-7xl',
|
|
149
|
-
// Typography
|
|
150
|
-
'text-sm', 'text-base', 'text-lg', 'text-xl', 'font-medium', 'font-semibold',
|
|
151
|
-
// Colors
|
|
152
|
-
'bg-white', 'bg-gray-50', 'bg-gray-100', 'text-gray-900', 'text-gray-600',
|
|
153
|
-
'dark:bg-gray-800', 'dark:bg-gray-900', 'dark:text-white', 'dark:text-gray-300',
|
|
154
|
-
// Borders
|
|
155
|
-
'border', 'border-gray-200', 'dark:border-gray-700', 'rounded-lg', 'rounded-md',
|
|
156
|
-
// Forms
|
|
157
|
-
'form-input', 'form-select', 'form-checkbox',
|
|
158
|
-
// Position & Z-index
|
|
159
|
-
'relative', 'absolute', 'fixed', 'sticky', 'top-0', 'left-0', 'right-0',
|
|
160
|
-
'z-10', 'z-20', 'z-30', 'z-40', 'z-50',
|
|
161
|
-
// Shadows
|
|
162
|
-
'shadow', 'shadow-md', 'shadow-lg',
|
|
163
|
-
// Tables
|
|
164
|
-
'table-auto', 'border-collapse',
|
|
165
|
-
// Buttons
|
|
166
|
-
'inline-flex', 'cursor-pointer'
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## 7. Update Package.json Scripts
|
|
172
|
-
|
|
173
|
-
```json
|
|
174
|
-
{
|
|
175
|
-
"name": "my-admin-app",
|
|
176
|
-
"scripts": {
|
|
177
|
-
"build:css": "tailwindcss -c tailwind.config.mjs -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify",
|
|
178
|
-
"build:js": "esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets --inject:./inject-jquery.js",
|
|
179
|
-
"build": "npm run build:css && npm run build:js",
|
|
180
|
-
"watch:css": "npm run build:css -- --watch",
|
|
181
|
-
"watch:js": "npm run build:js -- --watch"
|
|
182
|
-
}
|
|
183
|
-
}
|
|
49
|
+
```bash
|
|
50
|
+
mv tailwind-active_admin.config.js tailwind-active_admin.config.mjs
|
|
184
51
|
```
|
|
185
52
|
|
|
186
|
-
##
|
|
187
|
-
|
|
188
|
-
```javascript
|
|
189
|
-
// inject-jquery.js (in project root)
|
|
190
|
-
export { default as $ } from 'jquery/dist/jquery.js'
|
|
191
|
-
export { default as jQuery } from 'jquery/dist/jquery.js'
|
|
192
|
-
```
|
|
53
|
+
## 5. Tailwind Input (ActiveAdmin)
|
|
193
54
|
|
|
194
|
-
|
|
55
|
+
Create or update the Tailwind input file:
|
|
195
56
|
|
|
196
57
|
```css
|
|
197
|
-
/* app/assets/stylesheets/
|
|
198
|
-
@
|
|
199
|
-
@tailwind
|
|
200
|
-
@tailwind utilities;
|
|
201
|
-
|
|
202
|
-
/* ActiveAdmin custom styles */
|
|
203
|
-
@layer components {
|
|
204
|
-
/* Custom component styles */
|
|
205
|
-
.admin-button {
|
|
206
|
-
@apply px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/* Import vendor CSS if needed */
|
|
211
|
-
/* Note: @rocket-sensei/activeadmin_trumbowyg NPM package includes CSS automatically */
|
|
212
|
-
/* For manual Trumbowyg setup: @import 'trumbowyg/dist/ui/trumbowyg.css'; */
|
|
58
|
+
/* app/assets/stylesheets/active_admin.tailwind.css */
|
|
59
|
+
@import "tailwindcss";
|
|
60
|
+
@config "../../../tailwind-active_admin.config.mjs";
|
|
213
61
|
```
|
|
214
62
|
|
|
215
|
-
##
|
|
216
|
-
|
|
217
|
-
```javascript
|
|
218
|
-
// app/javascript/application.js
|
|
219
|
-
import "@hotwired/turbo-rails"
|
|
220
|
-
import "./controllers"
|
|
221
|
-
|
|
222
|
-
// If using jQuery and plugins
|
|
223
|
-
import $ from 'jquery'
|
|
224
|
-
window.$ = window.jQuery = $
|
|
225
|
-
|
|
226
|
-
// Import vendor libraries via NPM packages
|
|
227
|
-
// For activeadmin_trumbowyg gem users with esbuild/webpack:
|
|
228
|
-
// import '@rocket-sensei/activeadmin_trumbowyg'
|
|
229
|
-
|
|
230
|
-
// Or import Trumbowyg directly:
|
|
231
|
-
// import 'trumbowyg'
|
|
232
|
-
|
|
233
|
-
// Note: No generator needed when using esbuild/webpack with NPM packages
|
|
234
|
-
// The NPM package automatically handles initialization
|
|
235
|
-
|
|
236
|
-
// For manual plugin initialization if needed:
|
|
237
|
-
document.addEventListener('DOMContentLoaded', () => {
|
|
238
|
-
initializePlugins()
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
document.addEventListener('turbo:load', () => {
|
|
242
|
-
initializePlugins()
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
function initializePlugins() {
|
|
246
|
-
// Initialize your jQuery plugins if not auto-initialized
|
|
247
|
-
// $('.select2').select2()
|
|
248
|
-
// $('[data-trumbowyg]').trumbowyg() // Only if not using NPM package auto-init
|
|
249
|
-
}
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
## 11. Configure ActiveAdmin
|
|
253
|
-
|
|
254
|
-
```ruby
|
|
255
|
-
# config/initializers/active_admin.rb
|
|
256
|
-
ActiveAdmin.setup do |config|
|
|
257
|
-
config.site_title = "My Admin App"
|
|
258
|
-
|
|
259
|
-
# Authentication (if using Devise)
|
|
260
|
-
config.authentication_method = :authenticate_admin_user!
|
|
261
|
-
config.current_user_method = :current_admin_user
|
|
262
|
-
config.logout_link_path = :destroy_admin_user_session_path
|
|
263
|
-
|
|
264
|
-
# Or disable authentication for development
|
|
265
|
-
# config.authentication_method = false
|
|
266
|
-
# config.current_user_method = false
|
|
267
|
-
|
|
268
|
-
config.batch_actions = true
|
|
269
|
-
config.filter_attributes = [:encrypted_password, :password, :password_confirmation]
|
|
270
|
-
config.localize_format = :long
|
|
271
|
-
end
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
## 12. Create Sample Model and Admin Resource
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
# Generate a model
|
|
278
|
-
rails generate model Product name:string description:text price:decimal active:boolean
|
|
279
|
-
rails db:migrate
|
|
280
|
-
```
|
|
63
|
+
## 6. Build Tasks
|
|
281
64
|
|
|
282
65
|
```ruby
|
|
283
|
-
#
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
column :created_at
|
|
296
|
-
actions
|
|
66
|
+
# lib/tasks/active_admin.rake
|
|
67
|
+
namespace :active_admin do
|
|
68
|
+
desc "Build Active Admin Tailwind stylesheets"
|
|
69
|
+
task build: :environment do
|
|
70
|
+
command = [
|
|
71
|
+
Rails.root.join("bin/tailwindcss").to_s,
|
|
72
|
+
"-i", Rails.root.join("app/assets/stylesheets/active_admin.tailwind.css").to_s,
|
|
73
|
+
"-o", Rails.root.join("app/assets/builds/active_admin.css").to_s,
|
|
74
|
+
"-m"
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
system(*command, exception: true)
|
|
297
78
|
end
|
|
298
79
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
f.input :active
|
|
311
|
-
end
|
|
312
|
-
f.actions
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
show do
|
|
316
|
-
attributes_table do
|
|
317
|
-
row :name
|
|
318
|
-
row :description
|
|
319
|
-
row :price do |product|
|
|
320
|
-
number_to_currency product.price
|
|
321
|
-
end
|
|
322
|
-
row :active
|
|
323
|
-
row :created_at
|
|
324
|
-
row :updated_at
|
|
325
|
-
end
|
|
80
|
+
desc "Watch Active Admin Tailwind stylesheets"
|
|
81
|
+
task watch: :environment do
|
|
82
|
+
command = [
|
|
83
|
+
Rails.root.join("bin/tailwindcss").to_s,
|
|
84
|
+
"--watch",
|
|
85
|
+
"-i", Rails.root.join("app/assets/stylesheets/active_admin.tailwind.css").to_s,
|
|
86
|
+
"-o", Rails.root.join("app/assets/builds/active_admin.css").to_s,
|
|
87
|
+
"-m"
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
system(*command, exception: true)
|
|
326
91
|
end
|
|
327
92
|
end
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
## 13. Build Assets
|
|
331
|
-
|
|
332
|
-
```bash
|
|
333
|
-
npm run build
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
## 14. Start Rails Server
|
|
337
|
-
|
|
338
|
-
```bash
|
|
339
|
-
rails server
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
Visit http://localhost:3000/admin
|
|
343
|
-
|
|
344
|
-
Default credentials (if using Devise):
|
|
345
|
-
- Email: admin@example.com
|
|
346
|
-
- Password: password
|
|
347
93
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
### Asset Precompilation
|
|
351
|
-
|
|
352
|
-
```ruby
|
|
353
|
-
# config/environments/production.rb
|
|
354
|
-
config.assets.compile = false
|
|
355
|
-
config.assets.precompile += %w[ application.js application.css ]
|
|
94
|
+
Rake::Task["assets:precompile"].enhance(["active_admin:build"])
|
|
356
95
|
```
|
|
357
96
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
```bash
|
|
361
|
-
RAILS_ENV=production bundle exec rails assets:precompile
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
### Heroku Deployment
|
|
365
|
-
|
|
366
|
-
```json
|
|
367
|
-
// package.json
|
|
368
|
-
{
|
|
369
|
-
"scripts": {
|
|
370
|
-
"build": "npm run build:css && npm run build:js",
|
|
371
|
-
"build:css": "tailwindcss -c tailwind.config.mjs -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify",
|
|
372
|
-
"build:js": "esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets --minify"
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
Add buildpacks:
|
|
378
|
-
```bash
|
|
379
|
-
heroku buildpacks:add heroku/nodejs
|
|
380
|
-
heroku buildpacks:add heroku/ruby
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
## 16. Adding Vendor Packages (Example: Trumbowyg)
|
|
384
|
-
|
|
385
|
-
### Method 1: Using the NPM Package (Recommended for esbuild/webpack)
|
|
386
|
-
|
|
387
|
-
```bash
|
|
388
|
-
# Install the official NPM package
|
|
389
|
-
npm install @rocket-sensei/activeadmin_trumbowyg
|
|
390
|
-
```
|
|
97
|
+
## 7. JavaScript Entry
|
|
391
98
|
|
|
392
99
|
```javascript
|
|
393
|
-
// app/javascript/
|
|
394
|
-
import
|
|
395
|
-
|
|
396
|
-
// That's it! The package auto-initializes Trumbowyg on elements with data-provider="trumbowyg"
|
|
397
|
-
// No generator needed for esbuild/webpack setups
|
|
100
|
+
// app/javascript/active_admin.js
|
|
101
|
+
import "@activeadmin/activeadmin";
|
|
398
102
|
```
|
|
399
103
|
|
|
400
|
-
|
|
401
|
-
# app/admin/posts.rb
|
|
402
|
-
ActiveAdmin.register Post do
|
|
403
|
-
form do |f|
|
|
404
|
-
f.inputs do
|
|
405
|
-
f.input :title
|
|
406
|
-
f.input :body, as: :text, input_html: {
|
|
407
|
-
'data-provider': 'trumbowyg',
|
|
408
|
-
class: 'trumbowyg-editor'
|
|
409
|
-
}
|
|
410
|
-
end
|
|
411
|
-
f.actions
|
|
412
|
-
end
|
|
413
|
-
end
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
### Method 2: Using Trumbowyg Directly (Manual Setup)
|
|
104
|
+
## 8. Build Assets
|
|
417
105
|
|
|
418
106
|
```bash
|
|
419
|
-
|
|
107
|
+
bundle binstubs tailwindcss-ruby --force
|
|
108
|
+
npm install @activeadmin/activeadmin@^4.0.0-beta19
|
|
109
|
+
npm run build
|
|
420
110
|
```
|
|
421
111
|
|
|
422
|
-
|
|
423
|
-
// app/javascript/admin.js
|
|
424
|
-
import $ from 'jquery'
|
|
425
|
-
import 'trumbowyg'
|
|
426
|
-
|
|
427
|
-
window.$ = window.jQuery = $
|
|
428
|
-
|
|
429
|
-
function initTrumbowyg() {
|
|
430
|
-
$('[data-trumbowyg]').each(function() {
|
|
431
|
-
if (!$(this).hasClass('trumbowyg-active')) {
|
|
432
|
-
$(this).trumbowyg({
|
|
433
|
-
svgPath: '/assets/trumbowyg/icons.svg'
|
|
434
|
-
})
|
|
435
|
-
$(this).addClass('trumbowyg-active')
|
|
436
|
-
}
|
|
437
|
-
})
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
document.addEventListener('DOMContentLoaded', initTrumbowyg)
|
|
441
|
-
document.addEventListener('turbo:load', initTrumbowyg)
|
|
442
|
-
```
|
|
112
|
+
## 9. Start Server
|
|
443
113
|
|
|
444
|
-
Copy icons (only needed for manual setup):
|
|
445
114
|
```bash
|
|
446
|
-
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
## Common Issues & Solutions
|
|
450
|
-
|
|
451
|
-
### Issue: Unstyled Admin Interface
|
|
452
|
-
**Solution**:
|
|
453
|
-
1. Ensure Tailwind safelist is configured
|
|
454
|
-
2. Check that CSS file is > 100KB
|
|
455
|
-
3. Rebuild assets with `npm run build`
|
|
456
|
-
|
|
457
|
-
### Issue: JavaScript Not Loading
|
|
458
|
-
**Solution**:
|
|
459
|
-
1. Check esbuild configuration
|
|
460
|
-
2. Ensure importmap or esbuild is properly configured
|
|
461
|
-
3. Check browser console for errors
|
|
462
|
-
|
|
463
|
-
### Issue: Dark Mode Not Working
|
|
464
|
-
**Solution**:
|
|
465
|
-
1. Ensure `darkMode: 'selector'` in Tailwind config
|
|
466
|
-
2. ActiveAdmin plugin handles dark mode toggle
|
|
467
|
-
|
|
468
|
-
### Issue: Forms Not Styled
|
|
469
|
-
**Solution**:
|
|
470
|
-
1. Add form-related classes to safelist
|
|
471
|
-
2. Ensure ActiveAdmin plugin is loaded
|
|
472
|
-
|
|
473
|
-
## Testing Setup
|
|
474
|
-
|
|
475
|
-
```ruby
|
|
476
|
-
# Gemfile - test group
|
|
477
|
-
group :test do
|
|
478
|
-
gem 'rspec-rails'
|
|
479
|
-
gem 'capybara'
|
|
480
|
-
gem 'factory_bot_rails'
|
|
481
|
-
end
|
|
482
|
-
```
|
|
483
|
-
|
|
484
|
-
```ruby
|
|
485
|
-
# spec/features/admin_spec.rb
|
|
486
|
-
require 'rails_helper'
|
|
487
|
-
|
|
488
|
-
RSpec.describe 'Admin Interface', type: :feature do
|
|
489
|
-
it 'loads the dashboard' do
|
|
490
|
-
visit '/admin'
|
|
491
|
-
expect(page).to have_content('Dashboard')
|
|
492
|
-
end
|
|
493
|
-
end
|
|
115
|
+
rails server
|
|
494
116
|
```
|
|
495
117
|
|
|
496
|
-
|
|
118
|
+
Visit http://localhost:3000/admin
|
|
497
119
|
|
|
498
|
-
|
|
499
|
-
my_admin_app/
|
|
500
|
-
├── app/
|
|
501
|
-
│ ├── admin/ # ActiveAdmin resources
|
|
502
|
-
│ ├── assets/
|
|
503
|
-
│ │ ├── builds/ # Compiled assets
|
|
504
|
-
│ │ ├── config/
|
|
505
|
-
│ │ │ └── manifest.js
|
|
506
|
-
│ │ └── stylesheets/
|
|
507
|
-
│ │ └── application.tailwind.css
|
|
508
|
-
│ └── javascript/
|
|
509
|
-
│ ├── application.js
|
|
510
|
-
│ └── active_admin.js # Optional: ActiveAdmin-specific JS
|
|
511
|
-
├── config/
|
|
512
|
-
│ └── initializers/
|
|
513
|
-
│ └── active_admin.rb
|
|
514
|
-
├── node_modules/
|
|
515
|
-
│ └── @rocket-sensei/
|
|
516
|
-
│ └── activeadmin_trumbowyg/ # NPM package location
|
|
517
|
-
├── public/
|
|
518
|
-
│ └── assets/ # Static vendor assets
|
|
519
|
-
├── package.json
|
|
520
|
-
├── tailwind.config.mjs # ESM format!
|
|
521
|
-
└── inject-jquery.js # If using jQuery
|
|
522
|
-
```
|
|
120
|
+
## ActiveAdmin 4.0.0.beta19 Notes (from upgrade guide)
|
|
523
121
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
-
|
|
528
|
-
-
|
|
529
|
-
-
|
|
530
|
-
-
|
|
531
|
-
-
|
|
532
|
-
- **Auto-initialization**: Yes, handles Turbo events automatically
|
|
533
|
-
|
|
534
|
-
### Ruby Gem (activeadmin_trumbowyg)
|
|
535
|
-
- **For**: Importmap/Propshaft users
|
|
536
|
-
- **Installation**: Add to Gemfile
|
|
537
|
-
- **Generator**: Required (`rails g activeadmin_trumbowyg:install`)
|
|
538
|
-
- **JavaScript paths**: Uses `active_admin/` prefix
|
|
539
|
-
- **Asset handling**: Via Rails asset pipeline
|
|
540
|
-
|
|
541
|
-
## Success Checklist
|
|
542
|
-
|
|
543
|
-
✅ Rails app created with esbuild and Tailwind
|
|
544
|
-
✅ ActiveAdmin installed and configured
|
|
545
|
-
✅ Tailwind config with ActiveAdmin plugin and safelist
|
|
546
|
-
✅ Assets building correctly (CSS > 100KB)
|
|
547
|
-
✅ Admin interface fully styled
|
|
548
|
-
✅ Dark mode toggle working
|
|
549
|
-
✅ Forms properly styled
|
|
550
|
-
✅ No JavaScript console errors
|
|
551
|
-
✅ Vendor packages integrated (if using NPM: @rocket-sensei/activeadmin_trumbowyg)
|
|
552
|
-
✅ Trumbowyg editor rendering on forms with `data-provider="trumbowyg"`
|
|
122
|
+
- `_site_header.html.erb` container class changed from `sticky` to `fixed`.
|
|
123
|
+
- `active_admin.html.erb` adds the `pt-16` utility class.
|
|
124
|
+
- Tailwind v4 requires `@import "tailwindcss"` + `@config`.
|
|
125
|
+
- jQuery and jQuery UI removed; `columns` and `tabs` removed.
|
|
126
|
+
- Replace `default_main_content` with `render "show_default"`.
|
|
127
|
+
- Replace `as: :datepicker` with `as: :date_picker`.
|
|
128
|
+
- Replace `active_admin_comments` with `active_admin_comments_for(resource)`.
|
|
129
|
+
- Replace `attributes_table` with `attributes_table_for(resource)` in sidebars.
|