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.
- checksums.yaml +7 -0
- data/.actrc +20 -0
- data/.claude/commands/fix-tests.md +203 -0
- data/.github/workflows/ci.yml +174 -0
- data/.github/workflows/npm-publish.yml +50 -0
- data/.gitignore +35 -0
- data/.npmignore +58 -0
- data/.rspec +1 -0
- data/.rubocop.yml +75 -0
- data/.yardopts +2 -0
- data/AGENTS.md +39 -0
- data/Appraisals +9 -0
- data/CHANGELOG.md +64 -0
- data/CLAUDE.md +157 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +368 -0
- data/LICENSE.txt +25 -0
- data/README.md +483 -0
- data/Rakefile +4 -0
- data/activeadmin-tom_select.gemspec +43 -0
- data/bin/rspec +17 -0
- data/config/database.yml +16 -0
- data/docs/activeadmin-4-detailed-reference.md +932 -0
- data/docs/activeadmin-4-gem-migration-guide.md +313 -0
- data/docs/combustion.md +213 -0
- data/docs/fail.png +0 -0
- data/docs/guide-update-your-app.md +283 -0
- data/docs/normal.png +0 -0
- data/docs/propshaft-readme.md +320 -0
- data/docs/propshaft-upgrade.md +484 -0
- data/docs/setup-activeadmin-app.md +552 -0
- data/docs/setup-activeadmin-gem.md +535 -0
- data/docs/tailwind/blog-page.md +341 -0
- data/docs/tailwind/upgrade-guide-enhanced.md +438 -0
- data/docs/tailwind/upgrade-guide.md +416 -0
- data/docs/tailwind-4/active_admin.rake +38 -0
- data/docs/tailwind-4/active_admin.tailwind.css +415 -0
- data/docs/tailwind-4/tailwind-active_admin.config.js +18 -0
- data/docs/test-app-change.md +154 -0
- data/docs/test-environment-fixes.md +58 -0
- data/docs/update-tom-select.md +184 -0
- data/docs/upload-system.md +225 -0
- data/gemfiles/rails_7.x_active_admin_4.x.gemfile +10 -0
- data/gemfiles/rails_7.x_active_admin_4.x.gemfile.lock +377 -0
- data/gemfiles/rails_8.x_active_admin_4.x.gemfile +10 -0
- data/gemfiles/rails_8.x_active_admin_4.x.gemfile.lock +372 -0
- data/lefthook.yml +17 -0
- data/lib/activeadmin/inputs/filters/searchable_select_input.rb +19 -0
- data/lib/activeadmin/inputs/searchable_select_input.rb +16 -0
- data/lib/activeadmin/tom_select/engine.rb +17 -0
- data/lib/activeadmin/tom_select/option_collection.rb +128 -0
- data/lib/activeadmin/tom_select/resource_dsl_extension.rb +56 -0
- data/lib/activeadmin/tom_select/resource_extension.rb +10 -0
- data/lib/activeadmin/tom_select/select_input_extension.rb +168 -0
- data/lib/activeadmin/tom_select/version.rb +5 -0
- data/lib/activeadmin/tom_select.rb +20 -0
- data/lib/activeadmin-tom_select.rb +5 -0
- data/lib/generators/active_admin/tom_select/install/install_generator.rb +180 -0
- data/npm-package/package-lock.json +51 -0
- data/npm-package/package.json +43 -0
- data/npm-package/src/index.js +153 -0
- data/npm-package/src/tom-select-tailwind.css +392 -0
- data/sonar-project.properties +25 -0
- data/spec/features/ajax_params_spec.rb +31 -0
- data/spec/features/asset_pipeline_diagnostic_spec.rb +155 -0
- data/spec/features/end_to_end_spec.rb +273 -0
- data/spec/features/filter_input_spec.rb +144 -0
- data/spec/features/form_input_spec.rb +122 -0
- data/spec/features/inline_ajax_setting_spec.rb +26 -0
- data/spec/features/input_errors_spec.rb +76 -0
- data/spec/features/input_html_options_spec.rb +30 -0
- data/spec/features/options_dsl_spec.rb +230 -0
- data/spec/features/production_build_spec.rb +108 -0
- data/spec/internal/.node-version +1 -0
- data/spec/internal/Gemfile +43 -0
- data/spec/internal/Gemfile.lock +333 -0
- data/spec/internal/Procfile.dev +3 -0
- data/spec/internal/README.md +24 -0
- data/spec/internal/Rakefile +6 -0
- data/spec/internal/app/admin/categories.rb +26 -0
- data/spec/internal/app/admin/dashboard.rb +29 -0
- data/spec/internal/app/admin/option_types.rb +19 -0
- data/spec/internal/app/admin/option_values.rb +30 -0
- data/spec/internal/app/admin/posts.rb +27 -0
- data/spec/internal/app/admin/products.rb +22 -0
- data/spec/internal/app/admin/rgb_colors.rb +25 -0
- data/spec/internal/app/admin/tag_names.rb +21 -0
- data/spec/internal/app/admin/test_ajax_params_category.rb +10 -0
- data/spec/internal/app/admin/test_ajax_params_post.rb +20 -0
- data/spec/internal/app/admin/test_form_post_class.rb +7 -0
- data/spec/internal/app/admin/test_form_post_custom.rb +11 -0
- data/spec/internal/app/admin/test_form_post_resource.rb +11 -0
- data/spec/internal/app/admin/test_form_post_resource_custom.rb +12 -0
- data/spec/internal/app/admin/test_inline_ajax_post.rb +9 -0
- data/spec/internal/app/admin/test_input_html_post.rb +11 -0
- data/spec/internal/app/admin/test_posts_display_text.rb +9 -0
- data/spec/internal/app/admin/test_posts_filter.rb +9 -0
- data/spec/internal/app/admin/test_posts_named.rb +9 -0
- data/spec/internal/app/admin/test_posts_pagination.rb +9 -0
- data/spec/internal/app/admin/test_posts_payload_lambda.rb +11 -0
- data/spec/internal/app/admin/test_posts_payload_proc.rb +9 -0
- data/spec/internal/app/admin/test_posts_scope_lambda.rb +8 -0
- data/spec/internal/app/admin/test_posts_scope_params.rb +8 -0
- data/spec/internal/app/admin/test_posts_scope_user.rb +8 -0
- data/spec/internal/app/admin/test_posts_text_attr.rb +5 -0
- data/spec/internal/app/admin/users.rb +23 -0
- data/spec/internal/app/admin/variants.rb +31 -0
- data/spec/internal/app/assets/config/manifest.js +2 -0
- data/spec/internal/app/assets/images/.keep +0 -0
- data/spec/internal/app/assets/stylesheets/active_admin.tailwind.css +16 -0
- data/spec/internal/app/assets/stylesheets/application.tailwind.css +15 -0
- data/spec/internal/app/controllers/application_controller.rb +9 -0
- data/spec/internal/app/controllers/concerns/.keep +0 -0
- data/spec/internal/app/helpers/application_helper.rb +2 -0
- data/spec/internal/app/javascript/active_admin.js +19 -0
- data/spec/internal/app/javascript/application.js +2 -0
- data/spec/internal/app/jobs/application_job.rb +7 -0
- data/spec/internal/app/mailers/application_mailer.rb +4 -0
- data/spec/internal/app/models/admin_user.rb +9 -0
- data/spec/internal/app/models/application_record.rb +3 -0
- data/spec/internal/app/models/article.rb +12 -0
- data/spec/internal/app/models/category.rb +12 -0
- data/spec/internal/app/models/color.rb +9 -0
- data/spec/internal/app/models/concerns/.keep +0 -0
- data/spec/internal/app/models/internal/tag_name.rb +14 -0
- data/spec/internal/app/models/internal_tag_name.rb +11 -0
- data/spec/internal/app/models/option_type.rb +12 -0
- data/spec/internal/app/models/option_value.rb +4 -0
- data/spec/internal/app/models/post.rb +15 -0
- data/spec/internal/app/models/product.rb +12 -0
- data/spec/internal/app/models/rgb_color.rb +16 -0
- data/spec/internal/app/models/tag.rb +12 -0
- data/spec/internal/app/models/tagging.rb +12 -0
- data/spec/internal/app/models/user.rb +12 -0
- data/spec/internal/app/models/variant.rb +12 -0
- data/spec/internal/app/views/layouts/application.html.erb +28 -0
- data/spec/internal/app/views/layouts/mailer.html.erb +13 -0
- data/spec/internal/app/views/layouts/mailer.text.erb +1 -0
- data/spec/internal/app/views/pwa/manifest.json.erb +22 -0
- data/spec/internal/app/views/pwa/service-worker.js +26 -0
- data/spec/internal/bin/bundle +117 -0
- data/spec/internal/bin/dev +11 -0
- data/spec/internal/bin/rackup +27 -0
- data/spec/internal/bin/rails +4 -0
- data/spec/internal/bin/rake +4 -0
- data/spec/internal/bin/setup +37 -0
- data/spec/internal/config/application.rb +50 -0
- data/spec/internal/config/boot.rb +3 -0
- data/spec/internal/config/credentials.yml.enc +1 -0
- data/spec/internal/config/database.yml +32 -0
- data/spec/internal/config/environment.rb +5 -0
- data/spec/internal/config/environments/development.rb +63 -0
- data/spec/internal/config/environments/production.rb +86 -0
- data/spec/internal/config/environments/test.rb +50 -0
- data/spec/internal/config/initializers/active_admin.rb +54 -0
- data/spec/internal/config/initializers/assets.rb +8 -0
- data/spec/internal/config/initializers/content_security_policy.rb +25 -0
- data/spec/internal/config/initializers/devise.rb +315 -0
- data/spec/internal/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/internal/config/initializers/inflections.rb +16 -0
- data/spec/internal/config/initializers/searchable_select.rb +6 -0
- data/spec/internal/config/locales/devise.en.yml +65 -0
- data/spec/internal/config/locales/en.yml +31 -0
- data/spec/internal/config/master.key +1 -0
- data/spec/internal/config/puma.rb +38 -0
- data/spec/internal/config/routes.rb +17 -0
- data/spec/internal/config.ru +6 -0
- data/spec/internal/db/schema.rb +174 -0
- data/spec/internal/db/seeds.rb +167 -0
- data/spec/internal/esbuild.config.js +34 -0
- data/spec/internal/lib/tasks/.keep +0 -0
- data/spec/internal/lib/tasks/active_admin.rake +55 -0
- data/spec/internal/log/.keep +0 -0
- data/spec/internal/package-lock.json +1954 -0
- data/spec/internal/package.json +21 -0
- data/spec/internal/public/400.html +114 -0
- data/spec/internal/public/404.html +114 -0
- data/spec/internal/public/406-unsupported-browser.html +114 -0
- data/spec/internal/public/422.html +114 -0
- data/spec/internal/public/500.html +114 -0
- data/spec/internal/public/icon.png +0 -0
- data/spec/internal/public/icon.svg +3 -0
- data/spec/internal/public/robots.txt +1 -0
- data/spec/internal/script/.keep +0 -0
- data/spec/internal/storage/.keep +0 -0
- data/spec/internal/tailwind.config.js +23 -0
- data/spec/internal/vendor/.keep +0 -0
- data/spec/internal/yarn.lock +824 -0
- data/spec/rails_helper.rb +62 -0
- data/spec/spec_helper.rb +138 -0
- data/spec/support/active_admin_helpers.rb +17 -0
- data/spec/support/capybara.rb +8 -0
- data/spec/support/models.rb +11 -0
- data/spec/support/pluck_polyfill.rb +12 -0
- data/spec/support/reset_settings.rb +5 -0
- metadata +497 -0
@@ -0,0 +1,174 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema[8.0].define(version: 0) do
|
14
|
+
create_table 'active_admin_comments', force: :cascade do |t|
|
15
|
+
t.string 'namespace'
|
16
|
+
t.text 'body'
|
17
|
+
t.string 'resource_type'
|
18
|
+
t.integer 'resource_id'
|
19
|
+
t.string 'author_type'
|
20
|
+
t.integer 'author_id'
|
21
|
+
t.datetime 'created_at', null: false
|
22
|
+
t.datetime 'updated_at', null: false
|
23
|
+
t.index %w[author_type author_id], name: 'index_active_admin_comments_on_author'
|
24
|
+
t.index ['namespace'], name: 'index_active_admin_comments_on_namespace'
|
25
|
+
t.index %w[resource_type resource_id], name: 'index_active_admin_comments_on_resource'
|
26
|
+
end
|
27
|
+
|
28
|
+
create_table 'admin_users', force: :cascade do |t|
|
29
|
+
t.string 'email', default: '', null: false
|
30
|
+
t.string 'encrypted_password', default: '', null: false
|
31
|
+
t.string 'reset_password_token'
|
32
|
+
t.datetime 'reset_password_sent_at'
|
33
|
+
t.datetime 'remember_created_at'
|
34
|
+
t.datetime 'created_at', null: false
|
35
|
+
t.datetime 'updated_at', null: false
|
36
|
+
t.index ['email'], name: 'index_admin_users_on_email', unique: true
|
37
|
+
t.index ['reset_password_token'], name: 'index_admin_users_on_reset_password_token',
|
38
|
+
unique: true
|
39
|
+
end
|
40
|
+
|
41
|
+
create_table 'articles', force: :cascade do |t|
|
42
|
+
t.string 'title'
|
43
|
+
t.text 'body'
|
44
|
+
t.integer 'category_id'
|
45
|
+
t.datetime 'created_at', null: false
|
46
|
+
t.datetime 'updated_at', null: false
|
47
|
+
t.index ['category_id'], name: 'index_articles_on_category_id'
|
48
|
+
end
|
49
|
+
|
50
|
+
create_table 'categories', force: :cascade do |t|
|
51
|
+
t.string 'name'
|
52
|
+
t.text 'description'
|
53
|
+
t.integer 'created_by_id'
|
54
|
+
t.datetime 'created_at', null: false
|
55
|
+
t.datetime 'updated_at', null: false
|
56
|
+
t.index ['created_by_id'], name: 'index_categories_on_created_by_id'
|
57
|
+
end
|
58
|
+
|
59
|
+
create_table 'colors', force: :cascade do |t|
|
60
|
+
t.string 'name'
|
61
|
+
t.string 'hex'
|
62
|
+
t.datetime 'created_at', null: false
|
63
|
+
t.datetime 'updated_at', null: false
|
64
|
+
end
|
65
|
+
|
66
|
+
create_table 'internal_tag_names', force: :cascade do |t|
|
67
|
+
t.string 'name'
|
68
|
+
t.datetime 'created_at', null: false
|
69
|
+
t.datetime 'updated_at', null: false
|
70
|
+
end
|
71
|
+
|
72
|
+
create_table 'option_types', force: :cascade do |t|
|
73
|
+
t.string 'name'
|
74
|
+
t.integer 'position'
|
75
|
+
t.datetime 'created_at', null: false
|
76
|
+
t.datetime 'updated_at', null: false
|
77
|
+
end
|
78
|
+
|
79
|
+
create_table 'option_values', force: :cascade do |t|
|
80
|
+
t.string 'name'
|
81
|
+
t.integer 'option_type_id'
|
82
|
+
t.datetime 'created_at', null: false
|
83
|
+
t.datetime 'updated_at', null: false
|
84
|
+
t.index ['option_type_id'], name: 'index_option_values_on_option_type_id'
|
85
|
+
end
|
86
|
+
|
87
|
+
create_table 'posts', force: :cascade do |t|
|
88
|
+
t.string 'title'
|
89
|
+
t.text 'body'
|
90
|
+
t.integer 'category_id'
|
91
|
+
t.integer 'created_by_id'
|
92
|
+
t.integer 'user_id'
|
93
|
+
t.integer 'color_id'
|
94
|
+
t.boolean 'published', default: false
|
95
|
+
t.integer 'position'
|
96
|
+
t.datetime 'created_at', null: false
|
97
|
+
t.datetime 'updated_at', null: false
|
98
|
+
t.index ['category_id'], name: 'index_posts_on_category_id'
|
99
|
+
t.index ['color_id'], name: 'index_posts_on_color_id'
|
100
|
+
t.index ['created_by_id'], name: 'index_posts_on_created_by_id'
|
101
|
+
t.index ['user_id'], name: 'index_posts_on_user_id'
|
102
|
+
end
|
103
|
+
|
104
|
+
create_table 'posts_tags', id: false, force: :cascade do |t|
|
105
|
+
t.integer 'post_id', null: false
|
106
|
+
t.integer 'tag_id', null: false
|
107
|
+
t.index ['post_id'], name: 'index_posts_tags_on_post_id'
|
108
|
+
t.index ['tag_id'], name: 'index_posts_tags_on_tag_id'
|
109
|
+
end
|
110
|
+
|
111
|
+
create_table 'products', force: :cascade do |t|
|
112
|
+
t.string 'name'
|
113
|
+
t.integer 'option_type_id'
|
114
|
+
t.datetime 'created_at', null: false
|
115
|
+
t.datetime 'updated_at', null: false
|
116
|
+
t.index ['option_type_id'], name: 'index_products_on_option_type_id'
|
117
|
+
end
|
118
|
+
|
119
|
+
create_table 'rgb_colors', force: :cascade do |t|
|
120
|
+
t.string 'name'
|
121
|
+
t.string 'code'
|
122
|
+
t.text 'description'
|
123
|
+
t.datetime 'created_at', null: false
|
124
|
+
t.datetime 'updated_at', null: false
|
125
|
+
end
|
126
|
+
|
127
|
+
create_table 'taggings', force: :cascade do |t|
|
128
|
+
t.integer 'tag_id'
|
129
|
+
t.string 'taggable_type'
|
130
|
+
t.integer 'taggable_id'
|
131
|
+
t.string 'tagger_type'
|
132
|
+
t.integer 'tagger_id'
|
133
|
+
t.string 'context', limit: 128
|
134
|
+
t.datetime 'created_at', null: false
|
135
|
+
t.datetime 'updated_at', null: false
|
136
|
+
t.index ['context'], name: 'index_taggings_on_context'
|
137
|
+
t.index %w[tag_id taggable_id taggable_type context tagger_id tagger_type],
|
138
|
+
name: 'taggings_idx', unique: true
|
139
|
+
t.index ['tag_id'], name: 'index_taggings_on_tag_id'
|
140
|
+
t.index %w[taggable_id taggable_type context], name: 'taggings_taggable_context_idx'
|
141
|
+
t.index %w[taggable_id taggable_type tagger_id context], name: 'taggings_idy'
|
142
|
+
t.index ['taggable_id'], name: 'index_taggings_on_taggable_id'
|
143
|
+
t.index %w[taggable_type taggable_id], name: 'index_taggings_on_taggable'
|
144
|
+
t.index ['taggable_type'], name: 'index_taggings_on_taggable_type'
|
145
|
+
t.index %w[tagger_id tagger_type], name: 'index_taggings_on_tagger'
|
146
|
+
t.index ['tagger_id'], name: 'index_taggings_on_tagger_id'
|
147
|
+
t.index %w[tagger_type tagger_id], name: 'index_taggings_on_tagger_type_and_tagger_id'
|
148
|
+
end
|
149
|
+
|
150
|
+
create_table 'tags', force: :cascade do |t|
|
151
|
+
t.string 'name'
|
152
|
+
t.integer 'taggings_count', default: 0
|
153
|
+
t.datetime 'created_at', null: false
|
154
|
+
t.datetime 'updated_at', null: false
|
155
|
+
t.index ['name'], name: 'index_tags_on_name', unique: true
|
156
|
+
end
|
157
|
+
|
158
|
+
create_table 'users', force: :cascade do |t|
|
159
|
+
t.string 'name'
|
160
|
+
t.string 'email'
|
161
|
+
t.datetime 'created_at', null: false
|
162
|
+
t.datetime 'updated_at', null: false
|
163
|
+
end
|
164
|
+
|
165
|
+
create_table 'variants', force: :cascade do |t|
|
166
|
+
t.integer 'product_id'
|
167
|
+
t.integer 'option_value_id'
|
168
|
+
t.decimal 'price'
|
169
|
+
t.datetime 'created_at', null: false
|
170
|
+
t.datetime 'updated_at', null: false
|
171
|
+
t.index ['option_value_id'], name: 'index_variants_on_option_value_id'
|
172
|
+
t.index ['product_id'], name: 'index_variants_on_product_id'
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# This file should ensure the existence of records required to run the application in every
|
2
|
+
# environment (production, development, test). The code here should be idempotent so that it
|
3
|
+
# can be executed at any point in every environment. The data can then be loaded with the
|
4
|
+
# bin/rails db:seed command (or created alongside the database with db:setup).
|
5
|
+
|
6
|
+
# Create admin user for ActiveAdmin
|
7
|
+
AdminUser.find_or_create_by(email: 'admin@example.com') do |admin|
|
8
|
+
admin.password = 'password'
|
9
|
+
admin.password_confirmation = 'password'
|
10
|
+
end
|
11
|
+
|
12
|
+
# Create sample users
|
13
|
+
users = []
|
14
|
+
10.times do |i|
|
15
|
+
users << User.find_or_create_by(name: "User #{i + 1}") do |user|
|
16
|
+
user.email = "user#{i + 1}@example.com"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Create sample categories with created_by association
|
21
|
+
categories = []
|
22
|
+
5.times do |i|
|
23
|
+
categories << Category.find_or_create_by(name: "Category #{i + 1}") do |category|
|
24
|
+
category.description = "Description for category #{i + 1}"
|
25
|
+
category.created_by = users.sample
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Create sample posts with published status
|
30
|
+
20.times do |i|
|
31
|
+
Post.find_or_create_by(title: "Post #{i + 1}") do |post|
|
32
|
+
post.body = "Body content for post #{i + 1}"
|
33
|
+
post.category = categories.sample
|
34
|
+
post.user = users.sample
|
35
|
+
post.published = [true, false].sample
|
36
|
+
post.position = i
|
37
|
+
# We'll set color_id after colors are created
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Create RGB colors
|
42
|
+
rgb_colors_data = [
|
43
|
+
{ code: '#FF0000', description: 'Red' },
|
44
|
+
{ code: '#00FF00', description: 'Green' },
|
45
|
+
{ code: '#0000FF', description: 'Blue' },
|
46
|
+
{ code: '#FFFF00', description: 'Yellow' },
|
47
|
+
{ code: '#FF00FF', description: 'Magenta' },
|
48
|
+
{ code: '#00FFFF', description: 'Cyan' },
|
49
|
+
{ code: '#000000', description: 'Black' },
|
50
|
+
{ code: '#FFFFFF', description: 'White' }
|
51
|
+
]
|
52
|
+
|
53
|
+
rgb_colors = rgb_colors_data.map do |color|
|
54
|
+
RgbColor.find_or_create_by(code: color[:code]) do |rgb|
|
55
|
+
rgb.description = color[:description]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Create internal tag names
|
60
|
+
10.times do |i|
|
61
|
+
InternalTagName.find_or_create_by(name: "Internal Tag #{i + 1}") do |tag|
|
62
|
+
tag.description = "Description for internal tag #{i + 1}"
|
63
|
+
tag.color_id = rgb_colors.sample.id
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Create option types and values
|
68
|
+
option_types = []
|
69
|
+
3.times do |i|
|
70
|
+
option_type = OptionType.find_or_create_by(name: "Option Type #{i + 1}")
|
71
|
+
option_types << option_type
|
72
|
+
|
73
|
+
5.times do |j|
|
74
|
+
OptionValue.find_or_create_by(
|
75
|
+
value: "Value #{j + 1} for #{option_type.name}",
|
76
|
+
option_type_id: option_type.id
|
77
|
+
)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# Create products and variants
|
82
|
+
10.times do |i|
|
83
|
+
product = Product.find_or_create_by(name: "Product #{i + 1}") do |p|
|
84
|
+
p.option_type = option_types.sample
|
85
|
+
end
|
86
|
+
|
87
|
+
3.times do |j|
|
88
|
+
option_value = product.option_type&.option_values&.sample
|
89
|
+
option_value_id = option_value&.id || OptionValue.first&.id
|
90
|
+
|
91
|
+
Variant.find_or_create_by(
|
92
|
+
product_id: product.id,
|
93
|
+
option_value_id: option_value_id
|
94
|
+
) do |variant|
|
95
|
+
variant.price = (10 + j) * 100
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Create Colors (different from RGB colors)
|
101
|
+
colors_data = [
|
102
|
+
{ name: 'Red', hex: '#FF0000' },
|
103
|
+
{ name: 'Green', hex: '#00FF00' },
|
104
|
+
{ name: 'Blue', hex: '#0000FF' },
|
105
|
+
{ name: 'Orange', hex: '#FFA500' },
|
106
|
+
{ name: 'Purple', hex: '#800080' }
|
107
|
+
]
|
108
|
+
|
109
|
+
colors = colors_data.map do |color_attrs|
|
110
|
+
Color.find_or_create_by(name: color_attrs[:name]) do |color|
|
111
|
+
color.hex = color_attrs[:hex]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Update posts with colors
|
116
|
+
Post.all.each do |post|
|
117
|
+
post.update(color: colors.sample) if post.color_id.nil?
|
118
|
+
end
|
119
|
+
|
120
|
+
# Create Tags
|
121
|
+
tags_data = [
|
122
|
+
{ name: 'Ruby' },
|
123
|
+
{ name: 'Rails' },
|
124
|
+
{ name: 'JavaScript' },
|
125
|
+
{ name: 'CSS' },
|
126
|
+
{ name: 'HTML' },
|
127
|
+
{ name: 'ActiveAdmin' },
|
128
|
+
{ name: 'Testing' }
|
129
|
+
]
|
130
|
+
|
131
|
+
tags = tags_data.map do |tag_attrs|
|
132
|
+
Tag.find_or_create_by(name: tag_attrs[:name])
|
133
|
+
end
|
134
|
+
|
135
|
+
# Create some taggings (many-to-many between posts and tags)
|
136
|
+
Post.all.sample(10).each do |post|
|
137
|
+
tags.sample(rand(1..3)).each do |tag|
|
138
|
+
Tagging.find_or_create_by(post_id: post.id, tag_id: tag.id)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Create Articles
|
143
|
+
5.times do |i|
|
144
|
+
Article.find_or_create_by(title: "Article #{i + 1}") do |article|
|
145
|
+
article.body = "Body content for article #{i + 1}"
|
146
|
+
article.category = categories.sample
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
puts '=' * 50
|
151
|
+
puts 'Seed data created successfully!'
|
152
|
+
puts '=' * 50
|
153
|
+
puts "AdminUsers: #{AdminUser.count}"
|
154
|
+
puts "Users: #{User.count}"
|
155
|
+
puts "Categories: #{Category.count}"
|
156
|
+
puts "Posts: #{Post.count}"
|
157
|
+
puts "Articles: #{Article.count}"
|
158
|
+
puts "RgbColors: #{RgbColor.count}"
|
159
|
+
puts "Colors: #{Color.count}"
|
160
|
+
puts "InternalTagNames: #{InternalTagName.count}"
|
161
|
+
puts "OptionTypes: #{OptionType.count}"
|
162
|
+
puts "OptionValues: #{OptionValue.count}"
|
163
|
+
puts "Products: #{Product.count}"
|
164
|
+
puts "Variants: #{Variant.count}"
|
165
|
+
puts "Tags: #{Tag.count}"
|
166
|
+
puts "Taggings: #{Tagging.count}"
|
167
|
+
puts '=' * 50
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
const esbuild = require('esbuild');
|
3
|
+
const path = require('path');
|
4
|
+
|
5
|
+
// Configuration for esbuild with proper module resolution
|
6
|
+
const config = {
|
7
|
+
entryPoints: ['app/javascript/active_admin.js'],
|
8
|
+
bundle: true,
|
9
|
+
sourcemap: true,
|
10
|
+
format: 'iife',
|
11
|
+
outdir: 'app/assets/builds',
|
12
|
+
publicPath: '/assets',
|
13
|
+
// Add node paths for module resolution
|
14
|
+
nodePaths: [
|
15
|
+
path.join(__dirname, 'node_modules'),
|
16
|
+
path.join(__dirname, '../../node_modules')
|
17
|
+
]
|
18
|
+
};
|
19
|
+
|
20
|
+
// Check if we're in watch mode
|
21
|
+
const watchMode = process.argv.includes('--watch');
|
22
|
+
|
23
|
+
if (watchMode) {
|
24
|
+
// Start the build with watch mode
|
25
|
+
esbuild.context(config).then(ctx => {
|
26
|
+
ctx.watch();
|
27
|
+
console.log('Watching for changes...');
|
28
|
+
});
|
29
|
+
} else {
|
30
|
+
// Single build
|
31
|
+
esbuild.build(config).then(() => {
|
32
|
+
console.log('Build completed');
|
33
|
+
}).catch(() => process.exit(1));
|
34
|
+
}
|
File without changes
|
@@ -0,0 +1,55 @@
|
|
1
|
+
namespace :active_admin do
|
2
|
+
desc 'Build Active Admin Tailwind stylesheets'
|
3
|
+
task :build do
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
root = File.expand_path('../../', __dir__)
|
7
|
+
|
8
|
+
# Ensure builds directory exists
|
9
|
+
FileUtils.mkdir_p(File.join(root, 'app/assets/builds'))
|
10
|
+
|
11
|
+
# Build with Tailwind CLI
|
12
|
+
command = [
|
13
|
+
'npx', 'tailwindcss',
|
14
|
+
'-i', File.join(root, 'app/assets/stylesheets/active_admin.tailwind.css'),
|
15
|
+
'-o', File.join(root, 'app/assets/builds/active_admin.css'),
|
16
|
+
'-c', File.join(root, 'tailwind.config.js'),
|
17
|
+
'-m'
|
18
|
+
]
|
19
|
+
|
20
|
+
system(*command, exception: true)
|
21
|
+
|
22
|
+
puts 'Built Active Admin CSS with Tailwind'
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Watch Active Admin Tailwind stylesheets'
|
26
|
+
task :watch do
|
27
|
+
root = File.expand_path('../../', __dir__)
|
28
|
+
|
29
|
+
# Watch for changes
|
30
|
+
command = [
|
31
|
+
'npx', 'tailwindcss',
|
32
|
+
'--watch',
|
33
|
+
'-i', File.join(root, 'app/assets/stylesheets/active_admin.tailwind.css'),
|
34
|
+
'-o', File.join(root, 'app/assets/builds/active_admin.css'),
|
35
|
+
'-c', File.join(root, 'tailwind.config.js'),
|
36
|
+
'-m'
|
37
|
+
]
|
38
|
+
|
39
|
+
system(*command)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Enhance existing rake tasks
|
44
|
+
if Rake::Task.task_defined?('assets:precompile')
|
45
|
+
Rake::Task['assets:precompile'].enhance(['active_admin:build'])
|
46
|
+
end
|
47
|
+
if Rake::Task.task_defined?('test:prepare')
|
48
|
+
Rake::Task['test:prepare'].enhance(['active_admin:build'])
|
49
|
+
end
|
50
|
+
if Rake::Task.task_defined?('spec:prepare')
|
51
|
+
Rake::Task['spec:prepare'].enhance(['active_admin:build'])
|
52
|
+
end
|
53
|
+
if Rake::Task.task_defined?('db:test:prepare')
|
54
|
+
Rake::Task['db:test:prepare'].enhance(['active_admin:build'])
|
55
|
+
end
|
File without changes
|