hot-glue 0.7 → 0.7.1

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: c823d274b52531414bbf843d1f44ccd364400ab9c736405a74b1cc5793774b48
4
- data.tar.gz: 52d175d729d5b57c063da43bb7b7cb2940ea334be16e99637ade700ddaa2593a
3
+ metadata.gz: 62c0a8b7999c39d4d93ece238d6447baa2ecdf34613d9fb11b5fe49842919424
4
+ data.tar.gz: c0a2d741d113fe2d3a366b5f33f110fc5aa8956a1b52af7ea2deb56085e76a4b
5
5
  SHA512:
6
- metadata.gz: a1c8b8309b61f0ddbb1f27ca3a73bde4e8349f13fb114c6f3f5dcc15343dcc597fa4fbdd11476c1456d38c772cfe29b61d7ca4bee7d79ad421592227cf305d49
7
- data.tar.gz: 9b915be8972458f2fee1163e00c9f6c58a6ddf74ec829da2449989f3a5640597d16efb93c5ede4ea449bc786714997f511d3830a584029ff33222c6cef4d626e
6
+ metadata.gz: dd02b7553a585535eb7eb2ac195ce55eb0192151edccfb41cb9f3b4c8110ed125096200bbe3442cdc79dbb27db48cc0b8a10fdbc3366c9c0371f7ba46dc3684f
7
+ data.tar.gz: 235257f2f9150c0ac038fd7b11d4ac0551d4a224213e5cf244311ed43ca4cbdc02e25bf6427090213e30abde0de7289a0b01b887e265f0e2496a63c9fc9b12e0
data/README.md CHANGED
@@ -1717,6 +1717,7 @@ This is a good place to set your created_by user id, like so
1717
1717
 
1718
1718
 
1719
1719
 
1720
+
1720
1721
  ```
1721
1722
  def new
1722
1723
  @email_template = EmailTemplate.new(crusade: crusade)
@@ -1748,6 +1749,16 @@ def create
1748
1749
  ```
1749
1750
  TODO: build a solution for inserting code only in the `new` action but NOT the create action
1750
1751
 
1752
+ #### `--code-in-controller=''` (escape newlines with `;` )
1753
+
1754
+ This code will be inserted directly into your controller (as a class-level definition)
1755
+
1756
+
1757
+ ```
1758
+ --code-in-controller="before_action -> { @thing = 'abc' }"
1759
+ ```
1760
+ A one-liner hook works well for these. if you define an entire method, be sure to use `;` to separate line breaks
1761
+
1751
1762
 
1752
1763
 
1753
1764
  ## Searching
@@ -2409,6 +2420,16 @@ These automatic pickups for partials are detected at build time. This means that
2409
2420
 
2410
2421
  # VERSION HISTORY
2411
2422
 
2423
+ #### 2025-11-12 - v0.7.1
2424
+ - in set searches, automatically sets the match field if the search text is input, removes match field (back to default) when search text is removed;
2425
+ -
2426
+ - also removes search text if you change the match selector back to empty
2427
+ -
2428
+ - removes vestiges of `.merge` from old implementation (#236)
2429
+
2430
+ - `--code-in-controller` option for inserting controller code directly into your controller
2431
+
2432
+
2412
2433
  #### 2025-11-05 - v0.7
2413
2434
 
2414
2435
  Hot Glue already has a robust set of tools to provide field-by-field access control, hiding or turning visible-only fields by multiple methods, described under Access Control & Field Visibility Features.
@@ -49,8 +49,8 @@ class StringField < Field
49
49
  end
50
50
 
51
51
  def search_field_output
52
- "<%= f.select 'q[0][#{name}_match]', options_for_select([['', ''], ['contains', 'contains'], ['is exactly', 'is_exactly'], ['starts with', 'starts_with'], ['ends with', 'ends_with']], @q[\'0\']['#{name}_match'] ), {} , { class: 'form-control match' } %>"+
53
- "<%= f.text_field 'q[0][#{name}_search]', value: @q[\'0\'][:#{name}_search], autocomplete: 'off', size: 40, class: 'form-control', type: 'text' %>"
52
+ "<%= f.select 'q[0][#{name}_match]', options_for_select([['', ''], ['contains', 'contains'], ['is exactly', 'is_exactly'], ['starts with', 'starts_with'], ['ends with', 'ends_with']], @q[\'0\']['#{name}_match'] ), {} , { class: 'form-control match' , 'data-search-form-target': \"textMatch\"} %>"+
53
+ "<%= f.text_field 'q[0][#{name}_search]', value: @q[\'0\'][:#{name}_search], autocomplete: 'off', size: 40, class: 'form-control', type: 'text' , 'data-search-form-target': \"textSearch\" %>"
54
54
  end
55
55
 
56
56
 
@@ -31,8 +31,8 @@ class TextField < Field
31
31
 
32
32
 
33
33
  def search_field_output
34
- "<%= f.select 'q[0][#{name}_match]', options_for_select([['', ''], ['contains', 'contains'], ['is exactly', 'is_exactly'], ['starts with', 'starts_with'], ['ends with', 'ends_with']], @q[\'0\']['#{name}_match'] ), {} , { class: 'form-control match' } %>"+
35
- "<%= f.text_field 'q[0][#{name}_search]', value: @q[\'0\'][:#{name}_search], autocomplete: 'off', size: 40, class: 'form-control', type: 'text' %>"
34
+ "<%= f.select 'q[0][#{name}_match]', options_for_select([['', ''], ['contains', 'contains'], ['is exactly', 'is_exactly'], ['starts with', 'starts_with'], ['ends with', 'ends_with']], @q[\'0\']['#{name}_match'] ), {} , { class: 'form-control match', 'data-search-form-target': \"textMatch\" } %>"+
35
+ "<%= f.text_field 'q[0][#{name}_search]', value: @q[\'0\'][:#{name}_search], autocomplete: 'off', size: 40, class: 'form-control', type: 'text', 'data-search-form-target': \"textSearch\" %>"
36
36
  end
37
37
 
38
38
 
@@ -45,7 +45,7 @@ class TextField < Field
45
45
  end
46
46
 
47
47
  def code_to_reset_match_if_search_is_blank
48
- " @q['0'][:#{name}_match] = '' if @q['0'][:#{name}_search] == ''"
48
+ # " @q['0'][:#{name}_match] = '' if @q['0'][:#{name}_search] == ''"
49
49
  end
50
50
 
51
51
  end
@@ -162,8 +162,13 @@ module HotGlue
162
162
 
163
163
  layout_object[:columns][:container][i] = column.split(",").collect{|x|
164
164
  x.gsub("-","").gsub("=","")
165
- }.collect(&:to_sym)
165
+ if x.include?("(")
166
+ x =~ /(.*)\((.*)\)/
167
+ x = $1
166
168
 
169
+ end
170
+ x
171
+ }.collect(&:to_sym)
167
172
 
168
173
 
169
174
  layout_object[:columns][:bootstrap_column_width][i] = fixed_widths[i] || target_col_size
@@ -199,7 +199,10 @@ module HotGlue
199
199
  size = layout_object[:columns][:bootstrap_column_width][columns.index(column)]
200
200
 
201
201
  " <div class='#{layout_strategy.column_classes_for_form_fields(size)} cell--#{singular}--#{column.join("-")}' >" +
202
- column.map { |col|
202
+ column.map { |full_col|
203
+
204
+ col = full_col.to_s.gsub("=", "").gsub("-", "").to_sym
205
+
203
206
  if col.to_s.starts_with?("**") && layout_object[:columns][:fields][col][:form]
204
207
  the_output = "<%= render partial: '#{col.to_s.gsub!("**","")}', locals: {#{singular}: #{singular} } %>"
205
208
  elsif ! layout_object[:columns][:fields][col][:form]
@@ -310,7 +313,13 @@ module HotGlue
310
313
  result = columns.map.with_index{ |column,i|
311
314
  size = layout_object[:columns][:bootstrap_column_width][i]
312
315
  "<div class='hg-col #{layout_strategy.column_classes_for_line_fields(size)} #{singular}--#{column.join("-")}'#{style_with_flex_basis}> " +
313
- column.map { |col|
316
+
317
+ column.map { |full_col|
318
+ col = full_col.to_s.gsub("=", "").gsub("-","").to_sym
319
+
320
+ if layout_object[:columns][:fields][col].nil?
321
+ raise "column #{col} not found on the layout data"
322
+ end
314
323
  if col.starts_with?("**") && layout_object[:columns][:fields][col][:show]
315
324
  the_output = "<%= render partial: '#{col.to_s.gsub!("**","")}', locals: {#{singular}: #{singular} } %>"
316
325
  elsif ! layout_object[:columns][:fields][col][:show]
@@ -117,6 +117,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
117
117
  class_option :phantom_create_params, type: :string, default: nil
118
118
  class_option :phantom_update_params, type: :string, default: nil
119
119
  class_option :controller_prefix, type: :string, default: nil
120
+ class_option :code_in_controller, type: :string, default: nil
120
121
 
121
122
  # SEARCH OPTIONS
122
123
  class_option :search, default: nil # set or predicate
@@ -439,6 +440,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
439
440
  @phantom_create_params = options['phantom_create_params'] || ""
440
441
  @phantom_update_params = options['phantom_update_params'] || ""
441
442
 
443
+
442
444
  if get_default_from_config(key: :pundit_default)
443
445
  raise "please note the config setting `pundit_default` has been renamed `pundit`. please update your hot_glue.yml file"
444
446
  end
@@ -645,6 +647,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
645
647
  @code_before_update = options['code_before_update']
646
648
  @code_after_update = options['code_after_update']
647
649
  @code_after_new = options['code_after_new']
650
+ @code_in_controller = options['code_in_controller'] || ""
648
651
 
649
652
  buttons_width = ((!@no_edit && 1) || 0) + ((!@no_delete && 1) || 0) + (@magic_buttons.any? ? 1 : 0)
650
653
 
@@ -687,6 +690,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
687
690
  # build a new polymorphic object
688
691
  @associations = []
689
692
  @columns_map = {}
693
+
690
694
  @columns.each do |col|
691
695
  # if !(@the_object.columns_hash.keys.include?(col.to_s) || @attachments.keys.include?(col))
692
696
  # raise "couldn't find #{col} in either field list or attachments list"
@@ -1077,6 +1081,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1077
1081
  @columns = @the_object.columns.map(&:name).map(&:to_sym).reject { |field| !@include_fields.include?(field) }
1078
1082
  end
1079
1083
 
1084
+
1080
1085
  @columns = @columns - @nested_set.collect { |set| (set[:singular] + "_id").to_sym }
1081
1086
 
1082
1087
  if @attachments.any?
@@ -1644,12 +1649,12 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1644
1649
  append_text = " <li class='nav-item'>
1645
1650
  <%= link_to '#{@list_label_heading.humanize}', #{path_helper_plural(@nested_set.any? ? true: false)}, class: \"nav-link \#{'active' if nav == '#{plural_name}'}\" %>
1646
1651
  </li>"
1647
- alt_append_text = " <li class='nav-item'>
1648
- <%= link_to '#{@list_label_heading.humanize.upcase}', #{path_helper_plural(@nested_set.any? ? true: false)}, class: \"nav-link \#{'active' if nav == '#{plural_name}'}\" %>
1649
- </li>"
1652
+ alt_append_text = "<%= link_to '#{@list_label_heading.humanize.upcase}', #{path_helper_plural(@nested_set.any? ? true: false)}, class: \"nav-link \#{'active' if nav == '#{plural_name}'}\" %>"
1653
+
1654
+ check_for_existing_append = "<%= link_to '#{@list_label_heading.humanize}', #{path_helper_plural(@nested_set.any? ? true: false)}, class: \"nav-link \#{'active' if nav == '#{plural_name}'}\" %>"
1650
1655
 
1651
1656
  text = File.read(nav_file)
1652
- if text.include?(append_text) || text.include?(alt_append_text)
1657
+ if text.include?(check_for_existing_append) || text.include?(alt_append_text)
1653
1658
  puts "SKIPPING: Nav link for #{singular_name} already exists in #{nav_file}"
1654
1659
  else
1655
1660
  puts "APPENDING: nav link for #{singular_name} #{nav_file}"
@@ -8,6 +8,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
8
8
 
9
9
  helper :hot_glue
10
10
  include HotGlue::ControllerHelper
11
+ <%= @code_in_controller.gsub(";", "\n") %>
11
12
 
12
13
  <% unless @god %>before_action :<%= "authenticate_" + @auth_identifier.split(".")[0] + "!" %><% end %><% if any_nested? %>
13
14
  <% nest_chain = [] %> <% @nested_set.each { |arg|
@@ -7,7 +7,11 @@
7
7
  <\%= form_with model: <%= singular %>,
8
8
  <% if @stimmify %> data: {controller: '<%= @stimmify %>' },
9
9
  <% end %>url: <%= form_path_edit_helper %><%= ", html: {'data-turbo': false}" if @big_edit %> do |f| %>
10
- <\%= render partial: "<%= namespace_with_trailing_dash + @controller_build_folder + "/" %>form", locals: {:<%= singular %> => <%= singular %>, f: f}<%= @nested_set.collect{|arg| ".merge(#{arg[:singular]} ? {#{arg[:singular]}: #{arg[:singular]}} : {})" }.join %> \%>
10
+ <\%= render partial: "<%= namespace_with_trailing_dash + @controller_build_folder + "/" %>form", locals: {
11
+ <%= singular %>: <%= singular %>,
12
+ f: f,
13
+ <%= @nested_set.collect{|arg| "#{arg[:singular]}: #{arg[:singular]}" }.join(",\n ") %>
14
+ } \%>
11
15
  <% if @edit_within_form_partial %><\%= render partial: "edit_within_form", locals: {f: f, <%= singular %>: <%= singular %>}<%= @nested_set.collect{|arg| ".merge(#{arg[:singular]} ? {#{arg[:singular]}: #{arg[:singular]}} : {})" }.join %> %><% end %>
12
16
  <\% end %>
13
17
  <% if @edit_after_form_partial %><\%= render partial: "edit_after_form", locals: {<%= singular %>: <%= singular %>}<%= @nested_set.collect{|arg| ".merge(#{arg[:singular]} ? {#{arg[:singular]}: #{arg[:singular]}} : {})" }.join %> %><% end %>
@@ -1,7 +1,10 @@
1
1
  <% if @turbo_streams %><\%= turbo_stream_from <%= singular %> %>
2
2
  <% end %><\%= turbo_frame_tag "<%= @namespace %>__#{ dom_id(<%= singular %>) }" do %>
3
3
  <div class='<%= @layout_strategy.row_classes %>' data-id='<\%= <%= singular %>.id %>' data-edit='false'>
4
- <\%= render partial: '<%= show_path_partial %>', locals: { <%= singular %>: <%= singular %><% if @nested_set.any? %>, <%= @nested_set.collect{|nest_arg| "#{nest_arg[:singular]}: #{ nest_arg[:singular] }"}.join(", ") %>, nested_for: "<%= @nested_set.collect{|nest_arg| nest_arg[:singular] + "-\#{#{nest_arg[:singular]}.id}"}.join("__") %>"<% end %> } %>
4
+ <\%= render partial: '<%= show_path_partial %>', locals: {
5
+ <%= singular %>: <%= singular %><% if @nested_set.any? %>,
6
+ <%= @nested_set.collect{|nest_arg| "#{nest_arg[:singular]}: #{ nest_arg[:singular] }"}.join(",\n ") %>,
7
+ nested_for: "<%= @nested_set.collect{|nest_arg| nest_arg[:singular] + "-\#{#{nest_arg[:singular]}.id}"}.join("__") %>"<% end %> } %>
5
8
  </div>
6
9
  <\% end %>
7
10
 
@@ -8,7 +8,14 @@
8
8
  <% end %>
9
9
 
10
10
  <% if @new_button_position == 'above' %>
11
- <% unless @no_create %><%= '<%= render partial: "' + ((@namespace+"/" if @namespace) || "") + @controller_build_folder + '/new_button", locals: {}' + @nested_set.collect{|arg| ".merge(defined?(#{arg[:singular]}) ? {#{arg[:singular]}: #{arg[:singular]}} : {})"}.join() + ' %\>'.gsub('\\',"") %><br /><% end %>
11
+ <% unless @no_create %>
12
+ <%= '<%= render partial: "' + ((@namespace+"/" if @namespace) || "") +
13
+ @controller_build_folder +
14
+ "/new_button\", locals: {
15
+ #{@nested_set.collect{|arg| arg[:singular] + ": " + arg[:singular]}.join(",\n ")} }" +
16
+ ' %\>'.gsub('\\',"") %>
17
+ <br />
18
+ <% end %>
12
19
  <% end %>
13
20
 
14
21
  <% unless @no_list %>
@@ -58,10 +65,8 @@
58
65
  </div>
59
66
  <\% end %>
60
67
  <\% <%= plural %>.each do |<%= singular %>| %>
61
- <\%= render partial: '<%= line_path_partial %>', locals: {<%= singular %>: <%= singular %>}
62
- .merge(defined?(nested_for) ? {nested_for: nested_for} : {})
63
- <%= @nested_set.collect{|arg| " .merge(defined?(#{arg[:singular]}) ? {#{arg[:singular]}: #{arg[:singular]}} : {})"}.join("\n") %>
64
- %>
68
+ <\%= render partial: '<%= line_path_partial %>', locals: {<%= singular %>: <%= singular %>,
69
+ <% if @nested_set.any? %>nested_for: nested_for, <%= @nested_set.collect{|arg| "#{arg[:singular]}: #{arg[:singular]}" }.join(", ") %><% end %> } \%>
65
70
  <\% end %>
66
71
  <% if @paginate_per_page_selector %>
67
72
  <\%= form_with url: '<%= path_helper_plural(top_level: false) %>', method: :get do |f| %>
@@ -5,8 +5,11 @@
5
5
  <\%= form_with model: <%= singular %>,
6
6
  <% if @stimmify %>data: {controller: '<%= @stimmify %>' },
7
7
  <% end %>url: <%= form_path_new_helper %>, method: :post<%= @display_edit_after_create ? ", html: {'data-turbo': false}" : "" %> do |f| \%>
8
- <\%= render partial: "<%= namespace_with_slash + @controller_build_folder %>/form",
9
- locals: { <%= singular %>: <%= singular %>, f: f}<%= @nested_set.collect{|arg| ".merge(defined?(#{arg[:singular]}) ? {#{arg[:singular]}: #{arg[:singular]}}: {})" }.join %> \%>
8
+ <\%= render partial: "<%= namespace_with_slash + @controller_build_folder %>/form", locals: {
9
+ <%= singular %>: <%= singular %>,
10
+ f: f,
11
+ <%= @nested_set.collect{|arg| "#{arg[:singular]}: #{arg[:singular]}" }.join(",\n ") %>
12
+ } \%>
10
13
 
11
14
  <% if @new_within_form_partial %><\%= render partial: "new_within_form", locals: {f: f, <%= singular %>: <%= singular %>}<%= @nested_set.collect{|arg| ".merge(#{arg[:singular]} ? {#{arg[:singular]}: #{arg[:singular]}} : {})" }.join %> %><% end %>
12
15
  <\% end %>
@@ -1,6 +1,9 @@
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 %>,
4
+ <% if @nested_set.any? %> <%= @nested_set.collect{|arg| "#{arg[:singular]}: @#{arg[:singular]}"}.join(", ") %>,
5
+ nested_for: "<%= @nested_set.collect{|arg| "#{arg[:singular]}-\#{@#{arg[:singular]}.id}"}.join("__") %>" <% end %>
6
+ } %>
4
7
 
5
8
  <\% end %>
6
9
  <\% end %>
@@ -9,9 +12,12 @@
9
12
  <!-- errors -->
10
13
  <\%= turbo_stream.replace "<%= @namespace %>__<%= singular %>-new" do %>
11
14
  <\% if @<%= singular %>.errors.none? %>
12
- <\%= render partial: "new_button", locals: {}<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {" + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> %>
15
+ <\%= render partial: "new_button", locals: {
16
+ <%= @nested_set.collect{|arg| "#{arg[:singular]}: @#{arg[:singular] }"}.join(", \n") %>
17
+
18
+ } %>
13
19
  <\% else %>
14
- <\%= render partial: "new_form", locals: {<%= singular %>: @<%= singular %>}<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {" + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> %>
20
+ <\%= render partial: "new_form", locals: {<%= singular %>: @<%= singular %>, <%= @nested_set.collect{|arg| arg[:singular] + ": @" + arg[:singular]}.join(",\n ") %> } %>
15
21
  <\% end %>
16
22
  <\% end %>
17
23
  <\%= turbo_stream.replace "flash_notices" do %>
@@ -1,9 +1,12 @@
1
1
  <%= turbo_parental_updates %>
2
2
 
3
3
  <\%= turbo_stream.update "<%= @namespace %>__<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
4
- <\%= render partial: "list", locals: {<%=plural%>: @<%=plural%> }<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {nested_for: \"" + arg[:singular] + "-\#{@" + arg[:singular] + ".id}\"" + ", " + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> \%>
4
+ <\%= render partial: "list", locals: {<%=plural%>: @<%=plural %> ,
5
+ <% if @nested_set.any? %>nested_for: "<%= @nested_set.collect{|arg| arg[:singular] + "-\#{@#{arg[:singular]}.id}" }.join("__") %>",
6
+ <%= @nested_set.collect{|arg| arg[:singular] + ": @" + arg[:singular] }.join(", ") %><% end %>
7
+ } \%>
5
8
  <\% end %>
6
9
 
7
10
  <\%= turbo_stream.update "flash_notices" do %>
8
11
  <\%= render partial: "layouts/flash_notices", locals: {resource: @<%= singular %>} %>
9
- <\% end %>
12
+ <\% end %>
@@ -1,5 +1,7 @@
1
1
  <% if @big_edit %>
2
- <div class="container">
2
+ <% if include_nav_template %><%= @layout_strategy.page_begin %><\%= render partial: "<%= nav_template %>", locals: {nav: "<%= @plural %>"} %><%= @layout_strategy.page_end %><% end %>
3
+
4
+ <div class="container">
3
5
  <div class="row">
4
6
  <div class="col-md-12">
5
7
  <\%= 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) %> %>
@@ -10,8 +12,6 @@
10
12
  </div>
11
13
  </div>
12
14
 
13
-
14
-
15
15
  <% if @downnest_children.any? && @big_edit %>
16
16
  <div class="container" data-controller="bootstrap-tabbed-nav">
17
17
  <ul class="nav nav-tabs" id="<%= singular + "_downnest_portals" %>" role="tablist">
@@ -1 +1 @@
1
- <\%= render partial: "new_form", locals: {<%= singular %>: @<%=singular%>}<%= @nested_set.collect{|arg| ".merge(@#{arg[:singular]} ? {#{arg[:singular]}: @#{arg[:singular]}} : {})" }.join %> %>
1
+ <\%= render partial: "new_form", locals: {<%= singular %>: @<%=singular%>, <%= @nested_set.collect{|arg| "#{arg[:singular]}: @#{arg[:singular]}" }.join(", ") %>} %>
@@ -1,16 +1,67 @@
1
1
  import { Controller } from "@hotwired/stimulus"
2
2
 
3
- // Connects to data-controller="search_form"
4
3
  export default class extends Controller {
5
- static targets = ["clearButton"];
4
+ static targets = ["clearButton", "textSearch", "textMatch"]
6
5
 
7
6
  connect() {
8
-
9
7
  if (this.hasClearButtonTarget) {
10
8
  this.clearButtonTarget.addEventListener("click", (event) => {
11
9
  event.preventDefault()
12
10
  this.element.reset()
13
11
  })
14
12
  }
13
+
14
+ // watch match selects
15
+ this.textMatchTargets.forEach(target => {
16
+ target.addEventListener("change", this.handleMatchChange)
17
+ })
18
+ }
19
+
20
+ textSearchTargetConnected(target) {
21
+ target.addEventListener("input", this.handleSearchInput)
22
+ }
23
+
24
+ disconnect() {
25
+ this.textSearchTargets.forEach(target => {
26
+ target.removeEventListener("input", this.handleSearchInput)
27
+ })
28
+ this.textMatchTargets.forEach(target => {
29
+ target.removeEventListener("change", this.handleMatchChange)
30
+ })
31
+ }
32
+
33
+ handleSearchInput = (event) => {
34
+ const searchEl = event.target
35
+ const matchEl = this.findMatchFor(searchEl)
36
+ if (!matchEl) return
37
+
38
+ const val = searchEl.value.trim()
39
+ const resettable = ["contains", "starts_with", "ends_with"]
40
+
41
+ if (val.length > 0 && matchEl.value === "") {
42
+ matchEl.value = "contains"
43
+ } else if (val === "" && resettable.includes(matchEl.value)) {
44
+ matchEl.value = ""
45
+ }
46
+ }
47
+
48
+ handleMatchChange = (event) => {
49
+ const matchEl = event.target
50
+ if (matchEl.value !== "") return
51
+
52
+ const searchEl = this.findSearchFor(matchEl)
53
+ if (!searchEl) return
54
+
55
+ searchEl.value = ""
56
+ }
57
+
58
+ findMatchFor(searchEl) {
59
+ const matchName = searchEl.name.replace("search", "match")
60
+ return this.textMatchTargets.find(t => t.name === matchName)
61
+ }
62
+
63
+ findSearchFor(matchEl) {
64
+ const searchName = matchEl.name.replace("match", "search")
65
+ return this.textSearchTargets.find(t => t.name === searchName)
15
66
  }
16
67
  }
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.7'
3
+ CURRENT = '0.7.1'
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.7'
4
+ version: 0.7.1
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-11-05 00:00:00.000000000 Z
11
+ date: 2025-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails