inline_forms_installer 8.1.3 → 8.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b4f54ce386e1f7b9b8052cb1817c837a94a1cb4b315887a19456d1c054f8a28
4
- data.tar.gz: 2597296ce7e66de213ba8eef07191b924c355258f45210cbf6380c1ffa695891
3
+ metadata.gz: 7ebb695af4c902a20604e51deb4fc8a2eefaf32e625cf86805633ffd65e048d4
4
+ data.tar.gz: 1b630b3fc3f578fbde245ec2957c9cedc60c0dc27cf28d506b56a41361fb9d5c
5
5
  SHA512:
6
- metadata.gz: 6517c3d2c92010b5f9f8032206e8bad5d14bf5d11b77c186d807fed490680534952d136aa2e63ebd485878d17561a66a7c7477126fface669d447e63d69aa245
7
- data.tar.gz: 243c4dee8186095ec2d8fd84a34a204bcf6deecf74360e01069b3396435dfad83fc12162fb347d704bf51e6a95301b9ef768b93185551f763523e6344fee27cd
6
+ metadata.gz: 50c22db56f53d41b37f9aaffb44298478a707fbd8f36d962a280e8d952f1c77a25306f6c9e2ecd10f59b825807ced7f172c6dfa547d613efa3569cee6c3e88ec
7
+ data.tar.gz: 1c4b64a00674ca2096c1b40c2f48f7bed3c2bd696f0fdf0cd295c6f7df093b244047040e2b07059c42364dd26e842040218973ea002324aafc6780a388ed7d62
@@ -368,6 +368,11 @@ create_file user_cfg.model_path, <<-USER_MODEL.strip_heredoc
368
368
  # via `#{user_cfg.class_name}.inline_forms_list`). Avoids `default_scope`
369
369
  # so callers can `unscope`/`reorder` cleanly when needed.
370
370
  scope :inline_forms_list, -> { order(:name, :id) }
371
+ # Search box on /#{user_cfg.plural_route} filters by name OR email. Without this
372
+ # the controller would `merge(ApplicationRecord.inline_forms_search(q))`,
373
+ # which is the no-op `all` fallback, and the query string would be silently
374
+ # ignored.
375
+ scope :inline_forms_search, ->(q) { where("name LIKE :q OR email LIKE :q", q: "%\#{q}%") }
371
376
 
372
377
  def _presentation
373
378
  "\#{name}"
@@ -379,31 +384,43 @@ create_file user_cfg.model_path, <<-USER_MODEL.strip_heredoc
379
384
 
380
385
  def inline_forms_attribute_list
381
386
  @inline_forms_attribute_list ||= [
382
- [ :header_user_login, '', :header ],
383
- [ :name, '', :text_field ],
384
- [ :email, '', :text_field ],
385
- [ :locale , '', :dropdown ],
386
- [ :password, '', :devise_password_field ],
387
- [ :header_user_roles, '', :header ],
388
- [ :roles, '', :check_list ],
389
- [ :header_user_other_stuff, '', :header ],
390
- [ :encrypted_password, '', :info ],
391
- [ :reset_password_token, '', :info ],
392
- [ :reset_password_sent_at, '', :info],
393
- [ :remember_created_at, '', :info ],
394
- [ :sign_in_count, '', :info ],
395
- [ :current_sign_in_at, '', :info ],
396
- [ :last_sign_in_at, '', :info ],
397
- [ :current_sign_in_ip, '', :info ],
398
- [ :last_sign_in_ip, '', :info ],
399
- [ :created_at, '', :info ],
400
- [ :updated_at, '', :info ],
387
+ [ :header_user_login, :header ],
388
+ [ :name, :text_field ],
389
+ [ :email, :text_field ],
390
+ [ :locale, :dropdown ],
391
+ [ :password, :devise_password_field ],
392
+ [ :header_user_roles, :header ],
393
+ [ :roles, :check_list ],
394
+ [ :header_user_other_stuff, :header ],
395
+ [ :encrypted_password, :info ],
396
+ [ :reset_password_token, :info ],
397
+ [ :reset_password_sent_at, :info ],
398
+ [ :remember_created_at, :info ],
399
+ [ :sign_in_count, :info ],
400
+ [ :current_sign_in_at, :info ],
401
+ [ :last_sign_in_at, :info ],
402
+ [ :current_sign_in_ip, :info ],
403
+ [ :last_sign_in_ip, :info ],
404
+ [ :created_at, :info ],
405
+ [ :updated_at, :info ],
401
406
  ]
402
407
  end
403
408
 
404
409
  end
405
410
  USER_MODEL
406
411
 
412
+ # inline_forms initializer (must exist before subsequent `rails g inline_forms`
413
+ # runs so the generator's `add_tab` step can inject each generated model's
414
+ # route token into `MODEL_TABS`). Pre-seeded with the user-model route
415
+ # (the user model is hand-written above, not generated, so the generator
416
+ # never sees it).
417
+ say "- Creating inline_forms initializer (MODEL_TABS seeded with #{user_cfg.plural_route})"
418
+ create_file "config/initializers/inline_forms.rb", <<-END_INITIALIZER.strip_heredoc
419
+ Rails.application.reloader.to_prepare do
420
+ MODEL_TABS = %w(#{user_cfg.plural_route} )
421
+ end
422
+ END_INITIALIZER
423
+
407
424
  # Create Locales
408
425
  say "- Create locales"
409
426
  generate "inline_forms", "Locale name:string title:string #{user_cfg.table_name}:has_many _enabled:yes _list_order:title _presentation:\#{title}"
@@ -545,13 +562,6 @@ create_file "app/helpers/application_helper.rb", <<-END_APPHELPER.strip_heredoc
545
562
  end
546
563
  END_APPHELPER
547
564
 
548
- say "- Creating inline_forms initializer"
549
- create_file "config/initializers/inline_forms.rb", <<-END_INITIALIZER.strip_heredoc
550
- Rails.application.reloader.to_prepare do
551
- MODEL_TABS = %w()
552
- end
553
- END_INITIALIZER
554
-
555
565
  say "- Recreating ApplicationController to add devise, cancan, I18n stuff..."
556
566
  remove_file "app/controllers/application_controller.rb" # the one that 'rails new' created
557
567
  create_file "app/controllers/application_controller.rb", <<-END_APPCONTROLLER.strip_heredoc
@@ -855,7 +865,7 @@ if ENV['install_example'] == 'true'
855
865
  # so it appears above :name in the inline panel.
856
866
  gsub_file "app/models/apartment.rb",
857
867
  /@inline_forms_attribute_list \|\|= \[\n/,
858
- "@inline_forms_attribute_list ||= [\n [ :owner , \"owner\", :dropdown ], \n"
868
+ "@inline_forms_attribute_list ||= [\n [ :owner, :dropdown ], \n"
859
869
 
860
870
  # Owner -> apartments: render as a check_list of EXISTING apartments
861
871
  # (not the default :associated panel that only lets you create new
@@ -863,8 +873,8 @@ if ENV['install_example'] == 'true'
863
873
  # `apartment_ids=` setter that CheckListHelper uses, so we just swap
864
874
  # the form element kind in the generated attribute list.
865
875
  gsub_file "app/models/owner.rb",
866
- /\[ :apartments , "apartments", :associated \]/,
867
- '[ :apartments , "apartments", :check_list ]'
876
+ /\[ :apartments, :associated \]/,
877
+ '[ :apartments, :check_list ]'
868
878
 
869
879
  say "- Replacing OwnersController with tabbed-show variant (/owners/:id)..."
870
880
  remove_file "app/controllers/owners_controller.rb"
@@ -904,7 +914,7 @@ if ENV['install_example'] == 'true'
904
914
  def owner_attributes_for(tab)
905
915
  full = @object.inline_forms_attribute_list
906
916
  OWNER_TAB_FIELDS.fetch(tab).map do |attr|
907
- full.find { |a, _, _| a == attr } ||
917
+ full.find { |a, _| a == attr } ||
908
918
  raise("OwnersController: attribute \#{attr.inspect} missing from Owner#inline_forms_attribute_list")
909
919
  end
910
920
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineFormsInstaller
3
- VERSION = "8.1.3"
3
+ VERSION = "8.1.5"
4
4
 
5
5
  # Written into generated apps' `.ruby-version` (must match gemspec `required_ruby_version`).
6
6
  TARGET_RUBY_VERSION = "ruby-4.0.4"
@@ -14,7 +14,7 @@ class ExampleAppPlainTextRichTextEdgeCasesTest < ActiveSupport::TestCase
14
14
  test "plain_text mapped to actiontext-backed attribute raises configuration error" do
15
15
  with_temporary_inline_forms_attribute_list(
16
16
  Apartment,
17
- [[:description, "description", :plain_text]]
17
+ [[:description, :plain_text]]
18
18
  ) do
19
19
  error = assert_raises(InlineForms::PlainTextColumnMissingError) do
20
20
  InlineForms.validate_plain_text_configuration_for!(Apartment)
@@ -38,7 +38,7 @@ class ExampleAppPlainTextRichTextEdgeCasesTest < ActiveSupport::TestCase
38
38
  test "switching text column field from plain_text to rich_text does not raise" do
39
39
  with_temporary_inline_forms_attribute_list(
40
40
  Role,
41
- [[:description, "description", :rich_text]]
41
+ [[:description, :rich_text]]
42
42
  ) do
43
43
  InlineForms.validate_plain_text_configuration_for!(Role)
44
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms_installer
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.3
4
+ version: 8.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares