inline_forms_installer 8.0.4 → 8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6570363351e7a504578a5e2bba393ec1b7fcd0c5dd3190bbb975a19b1347d8e
4
- data.tar.gz: 05ec0f8cde0a8ffdafb8a1d5444c2d2246704343d333fe9af49ed8691d6f3a0e
3
+ metadata.gz: 05c7f9da56bb038f34b0f8619f3a94a7ef74cda07eba0c72a6ea9e03458e1c0e
4
+ data.tar.gz: 37cabf1e8475f659b12a8f075efd809b5205af4b2bdf83db3d80a46a4d70bec5
5
5
  SHA512:
6
- metadata.gz: f74cde7fd33066320e1d971713c85854c9e6089958970c6b617d32f9ba3a717df6a08728dcfaed7c4c3670be0019089a5d2ea729625be10a85d398bf439cfa97
7
- data.tar.gz: 28047b073197118349feba7ce2347ac6dc20a82f0933c1c8550cf009066c11b0f402e87b1c053d49bdbc1ca836a1b5adfe1d936bd39b350a9ec8cfb0bf42067f
6
+ metadata.gz: fc3a508903eee6c51a65e6258fd4888923684bd178fbdca29a7f2481db41857c1a9ffbe2fb1e2ea4f225f3bee2092ea9bb3f406f782409b8f8b301f81522b86e
7
+ data.tar.gz: 853891dd6b7bce30674ddba3f7deeaa54659eb53ddf79253b5bba4f0513a4cc090f083410e1f89c82344c528f2facb6663d84a94c6829d73643c87fa05a17ed1
@@ -356,8 +356,6 @@ create_file user_cfg.model_path, <<-USER_MODEL.strip_heredoc
356
356
  # devise :timeoutable
357
357
  # devise :omniauthable
358
358
 
359
- # Setup accessible (or protected) attributes for your model
360
- attr_writer :inline_forms_attribute_list
361
359
  #attr_accessible :email, :password, :locale, :remember_me
362
360
 
363
361
  belongs_to :locale
@@ -366,13 +364,10 @@ create_file user_cfg.model_path, <<-USER_MODEL.strip_heredoc
366
364
  # validations
367
365
  validates :name, :presence => true
368
366
 
369
- default_scope {order :name}
370
-
371
- # pagination
372
- attr_reader :per_page
373
- @per_page = 7
374
-
375
- has_paper_trail on: [:create, :update, :destroy]
367
+ # Default ordering for inline_forms list views (and any explicit caller
368
+ # via `#{user_cfg.class_name}.inline_forms_list`). Avoids `default_scope`
369
+ # so callers can `unscope`/`reorder` cleanly when needed.
370
+ scope :inline_forms_list, -> { order(:name, :id) }
376
371
 
377
372
  def _presentation
378
373
  "\#{name}"
@@ -406,25 +401,17 @@ create_file user_cfg.model_path, <<-USER_MODEL.strip_heredoc
406
401
  ]
407
402
  end
408
403
 
409
- def self.not_accessible_through_html?
410
- false
411
- end
412
-
413
- def self.order_by_clause
414
- nil
415
- end
416
-
417
404
  end
418
405
  USER_MODEL
419
406
 
420
407
  # Create Locales
421
408
  say "- Create locales"
422
- generate "inline_forms", "Locale name:string title:string #{user_cfg.table_name}:has_many _enabled:yes _presentation:\#{title}"
409
+ generate "inline_forms", "Locale name:string title:string #{user_cfg.table_name}:has_many _enabled:yes _list_order:title _presentation:\#{title}"
423
410
  append_to_file "db/seeds.rb", "Locale.create({ id: 1, name: 'en', title: 'English' })\n"
424
411
 
425
412
  # Create Roles
426
413
  say "- Create roles"
427
- generate "inline_forms", "Role name:string description:text #{user_cfg.table_name}:has_and_belongs_to_many _enabled:yes _presentation:\#{name}"
414
+ generate "inline_forms", "Role name:string description:text #{user_cfg.table_name}:has_and_belongs_to_many _enabled:yes _list_order:name _presentation:\#{name}"
428
415
  append_to_file "db/seeds.rb", "Role.create({ id: 1, name: 'superadmin', description: 'Super Admin can access all.' })\n"
429
416
 
430
417
  # Create Admin User
@@ -463,7 +450,7 @@ copy_file File.join(INLINE_FORMS_ROOT, 'lib/generators/assets/stylesheets/inline
463
450
  say "- Sprockets: link inline_forms_devise.css (logical path; dartsass:install drops link_directory ../stylesheets)..."
464
451
  append_to_file "app/assets/config/manifest.js", "//= link inline_forms_devise.css\n"
465
452
 
466
- say "- Add human_attribute_name in app/models/application_record.rb"
453
+ say "- Install ApplicationRecord (PaperTrail, pagination, inline_forms defaults)..."
467
454
  remove_file 'app/models/application_record.rb' # the one that 'rails new' created
468
455
  copy_file File.join(INLINE_FORMS_ROOT, 'lib/generators/templates/application_record.rb'), "app/models/application_record.rb"
469
456
 
@@ -718,14 +705,14 @@ git commit: " -a -m 'Initial Commit'"
718
705
  # example
719
706
  if ENV['install_example'] == 'true'
720
707
  say "\nInstalling example application..."
721
- run 'bundle exec rails g inline_forms Photo name:string caption:string image:image_field description:rich_text apartment:belongs_to _presentation:\'#{name}\''
708
+ run 'bundle exec rails g inline_forms Photo name:string caption:string image:image_field description:rich_text apartment:belongs_to _list_order:name _presentation:\'#{name}\''
722
709
  run 'bundle exec rails generate uploader Image'
723
- run 'bundle exec rails g inline_forms Apartment name:string title:string opening_date:date description:rich_text photos:has_many photos:associated _enabled:yes _presentation:\'#{name}\''
710
+ run 'bundle exec rails g inline_forms Apartment name:string title:string opening_date:date description:rich_text photos:has_many photos:associated _enabled:yes _list_order:name _list_search:name _presentation:\'#{name}\''
724
711
 
725
712
  say "- Apartment name is required..."
726
713
  inject_into_file "app/models/apartment.rb",
727
714
  "\n validates :name, presence: true\n",
728
- after: " has_paper_trail on: [:create, :update, :destroy]\n"
715
+ after: "class Apartment < ApplicationRecord\n"
729
716
 
730
717
  # CarrierWave + PaperTrail history.
731
718
  # PaperTrail snapshots the column scalar (the stored filename) on update,
@@ -790,20 +777,7 @@ if ENV['install_example'] == 'true'
790
777
  end
791
778
 
792
779
  say "- Lower Photo.per_page so the seeded gallery paginates..."
793
- # The model template (lib/generators/templates/model.erb) emits
794
- # attr_reader :per_page
795
- # @per_page = 7
796
- # which is a long-standing typo: `attr_reader :per_page` defines an
797
- # *instance* method, then `@per_page = 7` (executed in the class body)
798
- # actively *clobbers* the class-level per_page that will_paginate
799
- # exposes via `class_attribute :per_page` (its singleton-ivar storage
800
- # also lives on `@per_page`). Net effect: nothing reads 7 anywhere,
801
- # and the class-level per_page silently reverts to will_paginate's
802
- # 30-default. Replace the pair on Photo with a real `self.per_page = 5`
803
- # so the seeded gallery (12 photos) actually paginates 5/5/2.
804
- gsub_file "app/models/photo.rb",
805
- /^\s*attr_reader\s+:per_page\s*\n\s*@per_page\s*=\s*\d+\s*\n/,
806
- " self.per_page = 5\n"
780
+ inject_into_class "app/models/photo.rb", "Photo", " self.per_page = 5\n"
807
781
 
808
782
  run 'bundle exec rake db:migrate'
809
783
 
@@ -855,12 +829,12 @@ if ENV['install_example'] == 'true'
855
829
  # shared first field. See OwnersController override below.
856
830
  say "- Generating Owner model (has_many apartments)..."
857
831
  sleep 1
858
- run %q{bundle exec rails g inline_forms Owner name:string birthdate:date address:string city:string country:string apartments:has_many apartments:associated _enabled:yes _presentation:'#{name}'}
832
+ run %q{bundle exec rails g inline_forms Owner name:string birthdate:date address:string city:string country:string apartments:has_many apartments:associated _enabled:yes _list_order:name _list_search:name _presentation:'#{name}'}
859
833
 
860
834
  say "- Owner name is required..."
861
835
  inject_into_file "app/models/owner.rb",
862
836
  "\n validates :name, presence: true\n",
863
- after: " has_paper_trail on: [:create, :update, :destroy]\n"
837
+ after: "class Owner < ApplicationRecord\n"
864
838
 
865
839
  say "- Adding owner_id to apartments + belongs_to :owner..."
866
840
  sleep 1
@@ -875,7 +849,7 @@ if ENV['install_example'] == 'true'
875
849
 
876
850
  inject_into_file "app/models/apartment.rb",
877
851
  " belongs_to :owner, optional: true\n",
878
- after: " has_paper_trail on: [:create, :update, :destroy]\n"
852
+ after: "class Apartment < ApplicationRecord\n"
879
853
 
880
854
  # Insert the :owner dropdown row at the top of Apartment's attribute list
881
855
  # so it appears above :name in the inline panel.
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineFormsInstaller
3
- VERSION = "8.0.4"
3
+ VERSION = "8.1.0"
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"
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.0.4
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares