hot-glue 0.5.24 → 0.5.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: badba8cc091a29c8613194fa379cce1d7cdd720a1ae3627630a069afb5b4c352
4
- data.tar.gz: d0e5cd8a96ae546596eabc865f1dc4979f0a528b82ffd19bdfdddf6dc92fe3f0
3
+ metadata.gz: 9c2b46bf01f0742356ab56ad4cd139534becbe919b8e38ac8d166f8ca1c1c47c
4
+ data.tar.gz: b697f19f9928249d693632ff040f7ebb97ddf396fd8fb8d74b60f3abfe3a6bca
5
5
  SHA512:
6
- metadata.gz: 94ae4da0d2644a6b6311f5b81da1f864ae90d4a69c133b4a3259ad53f0221ed10bfedfe4964dc7ceb04d65e2d6ef28c420af6b5489bae4ec22bb7989f6b0249a
7
- data.tar.gz: 9e0f23257368d5836f4a95c4f116f2d70057f063cce7ff14acecee0c2e7f62fd921e752d13fec73d073aa40ba6f89709a9efbb92a0c0f2bd823324a897cf93dd
6
+ metadata.gz: 9ad16ec01f21d5ac9013cbbc0ee2e364cce4deec8ff52544d34438c641a4009d763ff953e70813d2f4b5e5b35904959ca49b5fea50dc8187c254c0bc0a19850c
7
+ data.tar.gz: f7cbb297d36077486c6983b0dfebee09b32871b316f28fe215f3578df5054445f337d372e13b55d84f44f30a6e4e0de776df14cb3137a4ec12c8e481ed38abba
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.5.24)
4
+ hot-glue (0.5.25)
5
5
  ffaker (~> 2.16)
6
6
  kaminari (~> 1.2)
7
7
  rails (> 5.1)
@@ -139,7 +139,7 @@ GEM
139
139
  mini_mime (1.1.2)
140
140
  mini_portile2 (2.8.4)
141
141
  minitest (5.16.3)
142
- net-imap (0.4.0)
142
+ net-imap (0.4.1)
143
143
  date
144
144
  net-protocol
145
145
  net-pop (0.1.2)
data/README.md CHANGED
@@ -894,10 +894,15 @@ Produces ONLY the controller spec file, nothing else.
894
894
  Produces all the files except the spec file.
895
895
 
896
896
 
897
- ### `--no-paginate`
897
+ ### `--no-paginate` (default: false)
898
898
 
899
899
  Omits pagination. (All list views have pagination by default.)
900
900
 
901
+ ### `--paginate-per-page-selector` (default: false)
902
+
903
+ Show a small drop-down below the list to let the user choose 10, 25, or 100 results per page.
904
+
905
+
901
906
  ### `--no-list`
902
907
 
903
908
  Omits list action. Only makes sense to use this if want to create a view where you only want the create button or to navigate to the update screen alternative ways. (The new/create still appears, as well the edit, update & destroy actions are still created even though there is no natural way to navigate to them.)
@@ -1464,10 +1469,33 @@ bin/rails generate Thing --include=my_story --modify='my_story{tinymce}'
1464
1469
 
1465
1470
  # VERSION HISTORY
1466
1471
 
1472
+ #### 2023-10-16 - v0.5.25
1473
+
1474
+ - Fixes scoping on Pundit-built controllers; even when using pundit we should still wrap to the current build's own ownership scope (#132
1475
+ - don't write to the nav file if we're building a nested controller (#134)
1476
+ - adds system specs for self-auth feature
1477
+ - Pagination Fixes:
1478
+
1479
+ A new flag `--paginate-per-page-selector` (default false) will allow you to show a small drop-down to let the user choose 10, 25, or 100 results per page.
1480
+
1481
+ To get pagination to work, choose either #1 OR #2 below. #1 will replace the templates in app/views/kaminari so don't do that if you have modified them since first generating them out of Kaminari.
1482
+
1483
+ 1. Replace the kaminari gem with my fork and regenerate your templates
1484
+ bundle remove kaminari
1485
+ bundle add kaminari --git="https://github.com/jasonfb/kaminari.git" --branch="master"
1486
+ bundle install
1487
+ rm -rf app/views/kaminari
1488
+ rails g kaminari:config
1489
+
1490
+
1491
+ 2. Go into app/views/kaminari/ and modify each template in this folder by adding ` 'data-turbo-action': 'advance'` to all of the links (which mostly appear in this code as the `link_to_unless` helper-- add the parameter onto the end of the calls to those helpers.)
1492
+
1493
+
1494
+
1467
1495
  #### 2023-10-07 - v0.5.24
1468
1496
 
1469
1497
  - TinyMCE implementation. See 'TinyMCE' above.
1470
- Note: I plan to also implement ActionText as an alternative in the future. However, because TinyMCE is implemented with a `text` field type an ActionText is implemented with a Rails-specific `rich_text` field type, the two mechanisms will be incompatible with one another. TinyMCE has an annoying drawback in how it works with Turbo refreshes (not very consistently), and style of loading Javascript is discordant with Rails moving forward. So I am leaving this implementation as experimental.
1498
+ Note: I also plan to implement ActionText as an alternative. However, because TinyMCE is implemented with a `text` field type an ActionText is implemented with a Rails-specific `rich_text` field type, the two mechanisms will be incompatible with one another. TinyMCE has an annoying drawback in how it works with Turbo refreshes (not very consistently), and style of loading Javascript is discordant with Rails moving forward. So I am leaving this implementation as experimental.
1471
1499
  - Spec Savestart code: In the behavior specs, there is a code marker (start & end) where you can insert custom code that gets saved between
1472
1500
  build. The start code maker has changed from `#HOTGLUE-SAVESTART` to `# HOTGLUE-SAVESTART`
1473
1501
  and the end code marker has changed from `#HOTGLUE-END` to `# HOTGLUE-END`. This now conforms to Rubocop.
@@ -1968,7 +1996,5 @@ To run only the internal specs, use
1968
1996
 
1969
1997
  `rspec spec`
1970
1998
 
1971
- Internal Test coverage as of 2023-02-10 (v0.5.7)
1972
-
1973
- <img width="1202" alt="Screen Shot 2023-02-10 at 4 43 59 PM" src="https://user-images.githubusercontent.com/59002/218204736-5740505b-1ec8-456f-b0fb-9c359f6f7037.png">
1974
-
1999
+ Internal Test coverage as of 2023-10-15 (v0.5.24)
2000
+ All Files ( 86.29% covered at 75.64 hits/line )
@@ -55,6 +55,7 @@ class FieldFactory
55
55
  class_name: generator.singular_class,
56
56
  alt_lookups: generator.alt_lookups,
57
57
  singular: generator.singular,
58
+ self_auth: generator.self_auth,
58
59
  update_show_only: generator.update_show_only,
59
60
  attachment_data: generator.attachments[name.to_sym],
60
61
  sample_file_path: generator.sample_file_path,
@@ -10,7 +10,7 @@ class AssociationField < Field
10
10
  update_show_only: ,
11
11
  hawk_keys: , auth: , sample_file_path:, ownership_field: ,
12
12
  attachment_data: nil , layout_strategy: , form_placeholder_labels: nil,
13
- form_labels_position:, modify_as: )
13
+ form_labels_position:, modify_as: , self_auth: )
14
14
  super
15
15
 
16
16
  @assoc_model = eval("#{class_name}.reflect_on_association(:#{assoc})")
@@ -4,7 +4,7 @@ class AttachmentField < Field
4
4
  display_as:,
5
5
  singular:, update_show_only:, hawk_keys:, auth:,
6
6
  sample_file_path: nil, attachment_data:, ownership_field:, layout_strategy: ,
7
- form_placeholder_labels: , form_labels_position:, modify_as: )
7
+ form_placeholder_labels: , form_labels_position:, modify_as:, self_auth: )
8
8
  super
9
9
 
10
10
  @attachment_data = attachment_data
@@ -3,6 +3,7 @@ class Field
3
3
  :assoc_label, :class_name, :default_boolean_display, :display_as, :form_placeholder_labels,
4
4
  :form_labels_position,
5
5
  :hawk_keys, :layout_strategy, :limit, :modify_as, :name, :object, :sample_file_path,
6
+ :self_auth,
6
7
  :singular_class, :singular, :sql_type, :ownership_field,
7
8
  :update_show_only
8
9
 
@@ -22,7 +23,8 @@ class Field
22
23
  ownership_field: ,
23
24
  sample_file_path: nil,
24
25
  singular: ,
25
- update_show_only:
26
+ update_show_only:,
27
+ self_auth:
26
28
  )
27
29
  @name = name
28
30
  @layout_strategy = layout_strategy
@@ -39,6 +41,7 @@ class Field
39
41
  @modify_as = modify_as
40
42
  @display_as = display_as
41
43
 
44
+ @self_auth = self_auth
42
45
  @default_boolean_display = default_boolean_display
43
46
 
44
47
  # TODO: remove knowledge of subclasses from Field
@@ -83,7 +86,11 @@ class Field
83
86
  end
84
87
 
85
88
  def spec_list_view_natural_assertion
86
- "expect(page).to have_content(#{singular}#{1}.#{name})"
89
+ if !self_auth
90
+ "expect(page).to have_content(#{singular}#{1}.#{name})"
91
+ else
92
+ "expect(page).to have_content(current_#{singular}.#{name})"
93
+ end
87
94
  end
88
95
 
89
96
  def spec_list_view_assertion
@@ -22,7 +22,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
22
22
  :modify_as,
23
23
  :nest_with, :path, :plural, :sample_file_path, :show_only_data, :singular,
24
24
  :singular_class, :smart_layout, :stacked_downnesting, :update_show_only, :ownership_field,
25
- :layout_strategy, :form_placeholder_labels, :form_labels_position, :pundit
25
+ :layout_strategy, :form_placeholder_labels, :form_labels_position, :pundit,
26
+ :self_auth
26
27
 
27
28
  class_option :singular, type: :string, default: nil
28
29
  class_option :plural, type: :string, default: nil
@@ -47,6 +48,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
47
48
  class_option :no_controller, type: :boolean, default: false
48
49
  class_option :no_list, type: :boolean, default: false
49
50
  class_option :no_paginate, type: :boolean, default: false
51
+ class_option :paginate_per_page_selector, type: :boolean, default: false
50
52
  class_option :big_edit, type: :boolean, default: false
51
53
  class_option :show_only, type: :string, default: ""
52
54
  class_option :update_show_only, type: :string, default: ""
@@ -295,6 +297,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
295
297
 
296
298
  @no_create = options['no_create'] || false
297
299
  @no_paginate = options['no_paginate'] || false
300
+ @paginate_per_page_selector = options['paginate_per_page_selector']
301
+
298
302
  @big_edit = options['big_edit']
299
303
 
300
304
  @no_edit = options['no_edit'] || false
@@ -748,6 +752,14 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
748
752
  singular_class.gsub("::", "_").underscore
749
753
  end
750
754
 
755
+ def factory_testing_name
756
+ if !@self_auth
757
+ "#{singular}1"
758
+ else
759
+ "current_#{singular}"
760
+ end
761
+ end
762
+
751
763
  def spec_related_column_lets
752
764
  @columns_map.collect { |col, col_object|
753
765
  col_object.spec_related_column_lets
@@ -1093,7 +1105,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1093
1105
  def insert_into_nav_template
1094
1106
  # how does this get called(?)
1095
1107
  nav_file = "#{Rails.root}/app/views/#{namespace_with_trailing_dash}_nav.html.#{@markup}"
1096
- if include_nav_template
1108
+ if include_nav_template && @nested_set.none?
1097
1109
  append_text = " <li class='nav-item'>
1098
1110
  <%= link_to '#{@list_label_heading}', #{path_helper_plural}, class: \"nav-link \#{'active' if nav == '#{plural_name}'}\" %>
1099
1111
  </li>"
@@ -66,13 +66,16 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
66
66
  def load_<%= singular_name %>
67
67
  @<%= singular_name %> = (<%= auth_object.gsub("@",'') %><%= " if params.include?(:#{@nested_set[0][:singular]}_id)" if @nested_set.any? && @nested_set[0][:optional] %>)<% if @nested_set.any? && @nested_set[0][:optional] %> || <%= class_name %>.find(params[:id])<% end %>
68
68
  end<% end %>
69
+ <% if @paginate_per_page_selector %>def per
70
+ params[:per] || 10
71
+ end
69
72
 
70
- def load_all_<%= plural %><% if @pundit %>
71
- @<%= plural_name %> = policy_scope(<%= class_name %>).page(params[:page])<%= n_plus_one_includes %>
73
+ <% end %>def load_all_<%= plural %><% if @pundit %>
74
+ @<%= plural_name %> = policy_scope(<%= object_scope %>).page(params[:page])<%= n_plus_one_includes %><%= ".per(per)" if @paginate_per_page_selector %>
72
75
  authorize @<%= plural_name %>.all<% else %> <% if !@self_auth %>
73
- @<%= plural_name %> = <%= object_scope.gsub("@",'') %>.page(params[:page])<%= n_plus_one_includes %><%= " if params.include?(:#{ @nested_set.last[:singular]}_id)" if @nested_set.any? && @nested_set[0] && @nested_set[0][:optional] %><% if @nested_set[0] && @nested_set[0][:optional] %>
76
+ @<%= plural_name %> = <%= object_scope.gsub("@",'') %><%= n_plus_one_includes %>.page(params[:page])<%= ".per(per)" if @paginate_per_page_selector %><%= " if params.include?(:#{ @nested_set.last[:singular]}_id)" if @nested_set.any? && @nested_set[0] && @nested_set[0][:optional] %><% if @nested_set[0] && @nested_set[0][:optional] %>
74
77
  @<%= plural_name %> = <%= class_name %>.all<% end %><% else %>
75
- @<%= plural_name %> = <%= class_name %>.where(id: <%= auth_object.gsub("@",'') %>.id)<%= n_plus_one_includes %><% end %>
78
+ @<%= plural_name %> = <%= class_name %>.where(id: <%= auth_object.gsub("@",'') %>.id)<%= n_plus_one_includes %>.page(params[:page])<%= ".per(per)" if @paginate_per_page_selector %><% end %>
76
79
  <% end %>
77
80
  end
78
81
 
@@ -156,7 +159,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
156
159
  <% end %>
157
160
  modified_params = modify_date_inputs_on_params(<% if @update_show_only %>update_<% end %><%= singular_name %>_params.dup<%= controller_update_params_tap_away_alt_lookups %><%= controller_update_params_tap_away_magic_buttons %>, <%= current_user_object %>, <%= datetime_fields_list %>) <% if @object_owner_sym && eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>
158
161
  modified_params = modified_params.merge(<%= @object_owner_sym %>: <%= @object_owner_eval %>) <% elsif @object_owner_optional && any_nested? %>
159
- modified_params = modified_params.merge(<%= @object_owner_name %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}) <% elsif !@object_owner_eval.empty? %>
162
+ modified_params = modified_params.merge(<%= @object_owner_name %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}) <% elsif ! @object_owner_eval.empty? && !@self_auth%>
160
163
  modified_params = modified_params.merge(<%= @object_owner_eval %>) <% end %><% if !merge_lookups.empty? %>
161
164
  modified_params = modified_params.merge(<%= merge_lookups %>)
162
165
  <% end %>
@@ -51,6 +51,12 @@
51
51
  <%= @nested_set.collect{|arg| " .merge(defined?(#{arg[:singular]}) ? {#{arg[:singular]}: #{arg[:singular]}} : {})"}.join("\n") %>
52
52
  %>
53
53
  <\% end %>
54
+ <% if @paginate_per_page_selector %>
55
+ <\%= form_with url: things_path, method: :get do |f| %>
56
+ Show per page
57
+ <\%= f.collection_select "per", [10, 25, 100], :to_s, :to_s, {prompt: true, selected: params[:per]}, {onChange: "this.form.submit();"} %>
58
+ <\% end %>
59
+ <% end %>
54
60
  <%= @no_paginate ? "" : paginate %>
55
61
  <% end %>
56
62
  </div>
@@ -14,7 +14,7 @@ describe 'interaction for <%= controller_class_name %>' do
14
14
  <%= @existing_content %>
15
15
  <% unless @god %>let(:<%= @auth %>) {create(:<%= @auth.gsub('current_', '') %>)}<% end %>
16
16
  <%= spec_related_column_lets %>
17
- let!(:<%= singular %>1) {
17
+ <% unless @self_auth %> let!(:<%= singular %>1) {
18
18
  <%= singular %> = create(:<%= singular %><%= object_parent_mapping_as_argument_for_specs %> <%= item1_addOns %> )
19
19
  <%= @attachments.collect{ |attachment|
20
20
  " #{singular}.#{ attachment[0].to_s }.attach(
@@ -25,7 +25,7 @@ describe 'interaction for <%= controller_class_name %>' do
25
25
  %>
26
26
  <%=singular%>.save!
27
27
  <%=singular%>
28
- }
28
+ }<% end %>
29
29
  <%= objest_nest_factory_setup %> <% unless @god || (@existing_content && @existing_content.include?("login_as")) %>
30
30
  before do
31
31
  login_as(<%= @auth %>)
@@ -64,25 +64,25 @@ describe 'interaction for <%= controller_class_name %>' do
64
64
  describe "edit & update" do
65
65
  it "should return an editable form" do
66
66
  visit <%= path_helper_plural %>
67
- find("a.edit-<%= singular %>-button[href='/<%= namespace_with_slash %><%= plural %>/#{<%= singular %>1.id}/edit']").click
67
+ find("a.edit-<%= singular %>-button[href='/<%= namespace_with_slash %><%= plural %>/#{<%= factory_testing_name %>.id}/edit']").click
68
68
 
69
- expect(page).to have_content("Editing #{<%= singular %>1.<%= @display_class %>.squish || "(no name)"}")
69
+ expect(page).to have_content("Editing #{<%= factory_testing_name %>.<%= @display_class %>.squish || "(no name)"}")
70
70
  <%= capybara_make_updates(:update) %>
71
71
  click_button "Save"
72
- within("turbo-frame#<%= @namespace %>__#{dom_id(<%= singular %>1)} ") do
72
+ within("turbo-frame#<%= @namespace %>__#{dom_id(<%= factory_testing_name %>)} ") do
73
73
  <%= " " + @columns_map.map{ |col, col_object|
74
74
  if @attachments.keys.collect(&:to_sym).include?(col)
75
75
  elsif @show_only.include?(col)
76
76
  else
77
77
  col_object.spec_make_assertion
78
78
  end
79
- }.compact.join("\n ")
79
+ }.compact.join("\n ")
80
80
  %>
81
81
  end
82
82
  end
83
- end <% end %>
83
+ end <% end %><% if destroy_action %>
84
84
 
85
- <% unless @no_delete %> describe "destroy" do
85
+ describe "destroy" do
86
86
  it "should destroy" do
87
87
  visit <%= path_helper_plural %>
88
88
  accept_alert do
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.5.24'
3
+ CURRENT = '0.5.25'
4
4
  end
5
5
  end
data/script/test CHANGED
@@ -30,7 +30,9 @@ bin/rails generate hot_glue:scaffold Pet --gd
30
30
 
31
31
  bin/rails generate hot_glue:scaffold Human --gd
32
32
 
33
- #rails generate hot_glue:scaffold User --no-create --self-auth
33
+ bin/rails generate hot_glue:scaffold User --no-create --self-auth
34
+
35
+
34
36
  #rails generate hot_glue:scaffold Jkl --gd
35
37
  #rails generate hot_glue:scaffold Appointment --hawk=pets --gd
36
38
  #rails generate hot_glue:scaffold Family --gd
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hot-glue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.24
4
+ version: 0.5.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-07 00:00:00.000000000 Z
11
+ date: 2023-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -143,7 +143,7 @@ licenses:
143
143
  metadata:
144
144
  source_code_uri: https://github.com/hot-glue-for-rails/hot-glue
145
145
  homepage: https://heliosdev.shop/hot-glue
146
- funding: https://school.jasonfleetwoodboldt.com/8188
146
+ funding: https://school.jfbcodes.com/8188
147
147
  post_install_message: |
148
148
  ---------------------------------------------
149
149
  Welcome to Hot Glue - A Scaffold Building Companion for Hotwire + Turbo-Rails