hot-glue 0.6.3.2 → 0.6.3.3

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: 76d714abff8aa0f8fd8f763d80d281bfad48b73f22264721a65aa8c4113895cd
4
- data.tar.gz: c86b9c53e75cb794a9798ed3b112358c8ee6af2928c0d435486f2988a6fc5e38
3
+ metadata.gz: f7aeda073255d2be791a77dd97dac1176d2356020944d3dba448bf0c1b4e2008
4
+ data.tar.gz: 0a02c5f58d6a5a4bd77075cc568b2dfe8c1f7c8bb696622c029ba85a252664d5
5
5
  SHA512:
6
- metadata.gz: d794abf688a43ccd316547c35586938d6963c61e1194df2fd02efd434ab964f77f8eb5fba4f85a02f3d31ece2ad05a2282c1e31d07576048a3c4b88dbe1b62c3
7
- data.tar.gz: f1ebd911e9da38b7631ee357a1863ed7706d4cd016ce665c70bca088ba6d537bc3e0264ecd64c0e957ca8973766d91d8fd24e76f4dc5739911859813604ea3b0
6
+ metadata.gz: 67b004befc06d35faf3a3a2a03aa41eb10d895720386d872ba058071334eb5f9ebf8d7880861a2398700cd20fdc7224bcde7a7c7339c6f81b06fc8cf49a39276
7
+ data.tar.gz: 84885a474770d0c372df94755705bab8088f07734ac636536e3f400642053e9989059fb748cfa9e39e73221f7baac291316e8a1625743058b89536b3aca1eb86
data/.circleci/config.yml CHANGED
@@ -3,7 +3,7 @@ version: 2.1
3
3
 
4
4
  orbs:
5
5
  ruby: circleci/ruby@1.0
6
- browser-tools: circleci/browser-tools@1.4.4
6
+ browser-tools: circleci/browser-tools@1.4.8
7
7
 
8
8
  jobs:
9
9
  build:
@@ -48,13 +48,6 @@ jobs:
48
48
 
49
49
  steps:
50
50
  - run: sudo apt-get update
51
- - browser-tools/install-browser-tools:
52
- chrome-version: 116.0.5845.96 # TODO: remove when chromedriver downloads are fixed
53
- replace-existing-chrome: true
54
- - browser-tools/install-chrome:
55
- # TODO remove following line when fixed https://github.com/CircleCI-Public/browser-tools-orb/issues/90
56
- chrome-version: 116.0.5845.96
57
- replace-existing: true
58
51
 
59
52
  - browser-tools/install-chromedriver
60
53
  - checkout
data/README.md CHANGED
@@ -13,7 +13,9 @@ It will read your relationships and field types to generate your code for you, l
13
13
 
14
14
  By default, it generates code that gives users full control over objects they 'own' and by default it spits out functionality giving access to all fields. (Handily, Hot Glue leaves the command you used in a comment at the top of your generated controller so you can regenerate it again in the future.)
15
15
 
16
- Hot Glue generates functionality that is quick and dirty. It lets you be crafty. As with a real glue gun, use it with caution.
16
+ Alternatively, refinements allow you to scope records using custom access control or Pundit. Hot Glue scaffold comes with pagination by default and now has an option to add searching too.
17
+
18
+ Hot Glue generates quick and dirty functionality. It lets you be crafty. However, like with a real glue gun, please be sure to use it with caution.
17
19
 
18
20
  * Build plug-and-play scaffolding mixing generated ERB with the power of Hotwire and Turbo-Rails
19
21
  * Everything edits-in-place (unless you use `--big-edit`)
@@ -29,10 +31,10 @@ How is it different than Rails scaffolding?
29
31
 
30
32
  Although inspired by the Rails scaffold generators (built-in to Rails), Hot Glue does something similiar but has made opinionated decisions that deviate from the normal Rails scaffold:
31
33
 
32
- 1. The Hot Glue scaffolds are complete packages and pre-optimized for 'edit-in-place.' (the Rails scaffolding still generates views that make you flip between pages to do create/update operations)
34
+ 1. The Hot Glue scaffolds are complete packages and are pre-optimized for 'edit-in-place' so that new and edit operations happen in-page smoothly.
33
35
  2. Hot Glue does not create your models along with your scaffolding. Instead, create them first using `rails generate model X`
34
36
  3. Hot Glue *reads* the fields on your database *and* the relationships defined on your models. Unlike the Rails scaffolding you must add relationships and migrate your DB before building your scaffolding.
35
- 4. Hot Glue has many more features for building layouts quickly, like choosing which fields to include or exclude and how to lay them out on the page, for stitching together related objects (nesting and child portals), and more.
37
+ 4. Hot Glue has many more features for building layouts quickly, like choosing which fields to include or exclude and how to lay them out on the page, searching and scoping, related portals and nested sets, and applying modifiers (like currency or date format) and more.
36
38
 
37
39
  Other than the opinionated differences and additional features, Hot Glue produces code that is fundamentally very similiar and works consistent with the Rails 7 Hotwire & Turbo paradigms.
38
40
 
@@ -1585,7 +1587,7 @@ For example, to display the field `my_story` on the object `Thing`, you'd genera
1585
1587
  bin/rails generate Thing --include=my_story --modify='my_story{tinymce}'
1586
1588
  ```
1587
1589
 
1588
- ### Pickup Partial Includes for `_edit` and `_new` Screens
1590
+ ### Pickup Partials
1589
1591
 
1590
1592
  If you have a partial already in the view folder called `_edit_within_form.html.erb`, it with get included within the edit form.
1591
1593
  If you have a partial already in the view folder called `_new_within_form.html.erb`, it with get included within the new form.
@@ -1595,6 +1597,10 @@ These partials are good for including extra functionality in the form, like inte
1595
1597
  If you have a partial already in the view folder called `_edit_after_form.html.erb`, it with get included **_after_** the edit form.
1596
1598
  If you have a partial already in the view folder called `_new_after_form.html.erb`, it with get included **_after_** the new form.
1597
1599
  You can use any of the objects by local variable name (but you cannot use the form object `f` because it is not in scope.)
1600
+ If you have a partial already in your view folder called `_index_before_list`, it will be included above the list of records in the index view.
1601
+
1602
+ If you have a partial in your view folder called `_list_after_each_row`, it will be added after each row (be sure to include column divs)
1603
+ If you have a partial in your view folder called `_list_after_each_row_heading`, it will be added after the heading row above the list_after_each_row content (be sure to include column divs)
1598
1604
 
1599
1605
  The `within` partials should do operations within the form (like hidden fields), and the `after` partials should do entirely unrelated operations, like a different form entirely.
1600
1606
 
@@ -1606,6 +1612,27 @@ These automatic pickups for partials are detected at buildtime. This means that
1606
1612
 
1607
1613
  # VERSION HISTORY
1608
1614
 
1615
+ #### 2024-07-29 - v0.6.3.3
1616
+
1617
+ • Adds pickup partials for
1618
+ `_index_before_list`
1619
+ `_list_after_each_row`
1620
+ `_list_after_each_row_heading`
1621
+
1622
+ Remember, to use pickup partials these partials must exist in the build folder at the time you are building scaffolding.
1623
+
1624
+ • Fixes issue with Rails 7.1 when using `--no-edit` or `--no-delete` flags
1625
+ (Rails 7.1 enforces the presence of action names flagged with `only` on the before hook, which caused `The show action could not be found for the :load_charge callback...`)
1626
+
1627
+
1628
+
1629
+ #### 2024-01-28 - v0.6.3.2
1630
+ - corrects variables to be top-level in for nested merge in edit.erb; also adds new flag --display-edit-after-create used to direct to the edit page after the create action (#157)
1631
+ - code spacing tweeks
1632
+ - picks up all columns if no search fields specified
1633
+ - fixes top_level setting on edit.erb
1634
+
1635
+
1609
1636
  #### 2024-01-16 - v0.6.3.1
1610
1637
  Adds support for boolean modified datetime search; now, when using a modify= to turn a datetime into a boolean, the search box behaves appropriately and shows a 3-way radio picker: all, falsy, truthy.
1611
1638
  (Only implemented for datetime)
@@ -168,7 +168,7 @@ class AssociationField < Field
168
168
  data: { action: 'keyup->typeahead#fetchResults keydown->typeahead#navigateResults', typeahead_target: 'query' },
169
169
  autofocus: true,
170
170
  autocomplete: 'off',
171
- value: @q['0']['#{name}'] ? #{assoc.class_name}.find(@q['0']['#{name}']).try(:name) : \"\" %>
171
+ value: @q['0']['#{name}'].present? ? #{assoc.class_name}.find(@q['0']['#{name}']).try(:name) : \"\" %>
172
172
  <%= f.hidden_field \'q[0][#{name}]\', value: @q['0']['#{name}_search'].try(:id), 'data-typeahead-target': 'hiddenFormValue' %>
173
173
  <div data-typeahead-target='results'></div>
174
174
  <div data-typeahead-target='classIdentifier' data-id=\"typeahead--q_0_#{name}_search\"></div>
@@ -130,15 +130,26 @@ class Field
130
130
  end
131
131
 
132
132
  def modified_display_output
133
+ res = +''
133
134
  if modify_as[:cast] && modify_as[:cast] == "$"
134
- "<%= number_to_currency(#{singular}.#{name}) %>"
135
+ res += "<%= number_to_currency(#{singular}.#{name}) %>"
135
136
  elsif modify_as[:binary]
136
- "<%= #{singular}.#{name} ? '#{modify_as[:binary][:truthy]}' : '#{modify_as[:binary][:falsy]}' %>"
137
+ res += "<%= #{singular}.#{name} ? '#{modify_as[:binary][:truthy]}' : '#{modify_as[:binary][:falsy]}' %>"
137
138
  elsif modify_as[:tinymce]
138
139
 
139
140
  elsif modify_as[:enum]
140
- "<%= render partial: #{singular}.#{name}, locals: {#{singular}: #{singular}} %>"
141
+ res += "<%= render partial: #{singular}.#{name}, locals: {#{singular}: #{singular}} %>"
141
142
  end
143
+
144
+ if modify_as[:badges]
145
+ badge_code = if modify_as[:binary]
146
+ "#{singular}.#{name} ? '#{modify_as[:badges].split("|")[0]}' : '#{modify_as[:badges].split("|")[1]}'"
147
+ else
148
+ modify_as[:badges].split("|").to_s + "[#{singular}.#{name}]"
149
+ end
150
+ res = "<span class='badge <%= #{badge_code} %>'>" + res + "</span>"
151
+ end
152
+
142
153
  end
143
154
 
144
155
  def field_output(type = nil, width )
@@ -29,6 +29,6 @@ class FloatField < Field
29
29
  end
30
30
 
31
31
  def load_all_query_statement
32
-
33
- end
32
+ raise "Float field search not implemented"
33
+ end
34
34
  end
@@ -27,4 +27,8 @@ class IntegerField < Field
27
27
  def form_field_output
28
28
  " <%= f.text_field :#{name}, value: #{singular}.#{name}, autocomplete: 'off', size: 4, class: 'form-control', type: 'number'" + (form_placeholder_labels ? ", placeholder: '#{name.to_s.humanize}'" : "") + " %>\n " + "\n"
29
29
  end
30
+
31
+ def search_field_output
32
+ raise "Integer search not implemented"
33
+ end
30
34
  end
@@ -33,5 +33,13 @@ module LayoutStrategy
33
33
  def form_checkbox_input_class; ""; end
34
34
  def form_checkbox_label_class; ""; end
35
35
  def form_checkbox_wrapper_class; ""; end
36
+
37
+ def search_opening
38
+ ""
39
+ end
40
+
41
+ def search_closing
42
+ ""
43
+ end
36
44
  end
37
45
  end
@@ -68,4 +68,12 @@ class LayoutStrategy::Bootstrap < LayoutStrategy::Base
68
68
  def form_checkbox_label_class
69
69
  "form-check-label"
70
70
  end
71
+
72
+ def search_opening
73
+ '<div class="row"><div class="col-md-12 card"><div class="card-body">'
74
+ end
75
+
76
+ def search_closing
77
+ "</div></div></div>"
78
+ end
71
79
  end
@@ -59,6 +59,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
59
59
  class_option :magic_buttons, type: :string, default: nil
60
60
  class_option :small_buttons, type: :boolean, default: nil
61
61
  class_option :display_list_after_update, type: :boolean, default: false
62
+ class_option :display_edit_after_create, type: :boolean, default: false
63
+ class_option :new_in_modal, type: :boolean, default: false
62
64
  class_option :smart_layout, type: :boolean, default: false
63
65
  class_option :markup, type: :string, default: nil # deprecated -- use in app config instead
64
66
  class_option :layout, type: :string, default: nil # if used here it will override what is in the config
@@ -234,25 +236,28 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
234
236
 
235
237
  @modify_as = {}
236
238
  if !options['modify'].empty?
237
-
238
239
  modify_input = options['modify'].split(",")
239
240
  modify_input.each do |setting|
240
- setting =~ /(.*){(.*)}/
241
- key, lookup_as = $1, $2
242
-
241
+ if setting.include?("[")
242
+ setting =~ /(.*){(.*)}\[(.*)\]/
243
+ key, lookup_as = $1, $2, $3
244
+ else
245
+ setting =~ /(.*){(.*)}/
246
+ key, lookup_as = $1, $2
247
+ end
243
248
  if ["$"].include?($2)
244
- @modify_as[key.to_sym] = {cast: $2}
249
+ @modify_as[key.to_sym] = {cast: $2, badges: $3}
245
250
  elsif $2.include?("|")
246
251
  binary = $2.split("|")
247
- @modify_as[key.to_sym] = {binary: {truthy: binary[0], falsy: binary[1]}}
252
+ @modify_as[key.to_sym] = {binary: {truthy: binary[0],
253
+ falsy: binary[1]},
254
+ badges: $3}
248
255
  elsif $2 == "partial"
249
- @modify_as[key.to_sym] = {enum: :partials}
256
+ @modify_as[key.to_sym] = {enum: :partials, badges: $3 }
250
257
  elsif $2 == "tinymce"
251
- @modify_as[key.to_sym] = {tinymce: 1}
258
+ @modify_as[key.to_sym] = {tinymce: 1, badges: $3}
252
259
  elsif $2 == "typeahead"
253
- @modify_as[key.to_sym] = {typeahead: 1}
254
-
255
-
260
+ @modify_as[key.to_sym] = {typeahead: 1, badges: $3}
256
261
  else
257
262
  raise "unknown modification direction #{$2}"
258
263
  end
@@ -320,6 +325,9 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
320
325
  @stacked_downnesting = options['stacked_downnesting']
321
326
 
322
327
  @display_list_after_update = options['display_list_after_update'] || false
328
+ @display_edit_after_create = options['display_edit_after_create'] || false
329
+ @new_in_modal = options['new_in_modal'] || false
330
+
323
331
  @smart_layout = options['smart_layout']
324
332
 
325
333
  @pundit = options['pundit']
@@ -512,7 +520,11 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
512
520
  # search
513
521
  @search = options['search']
514
522
  if @search == 'set'
515
- @search_fields = options['search_fields'].split(',') || @columns
523
+ if options['search_fields'].nil?
524
+ @search_fields = @columns
525
+ else
526
+ @search_fields = options['search_fields'].split(',')
527
+ end
516
528
 
517
529
  # within the set search we will take out any fields on the query list
518
530
  # or the field
@@ -793,8 +805,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
793
805
  res = +"begin
794
806
  #{@factory_creation}
795
807
  "
796
- res << "\n" + "@#{singular} = factory.#{singular}" unless res.include?("@#{singular} = factory.#{singular}")
797
- res << "flash[:notice] = \"Successfully created \#{@#{singular}.name}\" unless @#{singular}.new_record?
808
+ res << "\n " + "@#{singular} = factory.#{singular}" unless res.include?("@#{singular} = factory.#{singular}")
809
+ res << "\n flash[:notice] = \"Successfully created \#{@#{singular}.name}\" unless @#{singular}.new_record?
798
810
  rescue ActiveRecord::RecordInvalid
799
811
  @#{singular} = factory.#{singular}
800
812
  flash[:alert] = \"Oops, your #{singular} could not be created. #{@hawk_alarm}\"
@@ -978,10 +990,11 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
978
990
  end
979
991
  end
980
992
 
981
- def path_helper_plural
993
+ def path_helper_plural(top_level = false)
982
994
  HotGlue.optionalized_ternary(namespace: @namespace,
983
995
  target: @controller_build_folder,
984
- nested_set: @nested_set)
996
+ nested_set: @nested_set,
997
+ top_level: top_level)
985
998
  end
986
999
 
987
1000
  def datetime_fields_list
@@ -1165,7 +1178,9 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1165
1178
  @edit_after_form_partial = File.exist?("#{filepath_prefix}app/views#{namespace_with_dash}/#{@controller_build_folder}/_edit_within_form.html.#{@markup}")
1166
1179
  @new_within_form_partial = File.exist?("#{filepath_prefix}app/views#{namespace_with_dash}/#{@controller_build_folder}/_new_within_form.html.#{@markup}")
1167
1180
  @new_after_form_partial = File.exist?("#{filepath_prefix}app/views#{namespace_with_dash}/#{@controller_build_folder}/_new_within_form.html.#{@markup}")
1168
-
1181
+ @index_before_list_partial = File.exist?("#{filepath_prefix}app/views#{namespace_with_dash}/#{@controller_build_folder}/_index_before_list.html.#{@markup}")
1182
+ @list_after_each_row_partial = File.exist?("#{filepath_prefix}app/views#{namespace_with_dash}/#{@controller_build_folder}/_list_after_each_row.html.#{@markup}")
1183
+ @list_after_each_row_heading_partial = File.exist?("#{filepath_prefix}app/views#{namespace_with_dash}/#{@controller_build_folder}/_list_after_each_row_heading.html.#{@markup}")
1169
1184
  if @no_controller
1170
1185
  File.write("#{Rails.root}/app/views/#{namespace_with_trailing_dash}/#{plural}/REGENERATE.md", regenerate_me_code)
1171
1186
  end
@@ -1174,7 +1189,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1174
1189
  formats.each do |format|
1175
1190
  source_filename = cc_filename_with_extensions("#{@markup}/#{view}", "#{@markup}")
1176
1191
  dest_filename = cc_filename_with_extensions("#{view}", "#{@markup}")
1177
-
1192
+ # byebug
1178
1193
  dest_filepath = File.join("#{filepath_prefix}app/views#{namespace_with_dash}",
1179
1194
  @controller_build_folder, dest_filename)
1180
1195
 
@@ -1513,10 +1528,12 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1513
1528
 
1514
1529
  def post_action_parental_updates
1515
1530
  if @nested_set.any?
1516
- "\n" + @nested_set.collect { |data|
1531
+ @nested_set.collect { |data|
1517
1532
  parent = data[:singular]
1518
1533
  "@#{singular}.#{parent}.reload"
1519
- }.join("\n")
1534
+ }
1535
+ else
1536
+ []
1520
1537
  end
1521
1538
  end
1522
1539
 
@@ -22,9 +22,9 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
22
22
 
23
23
  nest_chain << arg %>
24
24
  before_action :<%= arg[:singular] %><%= ", if: -> { params.include?(:#{arg[:singular]}_id) }" if arg[:optional] %><% } %><% end %>
25
- before_action :load_<%= singular_name %>, only: %i[show edit update destroy]
26
- after_action -> { flash.discard }, if: -> { request.format.symbol == :turbo_stream }
27
- <% if @nested_set.any? %>def <%= @nested_set[0][:singular] %><% if @god
25
+ before_action :load_<%= singular_name %>, only: %i[<%= "show edit update" unless @no_edit %> <%= "destroy" unless @no_delete %>]
26
+ after_action -> { flash.discard }, if: -> { request.format.symbol == :turbo_stream }<% if @nested_set.any? %>
27
+ def <%= @nested_set[0][:singular] %><% if @god
28
28
  next_object = nil
29
29
  collect_objects = @nested_set.reverse.collect {|x|
30
30
  if eval("#{next_object || class_name}.reflect_on_association(:#{x[:singular]})").nil?
@@ -54,7 +54,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
54
54
  this_scope = "#{nest_chain.last}.#{arg[:plural]}"
55
55
  nest_chain << arg[:singular] %>
56
56
  def <%= arg[:singular] %>
57
- @<%= arg[:singular] %> ||= (<%= this_scope; %>.find(params[:<%= arg[:singular] %>_id]) <%= " if params.include?(:#{last_arg[:singular]}_id)" if last_arg && @god && last_arg[:optional] %>)
57
+ @<%= arg[:singular] %> ||= (<%= this_scope; %>.find(params[:<%= arg[:singular] %>_id]) <%= " if params.include?(:#{last_arg[:singular]}_id)" if last_arg && @god && last_arg[:optional] %>)
58
58
  <% if @god && last_arg && (last_arg[:optional] ) %>@<%= arg[:singular] %> ||= (<%= collect_objects[index-1] %>.find(params[:<%= arg[:singular] %>_id]) if params.include?(:<%= arg[:singular] %>_id) ) <% end %>
59
59
  end<% end %><% end %>
60
60
  <% if !@self_auth %>
@@ -73,10 +73,9 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
73
73
  end<% end %>
74
74
  <% unless @no_list %>
75
75
  def load_all_<%= plural %>
76
- <%= load_all_code %>
77
- end
76
+ <%= load_all_code %> end
78
77
 
79
- def index <% if @search == "set" %>
78
+ def index<% if @search == "set" %>
80
79
  @q = params[:q] || <%= {"0" => @search_fields.collect{|foo|
81
80
  {"#{foo}_match".to_sym => ((@columns_map[foo.to_sym].modify_as && @columns_map[foo.to_sym].modify_as[:binary]) ? "-1" : ""), "#{foo}_search".to_sym => ""}}.reduce({}, :merge) } %> <% end %><% if @search_fields %>
82
81
  <%= @search_fields.collect{|field_name| @columns_map[field_name.to_sym].code_to_reset_match_if_search_is_blank}.compact.join(" \n") %><% end %>
@@ -100,7 +99,6 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
100
99
  end
101
100
 
102
101
  def create
103
- flash[:alert] = +''
104
102
  flash[:notice] = +''
105
103
  modified_params = modify_date_inputs_on_params(<%= singular_name %>_params.dup, <%= current_user_object %>, <%= datetime_fields_list %>)<% if @object_owner_sym && eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>
106
104
  modified_params = modified_params.merge(<%= @object_owner_sym %>: <%= @object_owner_eval %>) <% elsif @object_owner_optional && any_nested? %>
@@ -116,13 +114,19 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
116
114
  <%= @code_before_create ? "\n " + @code_before_create.gsub(";", "\n") : "" %>
117
115
  if @<%= singular_name %>.save<%= @code_after_create ? ("\n " + @code_after_create.gsub(";", "\n")) : ""%>
118
116
  flash[:notice] = "Successfully created #{@<%= singular %>.<%= display_class %>}"
119
- <%= post_action_parental_updates %>
117
+ <%= post_action_parental_updates.join("\n ") %>
120
118
  load_all_<%= plural %>
121
- render :create
119
+ <% unless @display_edit_after_create %>render :create<% else %>redirect_to <%= HotGlue.optionalized_ternary(namespace: @namespace,
120
+ top_level: true,
121
+ target: @singular,
122
+ nested_set: @nested_set,
123
+ modifier: 'edit_',
124
+ with_params: true,
125
+ put_form: true).gsub("(#{singular}", "(@#{singular}") %><% end %>
122
126
  else
123
127
  flash[:alert] = "Oops, your <%= singular_name %> could not be created. #{@hawk_alarm}"
124
128
  @action = 'new'
125
- render :create, status: :unprocessable_entity
129
+ <% unless @display_edit_after_create %>render :create, status: :unprocessable_entity<% else %>render :new , status: :unprocessable_entity<% end %>
126
130
  end<% if @pundit %>
127
131
  rescue Pundit::NotAuthorizedError => e
128
132
  @user.errors.add(:base, e.message)
@@ -131,8 +135,8 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
131
135
 
132
136
  <% end %>
133
137
  <% unless @no_edit %>
134
- def show
135
- <% if @pundit %>authorize @<%= singular %><% end %>
138
+ def show<% if @pundit %>
139
+ authorize @<%= singular %><% end %>
136
140
  redirect_to <%= HotGlue.optionalized_ternary(namespace: @namespace,
137
141
  target: @singular,
138
142
  nested_set: @nested_set,
@@ -146,7 +150,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
146
150
  @action = 'edit'
147
151
  render :edit<% if @pundit %>
148
152
  rescue Pundit::NotAuthorizedError
149
- flash[:alert] = "Editing #{@<%= singular %>.<%= display_class %>} not authorized."
153
+ flash[:notice] = "Editing #{@<%= singular %>.<%= display_class %>} not authorized."
150
154
  render :index <% end %>
151
155
  end
152
156
 
@@ -199,7 +203,8 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
199
203
  flash[:notice] = '<%= singular_name.titlecase %> successfully deleted'
200
204
  rescue StandardError => e
201
205
  flash[:alert] = '<%= singular_name.titlecase %> could not be deleted'
202
- end <%= post_action_parental_updates %>
206
+ end
207
+ <%= post_action_parental_updates.join("\n ") %>
203
208
  load_all_<%= plural %><% if @pundit %>
204
209
  rescue Pundit::NotAuthorizedError
205
210
  flash[:alert] = "Deleting #{@<%= singular_name %>.<%= display_class %>} not authorized. "
@@ -36,19 +36,17 @@
36
36
  <% end %>
37
37
  <% end %>
38
38
 
39
+ <% if @list_after_each_row_heading_partial %><\%= render partial: "list_after_each_row_heading" %><% end %>
40
+
39
41
  <div class=' scaffold-col-heading scaffold-col-heading-buttons <%= @layout_strategy.column_classes_for_column_headings %>' <%= @layout_strategy.button_column_style %>>
40
42
  </div>
41
43
  </div>
42
44
  <% end %>
43
-
44
45
  <% if @search %>
45
- <div class="card">
46
- <div class="card-body">
47
- <%= @template_builder.search_input_area %>
48
- </div>
49
- </div>
46
+ <%= @layout_strategy.search_opening %>
47
+ <%= @template_builder.search_input_area %>
48
+ <%= @layout_strategy.search_closing %>
50
49
  <% end %>
51
-
52
50
  <\% if <%= plural %>.empty? %>
53
51
  <div>
54
52
  None
@@ -2,7 +2,7 @@
2
2
  <h3>
3
3
  <%= @new_form_heading %>
4
4
  </h3>
5
- <\%= form_with model: <%= singular %>, url: <%= form_path_new_helper %>, method: :post do |f| \%>
5
+ <\%= form_with model: <%= singular %>, url: <%= form_path_new_helper %>, method: :post<%= @display_edit_after_create ? ", html: {'data-turbo': false}" : "" %> do |f| \%>
6
6
  <\%= render partial: "<%= namespace_with_slash + @controller_build_folder %>/form",
7
7
  locals: { <%= singular %>: <%= singular %>, f: f}<%= @nested_set.collect{|arg| ".merge(defined?(#{arg[:singular]}) ? {#{arg[:singular]}: #{arg[:singular]}}: {})" }.join %> \%>
8
8
 
@@ -24,6 +24,9 @@
24
24
  <% if @stacked_downnesting %></div><% end %>
25
25
  <% end %>
26
26
 
27
+
28
+ <% if @list_after_each_row_partial %><\%= render partial: "list_after_each_row", locals: {<%= @singular %>: <%= @singular %>} %> <% end %>
29
+
27
30
  <%= @layout_strategy.button_style %>
28
31
  <div class=" scaffold-line-buttons <%= @layout_strategy.column_classes_for_button_column %>" <%= @layout_strategy.button_style %>>
29
32
  <%= magic_button_output %>
@@ -2,7 +2,7 @@
2
2
  <div class="container">
3
3
  <div class="row">
4
4
  <div class="col-md-12">
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 %> %>
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(true) %> %>
6
6
  <% end %>
7
7
  <\%= render partial: "edit", locals: {<%= singular %>: @<%= singular %><%= @nested_set.collect{|arg| ", #{arg[:singular]}: @#{arg[:singular]}" }.join(", ") %>} %>
8
8
  <% if @big_edit %>
@@ -26,7 +26,7 @@
26
26
  <%= downnest_object_name %>: @<%= @singular %>.<%= downnest %>
27
27
  }
28
28
  .merge({nested_for: "<% if @nested_set.any? %>#{nested_for + "__" if defined?(nested_for)}<% end %><%= @singular %>-#{@<%= @singular %>.id}"})
29
- <%= @nested_set.collect{|arg| ".merge(defined?(#{arg[:singular]}) ? {#{arg[:singular]}: #{arg[:singular]}} : {} )"}.join("\n") %>
29
+ <%= @nested_set.collect{|arg| ".merge(defined?(@#{arg[:singular]}) ? {#{arg[:singular]}: @#{arg[:singular]}} : {} )"}.join("\n") %>
30
30
  \%>
31
31
 
32
32
  </div>
@@ -1,11 +1,11 @@
1
1
  <% if @menu_file_exists %><\%= render partial: "<%= namespace_with_trailing_dash %>menu", locals: {active: '<%= plural %>'} %><% end %>
2
2
 
3
3
  <div class="<%= @container_name %>">
4
- <%= @layout_strategy.page_begin %>
5
- <% if include_nav_template %><\%= render partial: "<%= nav_template %>", locals: {nav: "<%= @plural %>"} %><% end %>
4
+ <% if include_nav_template %><%= @layout_strategy.page_begin %><\%= render partial: "<%= nav_template %>", locals: {nav: "<%= @plural %>"} %><%= @layout_strategy.page_end %><% end %>
5
+ <% if @index_before_list_partial %><\%= render partial: "index_before_list" %><% end %>
6
6
 
7
+ <%= @layout_strategy.page_begin %>
7
8
  <\%= render partial: '<%= list_path_partial %>',
8
9
  locals: {<%= plural %>: @<%= plural %>}<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {nested_for: \"" + arg[:singular] + "-\#{@" + arg[:singular] + ".id}\"" + ", " + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> \%>
9
-
10
10
  <%= @layout_strategy.page_end %>
11
11
  </div>
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.6.3.2'
3
+ CURRENT = '0.6.3.3'
4
4
  end
5
5
  end
data/script/test CHANGED
@@ -30,7 +30,22 @@ bin/rails generate hot_glue:scaffold Pet --gd
30
30
 
31
31
  bin/rails generate hot_glue:scaffold Human --gd
32
32
 
33
- bin/rails generate hot_glue:scaffold User --no-create --self-auth
33
+
34
+ # why is only this one failing on CI
35
+
36
+
37
+ #
38
+ # 1) interaction for UsersController edit & update should return an editable form
39
+ # Failure/Error: find("a.edit-user-button[href='/users/#{current_user.id}/edit']").click
40
+ #
41
+ # Capybara::ElementNotFound:
42
+ # Unable to find css "a.edit-user-button[href='/users/14/edit']"
43
+ # # ./spec/features/users_behavior_spec.rb:31:in `block (3 levels) in <top (required)>'
44
+ #
45
+ #Finished in 10.76 seconds (files took 2.69 seconds to load)
46
+ #26 examples, 1 failure
47
+
48
+ #bin/rails generate hot_glue:scaffold User --no-create --self-auth
34
49
 
35
50
 
36
51
  #rails generate hot_glue:scaffold Jkl --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.6.3.2
4
+ version: 0.6.3.3
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: 2024-01-18 00:00:00.000000000 Z
11
+ date: 2024-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  - !ruby/object:Gem::Version
177
177
  version: '0'
178
178
  requirements: []
179
- rubygems_version: 3.4.10
179
+ rubygems_version: 3.5.7
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: A gem to build Turbo Rails scaffolding.