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,9 @@
1
+ # Admin for testing searchable_select_options with filter option
2
+ ActiveAdmin.register Post, as: 'TestPostFilter' do
3
+ menu false
4
+ searchable_select_options(
5
+ scope: Post,
6
+ filter: ->(term, scope) { scope.where(title: term) },
7
+ text_attribute: :title
8
+ )
9
+ end
@@ -0,0 +1,9 @@
1
+ # Admin for testing searchable_select_options with name prefix
2
+ ActiveAdmin.register Post, as: 'TestPostNamed' do
3
+ menu false
4
+ searchable_select_options(
5
+ name: :some,
6
+ scope: Post,
7
+ text_attribute: :title
8
+ )
9
+ end
@@ -0,0 +1,9 @@
1
+ # Admin for testing searchable_select_options with pagination
2
+ ActiveAdmin.register Post, as: 'TestPostPagination' do
3
+ menu false
4
+ searchable_select_options(
5
+ scope: Post,
6
+ text_attribute: :title,
7
+ per_page: 2
8
+ )
9
+ end
@@ -0,0 +1,11 @@
1
+ # Admin for testing searchable_select_options with additional_payload as lambda
2
+ ActiveAdmin.register Post, as: 'TestPostPayloadLambda' do
3
+ menu false
4
+ searchable_select_options(
5
+ scope: Post,
6
+ text_attribute: :title,
7
+ additional_payload: lambda do |record|
8
+ { published: record.published }
9
+ end
10
+ )
11
+ end
@@ -0,0 +1,9 @@
1
+ # Admin for testing searchable_select_options with additional_payload as proc
2
+ ActiveAdmin.register Post, as: 'TestPostPayloadProc' do
3
+ menu false
4
+ searchable_select_options(
5
+ scope: Post,
6
+ text_attribute: :title,
7
+ additional_payload: proc { |record| { published: record.published } }
8
+ )
9
+ end
@@ -0,0 +1,8 @@
1
+ # Admin for testing searchable_select_options with lambda scope
2
+ ActiveAdmin.register Post, as: 'TestPostScopeLambda' do
3
+ menu false
4
+ searchable_select_options(
5
+ scope: -> { Post.published },
6
+ text_attribute: :title
7
+ )
8
+ end
@@ -0,0 +1,8 @@
1
+ # Admin for testing searchable_select_options with lambda that takes params argument
2
+ ActiveAdmin.register Post, as: 'TestPostScopeParams' do
3
+ menu false
4
+ searchable_select_options(
5
+ scope: ->(params) { Post.where(user_id: params[:user]) },
6
+ text_attribute: :title
7
+ )
8
+ end
@@ -0,0 +1,8 @@
1
+ # Admin for testing searchable_select_options with lambda scope that uses view helpers
2
+ ActiveAdmin.register Post, as: 'TestPostScopeUser' do
3
+ menu false
4
+ searchable_select_options(
5
+ scope: -> { Post.where(user: current_user) },
6
+ text_attribute: :title
7
+ )
8
+ end
@@ -0,0 +1,5 @@
1
+ # Admin for testing searchable_select_options with text_attribute
2
+ ActiveAdmin.register Post, as: 'TestPostTextAttr' do
3
+ menu false
4
+ searchable_select_options(scope: Post, text_attribute: :title)
5
+ end
@@ -0,0 +1,23 @@
1
+ ActiveAdmin.register User do
2
+ permit_params :name
3
+
4
+ searchable_select_options(scope: User.all,
5
+ text_attribute: :name)
6
+
7
+ index do
8
+ selectable_column
9
+ id_column
10
+ column :name
11
+ column :created_at
12
+ actions
13
+ end
14
+
15
+ filter :name
16
+
17
+ form do |f|
18
+ f.inputs do
19
+ f.input :name
20
+ end
21
+ f.actions
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ ActiveAdmin.register Variant do
2
+ belongs_to :product
3
+
4
+ permit_params :price, :option_value_id, :product_id
5
+
6
+ index do
7
+ selectable_column
8
+ id_column
9
+ column :price
10
+ column :option_value
11
+ actions
12
+ end
13
+
14
+ filter :price
15
+ filter :option_value
16
+
17
+ form do |f|
18
+ f.inputs do
19
+ f.input :price
20
+ f.input(:option_value,
21
+ as: :searchable_select,
22
+ ajax: {
23
+ resource: OptionValue,
24
+ path_params: {
25
+ option_type_id: f.object.product&.option_type_id
26
+ }
27
+ })
28
+ end
29
+ f.actions
30
+ end
31
+ end
@@ -0,0 +1,2 @@
1
+ //= link_tree ../images
2
+ //= link_tree ../builds
File without changes
@@ -0,0 +1,16 @@
1
+ @import "tailwindcss/base";
2
+ @import "tailwindcss/components";
3
+ @import "tailwindcss/utilities";
4
+
5
+ @import "@rocket-sensei/activeadmin-tom_select/src/tom-select-tailwind.css";
6
+
7
+ /* Additional batch actions dropdown styles that aren't in the ActiveAdmin plugin */
8
+ @layer components {
9
+ .batch-actions-dropdown-toggle:disabled {
10
+ @apply opacity-50 cursor-not-allowed;
11
+ }
12
+
13
+ .batch-actions-dropdown-arrow {
14
+ @apply w-2.5 h-2.5;
15
+ }
16
+ }
@@ -0,0 +1,15 @@
1
+ @import "tailwindcss";
2
+
3
+ /* Import our Tom Select Tailwind theme overrides */
4
+ @import '../../../../../src/tom-select-tailwind.css';
5
+
6
+ /* Additional batch actions dropdown styles that aren't in the ActiveAdmin plugin */
7
+ @layer components {
8
+ .batch-actions-dropdown-toggle:disabled {
9
+ @apply opacity-50 cursor-not-allowed;
10
+ }
11
+
12
+ .batch-actions-dropdown-arrow {
13
+ @apply w-2.5 h-2.5;
14
+ }
15
+ }
@@ -0,0 +1,9 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Only allow modern browsers supporting webp images, web push, badges,
3
+ # import maps, CSS nesting, and CSS :has.
4
+ allow_browser versions: :modern if respond_to?(:allow_browser)
5
+
6
+ cattr_accessor :current_user
7
+
8
+ helper_method :current_user
9
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,19 @@
1
+ // Import ActiveAdmin - this already includes all features and Rails UJS
2
+ // DO NOT import Rails separately as it's already included and started in ActiveAdmin
3
+ import '@activeadmin/activeadmin';
4
+
5
+ // Import Tom Select
6
+ import TomSelect from 'tom-select';
7
+ // Make it globally available for the searchable select init
8
+ window.TomSelect = TomSelect;
9
+
10
+ // Import and setup ActiveAdmin Tom Select
11
+ import { setupAutoInit, initSearchableSelects } from '@rocket-sensei/activeadmin-tom_select';
12
+
13
+ // Make the init function globally available for tests
14
+ window.initSearchableSelects = initSearchableSelects;
15
+
16
+ // Initialize the module after everything is loaded
17
+ setupAutoInit();
18
+
19
+ console.log('ActiveAdmin JS loaded with Tom Select');
@@ -0,0 +1,2 @@
1
+ // Simple application.js for testing
2
+ console.log('Application.js loaded');
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,9 @@
1
+ class AdminUser < ApplicationRecord
2
+ # Include default devise modules. Others available are:
3
+ # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
4
+ devise :database_authenticatable, :recoverable, :rememberable, :validatable
5
+
6
+ def self.ransackable_attributes(_auth_object = nil)
7
+ %w[created_at email id remember_created_at reset_password_sent_at updated_at]
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ primary_abstract_class
3
+ end
@@ -0,0 +1,12 @@
1
+ class Article < ApplicationRecord
2
+ belongs_to :category, optional: true
3
+ belongs_to :user, optional: true
4
+
5
+ def self.ransackable_attributes(_auth_object = nil)
6
+ %w[category_id title]
7
+ end
8
+
9
+ def self.ransackable_associations(_auth_object = nil)
10
+ []
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class Category < ApplicationRecord
2
+ has_many :posts
3
+ belongs_to :created_by, class_name: 'User', optional: true
4
+
5
+ def self.ransackable_attributes(_auth_object = nil)
6
+ %w[created_by_id description id name created_at updated_at]
7
+ end
8
+
9
+ def self.ransackable_associations(_auth_object = nil)
10
+ %w[posts created_by]
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ class Color < ApplicationRecord
2
+ def display_name
3
+ "#{name} (#{hex})"
4
+ end
5
+
6
+ def self.ransackable_attributes(_auth_object = nil)
7
+ %w[created_at hex id name updated_at]
8
+ end
9
+ end
File without changes
@@ -0,0 +1,14 @@
1
+ module Internal
2
+ class TagName < ApplicationRecord
3
+ self.table_name = :internal_tag_names
4
+ belongs_to :color, class_name: 'RgbColor', foreign_key: :color_id, optional: true
5
+
6
+ def self.ransackable_attributes(_auth_object = nil)
7
+ %w[color_id name]
8
+ end
9
+
10
+ def self.ransackable_associations(_auth_object = nil)
11
+ ['color']
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ class InternalTagName < ApplicationRecord
2
+ belongs_to :color, class_name: 'RgbColor', optional: true
3
+
4
+ def self.ransackable_attributes(_auth_object = nil)
5
+ %w[color_id id name created_at updated_at]
6
+ end
7
+
8
+ def self.ransackable_associations(_auth_object = nil)
9
+ ['color']
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class OptionType < ApplicationRecord
2
+ has_many :option_values
3
+ has_many :products
4
+
5
+ def self.ransackable_attributes(_auth_object = nil)
6
+ %w[name id created_at updated_at]
7
+ end
8
+
9
+ def self.ransackable_associations(_auth_object = nil)
10
+ %w[option_values products]
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ class OptionValue < ApplicationRecord
2
+ belongs_to :option_type
3
+ has_many :variants
4
+ end
@@ -0,0 +1,15 @@
1
+ class Post < ApplicationRecord
2
+ belongs_to :category, optional: true
3
+ belongs_to :user, optional: true
4
+
5
+ scope :published, -> { where(published: true) }
6
+ scope :unpublished, -> { where(published: false) }
7
+
8
+ def self.ransackable_attributes(_auth_object = nil)
9
+ %w[body category_id id published title user_id created_at updated_at]
10
+ end
11
+
12
+ def self.ransackable_associations(_auth_object = nil)
13
+ %w[category user]
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ class Product < ApplicationRecord
2
+ belongs_to :option_type, optional: true
3
+ has_many :variants
4
+
5
+ def self.ransackable_attributes(_auth_object = nil)
6
+ %w[name option_type_id id created_at updated_at]
7
+ end
8
+
9
+ def self.ransackable_associations(_auth_object = nil)
10
+ %w[option_type variants]
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ class RgbColor < ApplicationRecord
2
+ has_many :internal_tag_names, foreign_key: :color_id
3
+ has_many :tags, class_name: 'Internal::TagName', foreign_key: :color_id
4
+
5
+ def display_name
6
+ "#{code} - #{description}"
7
+ end
8
+
9
+ def self.ransackable_attributes(_auth_object = nil)
10
+ %w[code description id created_at updated_at]
11
+ end
12
+
13
+ def self.ransackable_associations(_auth_object = nil)
14
+ %w[internal_tag_names tags]
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ class Tag < ApplicationRecord
2
+ has_many :taggings
3
+ has_many :posts, through: :taggings
4
+
5
+ def self.ransackable_attributes(_auth_object = nil)
6
+ %w[created_at id name updated_at]
7
+ end
8
+
9
+ def self.ransackable_associations(_auth_object = nil)
10
+ %w[posts taggings]
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class Tagging < ApplicationRecord
2
+ belongs_to :tag
3
+ belongs_to :post
4
+
5
+ def self.ransackable_attributes(_auth_object = nil)
6
+ %w[created_at id post_id tag_id updated_at]
7
+ end
8
+
9
+ def self.ransackable_associations(_auth_object = nil)
10
+ %w[post tag]
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class User < ApplicationRecord
2
+ has_many :posts
3
+ has_many :created_categories, class_name: 'Category', foreign_key: 'created_by_id'
4
+
5
+ def self.ransackable_attributes(_auth_object = nil)
6
+ %w[email id name created_at updated_at]
7
+ end
8
+
9
+ def self.ransackable_associations(_auth_object = nil)
10
+ %w[posts created_categories]
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class Variant < ApplicationRecord
2
+ belongs_to :product, optional: true
3
+ belongs_to :option_value, optional: true
4
+
5
+ def self.ransackable_attributes(_auth_object = nil)
6
+ %w[price product_id option_value_id id created_at updated_at]
7
+ end
8
+
9
+ def self.ransackable_associations(_auth_object = nil)
10
+ %w[product option_value]
11
+ end
12
+ end
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= content_for(:title) || "Internal" %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <meta name="apple-mobile-web-app-capable" content="yes">
7
+ <meta name="mobile-web-app-capable" content="yes">
8
+ <%= csrf_meta_tags %>
9
+ <%= csp_meta_tag %>
10
+
11
+ <%= yield :head %>
12
+
13
+ <%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
14
+ <%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>
15
+
16
+ <link rel="icon" href="/icon.png" type="image/png">
17
+ <link rel="icon" href="/icon.svg" type="image/svg+xml">
18
+ <link rel="apple-touch-icon" href="/icon.png">
19
+
20
+ <%# Includes all stylesheet files in app/assets/stylesheets %>
21
+ <%= stylesheet_link_tag :app %>
22
+ <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>
23
+ </head>
24
+
25
+ <body>
26
+ <%= yield %>
27
+ </body>
28
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "Internal",
3
+ "icons": [
4
+ {
5
+ "src": "/icon.png",
6
+ "type": "image/png",
7
+ "sizes": "512x512"
8
+ },
9
+ {
10
+ "src": "/icon.png",
11
+ "type": "image/png",
12
+ "sizes": "512x512",
13
+ "purpose": "maskable"
14
+ }
15
+ ],
16
+ "start_url": "/",
17
+ "display": "standalone",
18
+ "scope": "/",
19
+ "description": "Internal.",
20
+ "theme_color": "red",
21
+ "background_color": "red"
22
+ }
@@ -0,0 +1,26 @@
1
+ // Add a service worker for processing Web Push notifications:
2
+ //
3
+ // self.addEventListener("push", async (event) => {
4
+ // const { title, options } = await event.data.json()
5
+ // event.waitUntil(self.registration.showNotification(title, options))
6
+ // })
7
+ //
8
+ // self.addEventListener("notificationclick", function(event) {
9
+ // event.notification.close()
10
+ // event.waitUntil(
11
+ // clients.matchAll({ type: "window" }).then((clientList) => {
12
+ // for (let i = 0; i < clientList.length; i++) {
13
+ // let client = clientList[i]
14
+ // let clientPath = (new URL(client.url)).pathname
15
+ //
16
+ // if (clientPath == event.notification.data.path && "focus" in client) {
17
+ // return client.focus()
18
+ // }
19
+ // }
20
+ //
21
+ // if (clients.openWindow) {
22
+ // return clients.openWindow(event.notification.data.path)
23
+ // }
24
+ // })
25
+ // )
26
+ // })