hot-glue 0.5.24 → 0.5.26

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: 226e0b7e11441c4332105233fc63eb44f879d582c4ce791e18e56bd54de56627
4
+ data.tar.gz: a1befc9f7e6d059b502730f4d7411d7aab538b8a239572163e112d85a364d39a
5
5
  SHA512:
6
- metadata.gz: 94ae4da0d2644a6b6311f5b81da1f864ae90d4a69c133b4a3259ad53f0221ed10bfedfe4964dc7ceb04d65e2d6ef28c420af6b5489bae4ec22bb7989f6b0249a
7
- data.tar.gz: 9e0f23257368d5836f4a95c4f116f2d70057f063cce7ff14acecee0c2e7f62fd921e752d13fec73d073aa40ba6f89709a9efbb92a0c0f2bd823324a897cf93dd
6
+ metadata.gz: fb0ce5e6cf19d8528f3a7cdf421f4cdaf81a10c8670b132a6994ee178361e353b9ffba58de34bf14c8f422bae485bd4994c5c55a06240b2f0ab358419fd2660f
7
+ data.tar.gz: b9bc2326b8d1b8430e278a3fc9b74a6a198238fdfc015e21b37024761283f1dbb770b15e4a90bbf8bfebcb6acf5e110a704409e3a22093067fdd0d6ddd4ad4ff
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.26)
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.2)
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,44 @@ bin/rails generate Thing --include=my_story --modify='my_story{tinymce}'
1464
1469
 
1465
1470
  # VERSION HISTORY
1466
1471
 
1472
+
1473
+ #### 2023-10-23 - v0.5.26
1474
+
1475
+ Various fixes:
1476
+ - fixed alert (danger) classes for bootstrap 5 ('alert alert-danger' was just 'alert-danger')
1477
+ - switches to use a self-defined instance var @action instead of action_name; this is so I can
1478
+ switch it back to 'new' or 'edit' upon a failure re-display to have the view behave the expected way
1479
+ - fix in create.turbo_stream.erb for failure redisplay (was not working)
1480
+ - fixes syntax error (in generated code) in edit.erb when there was a nested set
1481
+
1482
+
1483
+ #### 2023-10-16 - v0.5.25
1484
+
1485
+ - Fixes scoping on Pundit-built controllers; even when using pundit we should still wrap to the current build's own ownership scope (#132
1486
+ - don't write to the nav file if we're building a nested controller (#134)
1487
+ - adds system specs for self-auth feature
1488
+ - Pagination Fixes:
1489
+
1490
+ 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.
1491
+
1492
+ 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.
1493
+
1494
+ 1. Replace the kaminari gem with my fork and regenerate your templates
1495
+ bundle remove kaminari
1496
+ bundle add kaminari --git="https://github.com/jasonfb/kaminari.git" --branch="master"
1497
+ bundle install
1498
+ rm -rf app/views/kaminari
1499
+ rails g kaminari:config
1500
+
1501
+
1502
+ 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.)
1503
+
1504
+
1505
+
1467
1506
  #### 2023-10-07 - v0.5.24
1468
1507
 
1469
1508
  - 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.
1509
+ 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
1510
  - 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
1511
  build. The start code maker has changed from `#HOTGLUE-SAVESTART` to `# HOTGLUE-SAVESTART`
1473
1512
  and the end code marker has changed from `#HOTGLUE-END` to `# HOTGLUE-END`. This now conforms to Rubocop.
@@ -1968,7 +2007,5 @@ To run only the internal specs, use
1968
2007
 
1969
2008
  `rspec spec`
1970
2009
 
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
-
2010
+ Internal Test coverage as of 2023-10-15 (v0.5.24)
2011
+ 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})")
@@ -111,7 +111,7 @@ class AssociationField < Field
111
111
  end
112
112
 
113
113
  def field_error_name
114
- name
114
+ assoc_name
115
115
  end
116
116
 
117
117
  def form_show_only_output
@@ -140,6 +140,6 @@ class AssociationField < Field
140
140
 
141
141
  display_column = HotGlue.derrive_reference_name(assoc_class.to_s)
142
142
 
143
- "<%= #{singular}.#{assoc}.try(:#{display_column}) || '<span class=\"content alert-danger\">MISSING</span>'.html_safe %>"
143
+ "<%= #{singular}.#{assoc}.try(:#{display_column}) || '<span class=\"content \">MISSING</span>'.html_safe %>"
144
144
  end
145
145
  end
@@ -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
@@ -38,7 +38,7 @@ class BooleanField < Field
38
38
 
39
39
  def form_field_display
40
40
  if display_boolean_as.nil?
41
- byebug
41
+
42
42
  end
43
43
  "<div class='#{@layout_strategy.form_checkbox_wrapper_class} #{'form-switch' if display_boolean_as == 'switch'}'>\n" +
44
44
  (if display_boolean_as == 'radio'
@@ -58,7 +58,7 @@ class BooleanField < Field
58
58
  def line_field_output
59
59
  if modify_binary?
60
60
  "<% if #{singular}.#{name}.nil? %>
61
- <span class='alert-danger'>MISSING</span>
61
+ <span class=''>MISSING</span>
62
62
  <% elsif #{singular}.#{name} %>
63
63
  #{modify_as[:binary][:truthy]}
64
64
  <% else %>
@@ -66,7 +66,7 @@ class BooleanField < Field
66
66
  <% end %>"
67
67
  else
68
68
  "<% if #{singular}.#{name}.nil? %>
69
- <span class='alert-danger'>MISSING</span>
69
+ <span class=''>MISSING</span>
70
70
  <% elsif #{singular}.#{name} %>
71
71
  YES
72
72
  <% else %>
@@ -17,7 +17,7 @@ class DateField < Field
17
17
  "<% unless #{singular}.#{name}.nil? %>
18
18
  <%= #{singular}.#{name} %>
19
19
  <% else %>
20
- <span class='alert-danger'>MISSING</span>
20
+ <span class=''>MISSING</span>
21
21
  <% end %>"
22
22
  end
23
23
  end
@@ -13,7 +13,7 @@ class DateTimeField < Field
13
13
  if !modify_binary?
14
14
  "expect(page).to have_content(new_#{name}.in_time_zone(testing_timezone).strftime('%m/%d/%Y @ %l:%M %p %Z').gsub(' ', ' '))"
15
15
  else
16
- "expect(page).to have_content('#{modify[:binary][:truthy]}'"
16
+ "expect(page).to have_content('#{modify_as[:binary][:truthy]}'"
17
17
  end
18
18
  end
19
19
 
@@ -23,7 +23,7 @@ class DateTimeField < Field
23
23
 
24
24
  def spec_list_view_assertion
25
25
  if modify_binary?
26
- "expect(page).to have_content('#{modify[:binary][:truthy]}')"
26
+ "expect(page).to have_content('#{modify_as[:binary][:truthy]}')"
27
27
  else
28
28
  spec_list_view_natural_assertion
29
29
  end
@@ -44,7 +44,7 @@ class DateTimeField < Field
44
44
  "<% unless #{singular}.#{name}.nil? %>
45
45
  <%= #{singular}.#{name}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p %Z') %>
46
46
  <% else %>
47
- <span class='alert-danger'>MISSING</span>
47
+ <span class=''>MISSING</span>
48
48
  <% end %>"
49
49
  end
50
50
  end
@@ -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
@@ -12,7 +12,7 @@ class TimeField < Field
12
12
  "<% unless #{singular}.#{name}.nil? %>
13
13
  <%= #{singular}.#{name}.in_time_zone(current_timezone).strftime('%l:%M %p ') %>
14
14
  <% else %>
15
- <span class='alert-danger'>MISSING</span>
15
+ <span class=''>MISSING</span>
16
16
  <% end %>"
17
17
  end
18
18
 
@@ -95,9 +95,9 @@ module HotGlue
95
95
  if show_only.include?(col)
96
96
  columns_map[col].form_show_only_output
97
97
  elsif update_show_only.include?(col) && !@pundit
98
- "<% if action_name == 'edit' %>" + columns_map[col].form_show_only_output + "<% else %>" + columns_map[col].form_field_output + "<% end %>"
98
+ "<% if @action == 'edit' %>" + columns_map[col].form_show_only_output + "<% else %>" + columns_map[col].form_field_output + "<% end %>"
99
99
  elsif update_show_only.include?(col) && @pundit && eval("defined? #{singular_class}Policy") && eval("#{singular_class}Policy").instance_methods.include?("#{col}_able?".to_sym)
100
- "<% if action_name == 'new' && policy(@#{singular}).#{col}_able? %>" + columns_map[col].form_field_output + "<% else %>" + columns_map[col].form_show_only_output + "<% end %>"
100
+ "<% if @action == 'new' && policy(@#{singular}).#{col}_able? %>" + columns_map[col].form_field_output + "<% else %>" + columns_map[col].form_show_only_output + "<% end %>"
101
101
 
102
102
  # show only on the update action overrides any pundit policy
103
103
  elsif @pundit && eval("defined? #{singular_class}Policy") && eval("#{singular_class}Policy").instance_methods.include?("#{col}_able?".to_sym)
@@ -108,7 +108,7 @@ module HotGlue
108
108
  # byebug
109
109
  @tinymce_stimulus_controller = (columns_map[col].modify_as == {tinymce: 1} ? "data-controller='tiny-mce' " : "")
110
110
 
111
- add_spaces_each_line( "\n <span #{@tinymce_stimulus_controller}class='<%= \"alert-danger\" if #{singular}.errors.details.keys.include?(:#{field_error_name}) %>' #{'style="display: inherit;"'} >\n" +
111
+ add_spaces_each_line( "\n <span #{@tinymce_stimulus_controller}class='<%= \"alert alert-danger\" if #{singular}.errors.details.keys.include?(:#{field_error_name}) %>' #{'style="display: inherit;"'} >\n" +
112
112
  add_spaces_each_line( (form_labels_position == 'before' ? the_label || "" : "") +
113
113
  + " <br />\n" + field_result +
114
114
  (form_labels_position == 'after' ? the_label : "") , 4) +
@@ -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
 
@@ -88,6 +91,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
88
91
  @<%= singular_name %> = <% if @pundit %>policy_scope(<% end %><%= class_name %><% if @pundit %>)<% end %>.new({}.merge(<%= @nested_set.last[:singular] %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}))<% else %>
89
92
  @<%= singular_name %> = <% if @pundit %>policy_scope(<% end %><%= class_name %><% if @pundit %>)<% end %>.new(<% if any_nested? %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)<% end %>
90
93
  <% if @pundit %>authorize @<%= singular_name %><% end %><% if @pundit %>
94
+ @action = "new"
91
95
  rescue Pundit::NotAuthorizedError
92
96
  flash[:alert] = "You are not authorized to perform this action."
93
97
  render :index<% end %>
@@ -116,6 +120,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
116
120
  render :create
117
121
  else
118
122
  flash[:alert] = "Oops, your <%= singular_name %> could not be created. #{@hawk_alarm}"
123
+ @action = "new"
119
124
  render :create, status: :unprocessable_entity
120
125
  end<% if @pundit %>
121
126
  rescue Pundit::NotAuthorizedError
@@ -136,6 +141,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
136
141
 
137
142
  def edit<% if @pundit %>
138
143
  authorize @<%= singular_name %><% end %>
144
+ @action = "edit"
139
145
  render :edit<% if @pundit %>
140
146
  rescue Pundit::NotAuthorizedError
141
147
  flash[:alert] = "Editing #{@<%= singular %>.<%= display_class %>} not authorized."
@@ -156,7 +162,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
156
162
  <% end %>
157
163
  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
164
  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? %>
165
+ modified_params = modified_params.merge(<%= @object_owner_name %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}) <% elsif ! @object_owner_eval.empty? && !@self_auth%>
160
166
  modified_params = modified_params.merge(<%= @object_owner_eval %>) <% end %><% if !merge_lookups.empty? %>
161
167
  modified_params = modified_params.merge(<%= merge_lookups %>)
162
168
  <% end %>
@@ -183,6 +189,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
183
189
  render :update
184
190
  else
185
191
  flash[:alert] = "<%= singular_name.titlecase %> could not be saved. #{@hawk_alarm}"
192
+ @action = "edit"
186
193
  render :update, status: :unprocessable_entity
187
194
  end<% if @pundit %>
188
195
  rescue Pundit::NotAuthorizedError
@@ -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>
@@ -4,7 +4,7 @@
4
4
  <\% end %>
5
5
  <\% end %>
6
6
  <%= turbo_parental_updates %>
7
- <\%= turbo_stream.replace "<%= @namespace %>__<%= singular %>__<%= singular %>-new" do %>
7
+ <\%= turbo_stream.replace "<%= @namespace %>__<%= singular %>-new" do %>
8
8
  <\% if @<%= singular %>.errors.none? %>
9
9
  <\%= render partial: "new_button", locals: {}<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {" + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> %>
10
10
  <\% else %>
@@ -4,7 +4,7 @@
4
4
  <div class="col-md-12">
5
5
  <\%= link_to "<% if @button_icons == 'font-awesome' %><i class='fa fa-arrow-circle-left 2x'></i><% end %> Back to list".html_safe, <%= path_helper_plural %> %>
6
6
  <% end %>
7
- <\%= render partial: "edit", locals: {<%= singular %>: @<%= singular %>} %>
7
+ <\%= render partial: "edit", locals: {<%= singular %>: @<%= singular %><%= @nested_set.collect{|arg| ", #{arg[:singular]}: @#{arg[:singular]}" }.join(", ") %>} %>
8
8
  <% if @big_edit %>
9
9
  </div>
10
10
  </div>
@@ -1,3 +1,3 @@
1
1
  <\%= turbo_stream.replace "<%= @namespace %>__#{dom_id(<%= singular %>)}" do %>
2
- <\%= render 'edit' %>
2
+ <\%= render 'edit', locals: {<%= singular %>: @<%= singular %><%= @nested_set.collect{|arg| ", #{arg[:singular]}: @#{arg[:singular]}} " }.join("") %> %>
3
3
  <\% end %>
@@ -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.26'
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.26
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-23 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