hot-glue 0.6.12 → 0.6.15
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 +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +17 -1
- data/app/helpers/hot_glue/controller_helper.rb +11 -1
- data/lib/generators/hot_glue/fields/association_field.rb +9 -1
- data/lib/generators/hot_glue/fields/field.rb +10 -1
- data/lib/generators/hot_glue/markup_templates/erb.rb +3 -1
- data/lib/generators/hot_glue/scaffold_generator.rb +22 -7
- data/lib/generators/hot_glue/templates/erb/_list.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +3 -3
- data/lib/hotglue/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e3993f35ba9d926cec0a205bb06708be83c2d72012eaafebce6cb384da07a92
|
4
|
+
data.tar.gz: 509b98c64699c6561435d63da9b0ae6afe2924d6c1624dbcedf1a3288a5dfc0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3d097f4f7130718597c9024173980e2d7b59826d4bb355ce34c22f70f0fec01e6265784007bdc296f41e0cd232d96d7a1ed2e0b055a6f7dbb1eef644fac5da7
|
7
|
+
data.tar.gz: 83905ccb51e15676d2dff4253f656ef29a330272ed0549ebbbb74a7272ee9aa42b04491ba4ef88c2bf9fb84ec047991da89fa027e519cf048f3197bd7687ccd1
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hot-glue (0.6.
|
4
|
+
hot-glue (0.6.14)
|
5
5
|
ffaker (~> 2.16)
|
6
6
|
kaminari (~> 1.2)
|
7
7
|
rails (> 5.1)
|
@@ -140,14 +140,14 @@ GEM
|
|
140
140
|
mini_mime (1.1.2)
|
141
141
|
mini_portile2 (2.8.4)
|
142
142
|
minitest (5.16.3)
|
143
|
-
net-imap (0.5.
|
143
|
+
net-imap (0.5.6)
|
144
144
|
date
|
145
145
|
net-protocol
|
146
146
|
net-pop (0.1.2)
|
147
147
|
net-protocol
|
148
148
|
net-protocol (0.2.2)
|
149
149
|
timeout
|
150
|
-
net-smtp (0.5.
|
150
|
+
net-smtp (0.5.1)
|
151
151
|
net-protocol
|
152
152
|
nio4r (2.5.8)
|
153
153
|
nokogiri (1.13.9)
|
data/README.md
CHANGED
@@ -674,7 +674,9 @@ Applies a badge `bg-primary` to rows with opened_at truthy and `bg-secondary` to
|
|
674
674
|
to display a badge on everything, use the `none` modifier with the
|
675
675
|
`--modify=opened_at{none}[bg-dark]`
|
676
676
|
|
677
|
+
For the `$` modifier only, if the field name ends with `_cents`, the modifier will automatically divide the field by 100 before displaying it.
|
677
678
|
|
679
|
+
(This is consistent with Stripe'e paradigm to always store money in cents, and this way I force myself to put `_cents` on the end of my field names to remind myself that they are in cents.)
|
678
680
|
|
679
681
|
### `--alt-foreign-key-lookup=`
|
680
682
|
|
@@ -1749,7 +1751,21 @@ These automatic pickups for partials are detected at build time. This means that
|
|
1749
1751
|
|
1750
1752
|
# VERSION HISTORY
|
1751
1753
|
|
1752
|
-
#### 2025-
|
1754
|
+
#### 2025-03-17 - v0.6.15
|
1755
|
+
|
1756
|
+
• now store on your current_user model (this is automatically passed into the method modify_date_inputs_on_params). HG will set user-inputted values correctly to daylight savings time during April-Nov months only (#195)
|
1757
|
+
• fixes issue with turbo frame name after create is rendered (#194)
|
1758
|
+
• removes vestigates of optionalized partents
|
1759
|
+
|
1760
|
+
|
1761
|
+
#### 2025-02-28 - v0.6.14
|
1762
|
+
|
1763
|
+
• fixes bug in association field involving scaffolds built without nesting
|
1764
|
+
• fixes bug in paginated display
|
1765
|
+
• when applying $ modifier to a numerical field, if the field ends with `_cents`, the number will be /100 before being displayed
|
1766
|
+
|
1767
|
+
|
1768
|
+
#### 2025-02-20 - v0.6.12
|
1753
1769
|
• adds decimal field type (displays as float-- there is no special handling for decimal on the UI)
|
1754
1770
|
• guard against polymorphic belongs_to -- not a full implementation for polymorphic fields, just hides the fields on the form; on the list uses to_label always
|
1755
1771
|
• fixes heading with multiword names on downnested portals to display nicely capitalized
|
@@ -68,8 +68,16 @@ module HotGlue
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def is_dst_now?
|
72
|
+
Time.now.utc.month > 3 && Time.now.month < 11 ||
|
73
|
+
(Time.now.utc.month == 3 && Time.now.day >= (14 - Time.now.utc.wday)) ||
|
74
|
+
(Time.now.utc.month == 11 && Time.now.utc.day < (7 - Time.now.utc.wday))
|
75
|
+
end
|
76
|
+
|
71
77
|
def modify_date_inputs_on_params(modified_params, current_user_object = nil, field_list = nil)
|
72
78
|
use_timezone = (current_user_object.try(:timezone)) || Time.zone
|
79
|
+
uses_dst = (current_user_object.try(:locale_uses_dst)) || false
|
80
|
+
|
73
81
|
modified_params = modified_params.tap do |params|
|
74
82
|
params.keys.each{|k|
|
75
83
|
|
@@ -88,7 +96,9 @@ module HotGlue
|
|
88
96
|
# if they already exist in your database, you should zero them out
|
89
97
|
# or apply .change(sec: 0) when displaying them as output in the form
|
90
98
|
# this will prevent seconds from being added by the browser
|
91
|
-
|
99
|
+
parsed_time = Time.strptime(parse_date, "%Y-%m-%d %H:%M %Z")
|
100
|
+
parsed_time = parsed_time.to_time - 60.minutes if uses_dst && is_dst_now?
|
101
|
+
params[k] = parsed_time
|
92
102
|
end
|
93
103
|
end
|
94
104
|
}
|
@@ -112,7 +112,7 @@ class AssociationField < Field
|
|
112
112
|
# end
|
113
113
|
elsif modify_as && modify_as[:typeahead]
|
114
114
|
search_url = "#{namespace ? namespace + "_" : ""}" +
|
115
|
-
modify_as[:nested].join("_") + (
|
115
|
+
modify_as[:nested].join("_") + ( modify_as[:nested].any? ? "_" : "") +
|
116
116
|
+ "#{assoc.class_name.downcase.pluralize}_typeahead_index_url"
|
117
117
|
|
118
118
|
|
@@ -155,6 +155,7 @@ class AssociationField < Field
|
|
155
155
|
hawked_association = "#{assoc.class_name}.all"
|
156
156
|
end
|
157
157
|
|
158
|
+
|
158
159
|
(is_owner ? "<% unless @#{assoc_name} %>\n" : "") +
|
159
160
|
" <%= f.collection_select(:#{name}, #{hawked_association}, :id, :#{display_column}, {prompt: true, selected: #{singular}.#{name} }, class: 'form-control') %>\n" +
|
160
161
|
(is_owner ? "<% else %>\n <%= @#{assoc_name}.#{display_column} %>" : "") +
|
@@ -253,6 +254,13 @@ class AssociationField < Field
|
|
253
254
|
# "\n "
|
254
255
|
end
|
255
256
|
|
257
|
+
def newline_after_field?
|
258
|
+
if modify_as && modify_as[:typeahead]
|
259
|
+
false
|
260
|
+
else
|
261
|
+
true
|
262
|
+
end
|
263
|
+
end
|
256
264
|
|
257
265
|
def where_query_statement
|
258
266
|
".where(*#{name}_query)"
|
@@ -145,7 +145,11 @@ class Field
|
|
145
145
|
res = +''
|
146
146
|
|
147
147
|
if modify_as[:cast] && modify_as[:cast] == "$"
|
148
|
-
|
148
|
+
if name.ends_with?("_cents")
|
149
|
+
res += "<%= number_to_currency(#{singular}.#{name} / 100) %>"
|
150
|
+
else
|
151
|
+
res += "<%= number_to_currency(#{singular}.#{name}) %>"
|
152
|
+
end
|
149
153
|
elsif modify_as[:binary]
|
150
154
|
res += "<%= #{singular}.#{name} ? '#{modify_as[:binary][:truthy]}' : '#{modify_as[:binary][:falsy]}' %>"
|
151
155
|
elsif modify_as[:tinymce]
|
@@ -215,4 +219,9 @@ class Field
|
|
215
219
|
def code_to_reset_match_if_search_is_blank
|
216
220
|
nil
|
217
221
|
end
|
222
|
+
|
223
|
+
def newline_after_field?
|
224
|
+
false
|
225
|
+
end
|
226
|
+
|
218
227
|
end
|
@@ -158,6 +158,8 @@ module HotGlue
|
|
158
158
|
# show only on the update action overrides any pundit policy
|
159
159
|
elsif @pundit && eval("defined? #{singular_class}Policy") && eval("#{singular_class}Policy").instance_methods.include?("#{col}_able?".to_sym)
|
160
160
|
"<% if policy(@#{singular}).#{col}_able? %>" + columns_map[col].form_field_output + "<% else %>" + columns_map[col].form_show_only_output + "<% end %>"
|
161
|
+
elsif update_show_only.include?(col)
|
162
|
+
"<% if @action == 'edit' %>" + columns_map[col].form_show_only_output + "<% else %>" + columns_map[col].form_field_output + "<% end %>"
|
161
163
|
else
|
162
164
|
columns_map[col].form_field_output
|
163
165
|
end
|
@@ -168,7 +170,7 @@ module HotGlue
|
|
168
170
|
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" +
|
169
171
|
add_spaces_each_line( (form_labels_position == 'before' ? (the_label || "") + "<br />\n" : "") +
|
170
172
|
+ field_result +
|
171
|
-
(form_labels_position == 'after' ? "<br />\n" + (the_label || "") : "") , 4) +
|
173
|
+
(form_labels_position == 'after' ? ( columns_map[col].newline_after_field? ? "<br />\n" : "") + (the_label || "") : "") , 4) +
|
172
174
|
"\n </span>\n ", 2)
|
173
175
|
|
174
176
|
}.join("") + "\n </div>"
|
@@ -77,7 +77,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
77
77
|
class_option :no_list_heading, type: :boolean, default: false
|
78
78
|
|
79
79
|
# determines if the labels show up BEFORE or AFTER on the NEW/EDIT (form)
|
80
|
-
class_option :form_labels_position, type: :string
|
80
|
+
class_option :form_labels_position, type: :string # choices are before, after, omit
|
81
81
|
class_option :form_placeholder_labels, type: :boolean, default: false # puts the field names into the placeholder labels
|
82
82
|
|
83
83
|
# determines if labels appear within the rows of the VIEWABLE list (does NOT affect the list heading)
|
@@ -310,10 +310,18 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
310
310
|
@inline_list_labels = options['inline_list_labels'] || get_default_from_config(key: :inline_list_labels) || 'omit' # 'before','after','omit'
|
311
311
|
|
312
312
|
@form_labels_position = options['form_labels_position']
|
313
|
-
if
|
314
|
-
|
313
|
+
if @form_labels_position.nil?
|
314
|
+
@form_labels_position = get_default_from_config(key: :form_labels_position)
|
315
|
+
if @form_labels_position.nil?
|
316
|
+
@form_labels_position = 'after'
|
317
|
+
end
|
318
|
+
else
|
319
|
+
if !['before', 'after', 'omit'].include?(@form_labels_position)
|
320
|
+
raise HotGlue::Error, "You passed '#{@form_labels_position}' as the setting for --form-labels-position but the only allowed options are before, after (default), and omit"
|
321
|
+
end
|
315
322
|
end
|
316
323
|
|
324
|
+
|
317
325
|
if !['before', 'after', 'omit'].include?(@inline_list_labels)
|
318
326
|
raise HotGlue::Error, "You passed '#{@inline_list_labels}' as the setting for --inline-list-labels but the only allowed options are before, after, and omit (default)"
|
319
327
|
end
|
@@ -651,6 +659,10 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
651
659
|
@menu_file_exists = true if @nested_set.none? && File.exist?("#{Rails.root}/app/views/#{namespace_with_trailing_dash}_menu.#{@markup}")
|
652
660
|
|
653
661
|
@turbo_streams = !!options['with_turbo_streams']
|
662
|
+
|
663
|
+
puts "show only #{@show_only}"
|
664
|
+
puts "update show only #{@update_show_only}"
|
665
|
+
|
654
666
|
end
|
655
667
|
|
656
668
|
def setup_hawk_keys
|
@@ -1330,9 +1342,12 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1330
1342
|
append_text = " <li class='nav-item'>
|
1331
1343
|
<%= link_to '#{@list_label_heading.humanize}', #{path_helper_plural(@nested_set.any? ? true: false)}, class: \"nav-link \#{'active' if nav == '#{plural_name}'}\" %>
|
1332
1344
|
</li>"
|
1345
|
+
alt_append_text = " <li class='nav-item'>
|
1346
|
+
<%= link_to '#{@list_label_heading.humanize.upcase}', #{path_helper_plural(@nested_set.any? ? true: false)}, class: \"nav-link \#{'active' if nav == '#{plural_name}'}\" %>
|
1347
|
+
</li>"
|
1333
1348
|
|
1334
1349
|
text = File.read(nav_file)
|
1335
|
-
if text.include?(append_text)
|
1350
|
+
if text.include?(append_text) || text.include?(alt_append_text)
|
1336
1351
|
puts "SKIPPING: Nav link for #{singular_name} already exists in #{nav_file}"
|
1337
1352
|
else
|
1338
1353
|
puts "APPENDING: nav link for #{singular_name} #{nav_file}"
|
@@ -1531,9 +1546,9 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1531
1546
|
if @nested_set.none?
|
1532
1547
|
"\"\""
|
1533
1548
|
else
|
1534
|
-
@nested_set.collect { |arg|
|
1535
|
-
"
|
1536
|
-
}.join(" + "
|
1549
|
+
"\"" + @nested_set.collect { |arg|
|
1550
|
+
"__#{arg[:singular]}-\#{" + "@" + arg[:singular] + ".id}"
|
1551
|
+
}.join("") + "\""
|
1537
1552
|
end
|
1538
1553
|
end
|
1539
1554
|
|
@@ -61,7 +61,7 @@
|
|
61
61
|
%>
|
62
62
|
<\% end %>
|
63
63
|
<% if @paginate_per_page_selector %>
|
64
|
-
<\%= form_with url:
|
64
|
+
<\%= form_with url: '<%= path_helper_plural(top_level: false) %>', method: :get do |f| %>
|
65
65
|
Show per page
|
66
66
|
<\%= f.collection_select "per", [10, 25, 100], :to_s, :to_s, {prompt: true, selected: params[:per]}, {onChange: "this.form.submit();"} %>
|
67
67
|
<\% end %>
|
@@ -1,7 +1,8 @@
|
|
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
|
4
|
-
|
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
|
+
|
5
|
+
<\% end %>
|
5
6
|
<\% end %>
|
6
7
|
<!-- parental updated -->
|
7
8
|
<%= turbo_parental_updates %>
|
@@ -15,5 +16,4 @@
|
|
15
16
|
<\% end %>
|
16
17
|
<\%= turbo_stream.replace "flash_notices" do %>
|
17
18
|
<\%= render partial: "layouts/flash_notices", locals: {resource: @<%= singular %>} %>
|
18
|
-
|
19
19
|
<\% end %>
|
data/lib/hotglue/version.rb
CHANGED
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.
|
4
|
+
version: 0.6.15
|
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
|
+
date: 2025-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|