hot-glue 0.6.22 → 0.6.23

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: 0a92b0ee848c36d585691eefae1df23634e0814ad7d8e8b96a2d9dd7605c60d7
4
- data.tar.gz: ecbd2c67fb4a1a3665870178da7c92b6a10a11d336a8b953fed1ca49042ffb18
3
+ metadata.gz: 342a81dfd2a338859c929f72b0634b6458a8e6f07f037b6d7c22aba2c2259e9e
4
+ data.tar.gz: 138dab55e50cef822a4ae6c56c32dbb147d3941b65bb38e1a96c3eef1d11d6a5
5
5
  SHA512:
6
- metadata.gz: 045ef49863d103f17c889b6b0e8aa7a516faacb4b2b27a2b9bc5e6018d5113f89bfab29065d503bb277bb499afebcbf0592e57a3ef0ee1db61ca27ad2c5baa6a
7
- data.tar.gz: 8b6eb8ad573fa9d58c46018c46c055b4af97bd6ec3f7eb597d572ec1195346eb9c6504a0ea0423fa44e6b52dae4e02194ff14bf554b22d566124b5671e7b461d
6
+ metadata.gz: 29c0d4473cf36ebf0468b463d80ee19c98375b19085a21218f61d7986ac380b48b12acef8b229fa4884902c8d42f4efadc3668e280994c626f5ff6ddf8ae6d30
7
+ data.tar.gz: e851c22d5484a50a2135d8a6cf3a3e417c40c40af271880589a7513389b2513f9c3a4cef706657ceaf86a3d1204479726674f8feed0acf2b8accb429becf98b3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.6.21.2)
4
+ hot-glue (0.6.22)
5
5
  ffaker (~> 2.16)
6
6
  kaminari (~> 1.2)
7
7
  rails (> 5.1)
data/README.md CHANGED
@@ -852,7 +852,8 @@ Notice that each modifiers can be used with specific field types.
852
852
  | tinymce | applies to text fields only, be sure to setup TineMCE globally | text fields only | | |
853
853
  | typeahead | turns a foreign key (only) into a searchable typeahead field | foreign keys only | | |
854
854
  | timezone | turns a string (varchar) into a drop down of timezones | foreign keys only | | |
855
- | none | special modifier for using badges |
855
+ | include_blank | special modifier for association fields, adds include_blank to the created dropdown | |
856
+ | none | special modifier for using badges |
856
857
 
857
858
  Except for "(truthy label)" and "(falsy label)" which use the special syntax, use the modifier _exactly_ as it is named.
858
859
 
@@ -2145,15 +2146,75 @@ These automatic pickups for partials are detected at build time. This means that
2145
2146
 
2146
2147
  # VERSION HISTORY
2147
2148
 
2149
+ #### 2025-08-15 - v.0.6.23
2150
+
2151
+ • Lazy Lists: Important Breaking Change
2152
+
2153
+ All downnested portals now use Turbo's last list feature (frame with `src:` to load the subview via a separate request).
2154
+ The user sees "Loading" in the box as it is loading. (See `--downnest` and `--nested` sections.)
2155
+
2156
+ Unfortunately, this is a partially breaking change in that a parent & child should be rebuilt together on this version.
2157
+
2158
+ Whereas before the parent's edit template included the list and passed it the records to render immediately (in the same request)
2159
+
2160
+ ```
2161
+ <%= render partial: "agent_rules/list", locals: {agent: @agent, rules: @agent.rules} %>
2162
+
2163
+ ```
2164
+
2165
+ Now, we will render a new partial (from the child's build folder) at `lazy_list` (when the parent is rendering its children)
2166
+
2167
+ ```
2168
+ <%= render partial: "agent_rules/lazy_list", locals: {agent: @agent, ...
2169
+ ```
2170
+
2171
+ The `lazy_list` itself contains a turbo frame tag with an `src` set to the URL where the list can be loaded, appened with __lazy=1 to let the child controller know not to render the full layout.
2172
+
2173
+
2174
+ ```
2175
+ <%= tag.turbo_frame id: "__agents-list" + ((('__' + nested_for) if defined?(nested_for)) || ""),
2176
+ src: account_crusade_agents_path(account,crusade) + "?__lazy",
2177
+ loading: "lazy" do %>
2178
+
2179
+ ```
2180
+
2181
+ In the downnested controller, the children will now suppress the layout when loaded lazy
2182
+
2183
+ ```
2184
+ render layout: (params[:__lazy].present? ? false : true)
2185
+ ```
2186
+
2187
+ Just remember you must rebuild the parent if you rebuild a child, and you must rebuild ALL the children of any parent that is rebuilt.
2188
+
2189
+
2190
+ • Modify now has an `include_blank` option to add a blank option for associations
2191
+
2192
+
2193
+ `--modify-as=person_id{include_blank}`
2194
+
2195
+ Make sure your `belongs_to` association has `optional: true` or else you will get validation errors when you try to save a record with an empty association.
2196
+
2197
+
2198
+ • Fixes cancel button problems related to subviews (no longer necessary to load the edit of the parent in the lazy paradigm)
2199
+
2200
+ • Fixes double-entry redisplay problem (second create action would be saved but not show up in UI) due to malformed nested_for
2201
+
2202
+
2203
+
2148
2204
 
2149
2205
  #### 2025-07-28 v0.6.22
2150
2206
 
2207
+
2208
+
2209
+ #### 2025-07-05 v0.6.21
2210
+ •Now use new code insertion `--code-after-new` for code that happens directly after `.new()` call. use semicolon (`;`) to create linebreaks; no reason why the factories should insert flash messages
2211
+
2151
2212
  `--phantom-create-params`
2152
2213
  These parameters get added in the strong parameters safelist for the create action
2153
2214
 
2154
2215
  You'll probably wnat to use this along with --code-after-create to check that phanton param
2155
2216
 
2156
- TODO: you have to tap these away yourself
2217
+ TODO: you have to tap these away yourself
2157
2218
  TODO: can they be tapped away automatically if not using a factory
2158
2219
 
2159
2220
  `--phantom-update-params`
@@ -2182,7 +2243,7 @@ See "Polymorphic downnesting" in the downnesting section for an example.
2182
2243
 
2183
2244
  • Removes more vestiges of optionalized nesting (which I had implemented 3 years ago!)
2184
2245
 
2185
- I no longer like optionalized nesting, and recommend against it.
2246
+ I no longer like optionalized nesting, and recommend against it.
2186
2247
 
2187
2248
  Nesting should always be part of the structure, and every route should operate firmly in its nest path.
2188
2249
 
@@ -2190,11 +2251,6 @@ Use new controller-prefix to make on-off exceptions or with polymorphic children
2190
2251
 
2191
2252
  • Fixes for localized datetime & time inputs
2192
2253
 
2193
-
2194
-
2195
- #### 2025-07-05 v0.6.21
2196
- •Now use new code insertion `--code-after-new` for code that happens directly after `.new()` call. use semicolon (`;`) to create linebreaks; no reason why the factories should insert flash messages
2197
-
2198
2254
  • removes duplicitous flash messages in factory context
2199
2255
 
2200
2256
  • adds documentation for `--code-before-create`, `--code-after-create`, `--code-before-update`, `--code-after-update` (these features were already implemented)
@@ -154,8 +154,12 @@ class AssociationField < Field
154
154
 
155
155
 
156
156
 
157
+ if modify_as && modify_as[:include_blank]
158
+ include_blank = ", include_blank: true"
159
+ end
160
+
157
161
  (is_owner ? "<% unless @#{assoc_name} %>\n" : "") +
158
- " <%= f.collection_select(:#{name}, #{hawked_association}, :id, :#{display_column}, { prompt: true, selected: #{singular}.#{name} }, class: 'form-control'#{data_attr}) %>\n" +
162
+ " <%= f.collection_select(:#{name}, #{hawked_association}, :id, :#{display_column}, { prompt: true, selected: #{singular}.#{name}#{include_blank} }, class: 'form-control'#{data_attr}) %>\n" +
159
163
  (is_owner ? "<% else %>\n <%= @#{assoc_name}.#{display_column} %>" : "") +
160
164
  (is_owner ? "\n<% end %>" : "")
161
165
  end
@@ -31,7 +31,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
31
31
  :search_clear_button, :search_autosearch, :include_object_names,
32
32
  :stimmify, :stimmify_camel, :hidden_create, :hidden_update,
33
33
  :invisible_create, :invisible_update, :phantom_create_params,
34
- :phantom_update_params
34
+ :phantom_update_params, :lazy
35
35
  # important: using an attr_accessor called :namespace indirectly causes a conflict with Rails class_name method
36
36
  # so we use namespace_value instead
37
37
 
@@ -303,6 +303,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
303
303
  @modify_as[key.to_sym] = {typeahead: 1, nested: nested}
304
304
  elsif $2 == "timezone"
305
305
  @modify_as[key.to_sym] = {timezone: 1, badges: $3}
306
+ elsif $2 == "include_blank"
307
+ @modify_as[key.to_sym] = {include_blank: true}
306
308
  elsif $2 == "none"
307
309
  @modify_as[key.to_sym] = {none: 1, badges: $3}
308
310
  else
@@ -507,6 +509,10 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
507
509
  puts "NESTING: #{@nested_set}"
508
510
  end
509
511
 
512
+ if @nested_set.any?
513
+ @lazy = true
514
+ end
515
+
510
516
  # related_sets
511
517
  related_set_input = options['related_sets'].split(",")
512
518
  @related_sets = {}
@@ -587,6 +593,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
587
593
  setting =~ /(.*){(.*)}/
588
594
  key, lookup_as = $1, $2
589
595
 
596
+
597
+
590
598
  if !eval("#{class_name}.reflect_on_association(:#{key.to_s.gsub("_id","")})")
591
599
  raise "couldn't find association for #{key} in the object #{class_name}"
592
600
  end
@@ -1534,6 +1542,10 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1534
1542
  res -= %w{_list _line index}
1535
1543
  end
1536
1544
 
1545
+ if @lazy
1546
+ res << '_lazy_list'
1547
+ end
1548
+
1537
1549
  res
1538
1550
  end
1539
1551
 
@@ -86,6 +86,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
86
86
  authorize @<%= plural_name %><% elsif @pundit && @pundit_policy_override %>
87
87
  skip_authorization
88
88
  raise Pundit::NotAuthorizedError if ! <%= @pundit_policy_override %>.index?<% end %>
89
+ <% if @lazy %>render layout: (params[:__lazy].present? ? false : true)<% end %>
89
90
  rescue Pundit::NotAuthorizedError
90
91
  flash[:alert] = 'You are not authorized to perform this action.'
91
92
  render 'layouts/error'<% end %>
@@ -164,7 +165,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
164
165
  raise Pundit::NotAuthorizedError if ! <%= @pundit_policy_override %>.show?<% end %>
165
166
  redirect_to <%= HotGlue.optionalized_ternary(namespace: @namespace,
166
167
  target: @singular,
167
- top_level: false,
168
+ top_level: true,
168
169
  nested_set: @nested_set,
169
170
  modifier: 'edit_',
170
171
  with_params: true,
@@ -2,8 +2,7 @@
2
2
  <%= form_fields_html %>
3
3
 
4
4
  <div class="<%= @layout_strategy.column_classes_for_button_column %>">
5
- <\%= link_to "Cancel", <%=
6
- @nested_set.none? ? path_helper_plural : edit_parent_path_helper %>, {class: "btn btn-secondary"} %><% if @no_field_form %>
5
+ <\%= link_to "Cancel", <%= path_helper_plural %> + (params[:page] ? "?page=" + params[:page] : ""), {class: "btn btn-secondary"} %><% if @no_field_form %>
7
6
  <\%= f.hidden_field "_________" %><% end %>
8
7
  <\%= f.submit "Save", class: "btn btn-primary pull-right" %>
9
8
  </div>
@@ -0,0 +1,7 @@
1
+ <\%= tag.turbo_frame id: "<%= @namespace %>__<%= plural %>-list" <%= nested_for_turbo_id_list_constructor %>,
2
+ src: <%= path_helper_plural %> + "?__lazy",
3
+ loading: "lazy" do %>
4
+
5
+ <div class="text-muted">Loading ...</div>
6
+
7
+ <\% end %>
@@ -1,7 +1,5 @@
1
1
  <%= all_line_fields %>
2
2
 
3
-
4
-
5
3
  <% if @downnest_children.any? && ! @big_edit %>
6
4
  <% each_downnest_width = @downnest_children.count == 1 ? 33 : (53/@downnest_children.count).floor %>
7
5
  <% if @stacked_downnesting %><div class="<%= @layout_strategy.downnest_portal_stacked_column_width %> scaffold-downnest" ><% end %>
@@ -44,6 +42,6 @@
44
42
  <% end %>
45
43
 
46
44
  <% unless @no_edit %>
47
- <\%= link_to "Edit <% if @button_icons == 'font-awesome' %><i class='fa fa-1x fa-list-alt'></i><% end %>".html_safe, <%= edit_path_helper %>, <% if @big_edit %>'data-turbo' => 'false', <% end %>disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary btn-sm" %>
45
+ <\%= link_to "Edit <% if @button_icons == 'font-awesome' %><i class='fa fa-1x fa-list-alt'></i><% end %>".html_safe, <%= edit_path_helper %> + (params[:page] ? "?page=#{params[:page]}" : ""), <% if @big_edit %>'data-turbo' => 'false', <% end %>disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary btn-sm" %>
48
46
  <% end %>
49
47
  </div>
@@ -1,6 +1,6 @@
1
1
  <\% if @<%= singular %>.errors.none? %>
2
2
  <\%= turbo_stream.replace "<%= @namespace %>__<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
3
- <\%= render partial: "list", locals: {<%= plural %>: @<%= plural %><% if @nested_set.any? %>, <%= @nested_set.collect{|arg| "#{arg[:singular]}: @#{arg[:singular]}"}.join(", ") %>, nested_for: '<%= @nested_set.collect{|arg| "\"#{arg[:singular]}-\#{@#{arg[:singular]}.id}\""}.join("__") %>' <% end %> } %>
3
+ <\%= render partial: "list", locals: {<%= plural %>: @<%= plural %><% if @nested_set.any? %>, <%= @nested_set.collect{|arg| "#{arg[:singular]}: @#{arg[:singular]}"}.join(", ") %>, nested_for: "<%= @nested_set.collect{|arg| "#{arg[:singular]}-\#{@#{arg[:singular]}.id}"}.join("__") %>" <% end %> } %>
4
4
 
5
5
  <\% end %>
6
6
  <\% end %>
@@ -36,7 +36,8 @@
36
36
  <% downnest_object_name = downnest[:name] %>
37
37
  <% downnest_style = @layout_strategy.downnest_style %>
38
38
 
39
- <\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest_object_name %>/list", locals: {<%= @singular %>: @<%= @singular %>, <%= downnest[:polymorph_as] || downnest[:name] %>: @<%= @singular %>.<%= downnest[:polymorph_as] || downnest[:name] %><% if @nested_set.any? %>, <%= @nested_set.collect{|x| "#{x[:singular]}: @#{x[:singular]}"}.join(", ") %>, nested_for: "<%= @nested_set.collect{|x| "#{x[:singular]}-" + "\#{" + "@#{x[:singular]}.id}"}.join("__") %>__<%= singular %>-#{@<%= @singular %>.id}" <% end %> } \%>
39
+ <\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest_object_name %>/lazy_list", locals: {<%= @singular %>: @<%= @singular %>, <%= @nested_set.collect{|x| "#{x[:singular]}: @#{x[:singular]}"}.join(", ") %><%= @nested_set.any? ? "," : "" %> nested_for: "<%= (@nested_set).collect{|x| "#{x[:singular]}-" + "\#{" + "@#{x[:singular]}.id}"}.join("__") %><%= "__" if @nested_set.any? %><%= singular %>-#{@<%= @singular %>.id}" } \%>
40
+
40
41
  </div>
41
42
  <% end %>
42
43
  </div>
@@ -6,6 +6,7 @@
6
6
 
7
7
  <%= @layout_strategy.page_begin %>
8
8
  <\%= render partial: '<%= list_path_partial %>',
9
- locals: {<%= plural %>: @<%= plural %>}<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {nested_for: \"" + arg[:singular] + "-\#{@" + arg[:singular] + ".id}\"" + ", " + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> \%>
9
+ locals: {<%= plural %>: @<%= plural %> <% if @nested_set.any? %>, nested_for: "<%= @nested_set.collect{|n| "#{n[:singular]}-\#{@#{n[:singular]}.id}"}.join("__") %>", <%= @nested_set.collect{|n| "#{n[:singular]}: @#{n[:singular]}"}.join(", ") %><% end %>
10
+ } \%>
10
11
  <%= @layout_strategy.page_end %>
11
12
  </div>
data/lib/hot-glue.rb CHANGED
@@ -25,7 +25,7 @@ module HotGlue
25
25
  def self.optionalized_ternary(namespace: nil,
26
26
  target:,
27
27
  nested_set:,
28
- prefix: nil, # is this used
28
+ prefix: "", # is this used
29
29
  modifier: "",
30
30
  with_params: false,
31
31
  top_level: false,
@@ -35,33 +35,33 @@ module HotGlue
35
35
 
36
36
 
37
37
  if nested_set.nil? || nested_set.empty?
38
- return modifier + "#{(namespace + '_') if namespace}#{target}_path" + (("(#{instance_sym}#{target})" if put_form) || "")
39
- elsif nested_set[0][:optional] == false
38
+ return modifier + "#{(namespace + '_') if namespace}#{prefix}#{target}_path" + (("(#{instance_sym}#{target})" if put_form) || "")
40
39
 
40
+ else
41
41
  res = modifier + ((namespace + "_" if namespace) || "") + nested_set.collect{|x|
42
42
  x[:singular] + "_"
43
- }.join() + target + "_path" + (("(#{nested_set.collect{
43
+ }.join() + prefix + target + "_path" + (("(#{nested_set.collect{
44
44
  |x| instance_sym + x[:singular] }.join(",")
45
45
  }#{ put_form ? ',' + (instance_last_item ? "@" : instance_sym) + target : '' })") || "")
46
46
 
47
47
  res
48
-
49
- else
48
+ # else
49
+ # raise "optional nested set is deprecated"
50
50
  # copy the first item, make a ternery in this cycle, and recursively move to both the
51
51
  # is present path and the is optional path
52
52
 
53
- nonoptional = nested_set[0].dup
54
- nonoptional[:optional] = false
55
- rest_of_nest = nested_set[1..-1]
56
-
57
- is_present_path = HotGlue.optionalized_ternary(
58
- namespace: namespace,
59
- target: target,
60
- modifier: modifier,
61
- top_level: top_level,
62
- with_params: with_params,
63
- put_form: put_form,
64
- nested_set: [nonoptional, *rest_of_nest])
53
+ # nonoptional = nested_set[0].dup
54
+ # nonoptional[:optional] = false
55
+ # rest_of_nest = nested_set[1..-1]
56
+ #
57
+ # is_present_path = HotGlue.optionalized_ternary(
58
+ # namespace: namespace,
59
+ # target: target,
60
+ # modifier: modifier,
61
+ # top_level: top_level,
62
+ # with_params: with_params,
63
+ # put_form: put_form,
64
+ # nested_set: [nonoptional, *rest_of_nest])
65
65
 
66
66
  # is_missing_path = HotGlue.optionalized_ternary(
67
67
  # namespace: namespace,
@@ -72,7 +72,7 @@ module HotGlue
72
72
  # put_form: put_form,
73
73
  # nested_set: rest_of_nest )
74
74
  #
75
- return "#{is_present_path}"
75
+ # return "#{is_present_path}"
76
76
  end
77
77
  end
78
78
 
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.6.22'
3
+ CURRENT = '0.6.23'
4
4
  end
5
5
  end
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.22
4
+ version: 0.6.23
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: 2025-07-28 00:00:00.000000000 Z
11
+ date: 2025-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -115,6 +115,7 @@ files:
115
115
  - lib/generators/hot_glue/templates/erb/_edit.erb
116
116
  - lib/generators/hot_glue/templates/erb/_flash_notices.erb
117
117
  - lib/generators/hot_glue/templates/erb/_form.erb
118
+ - lib/generators/hot_glue/templates/erb/_lazy_list.erb
118
119
  - lib/generators/hot_glue/templates/erb/_line.erb
119
120
  - lib/generators/hot_glue/templates/erb/_list.erb
120
121
  - lib/generators/hot_glue/templates/erb/_nav.html.erb