hot-glue 0.6.30 → 0.6.31
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd6bfe4a874a5e894d6b315e72c145f1a563ac3a851e2d4849e41eb127b4402f
|
|
4
|
+
data.tar.gz: d88aeb4540484a0335150c0d637a8781b1781ff33b227cd65b60d96fa13703ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16e4242488830bb7b4da394a9e6e919b32ef885ddf5ce506e05954ca5830b918a47b2662661289d0bf4adbb6b3e4bf5d89fdb2ddbb59f9333126622461fabb81
|
|
7
|
+
data.tar.gz: 9ac25352156d69caf694303602f968990441cded93504d6fc340df1b92091bb450f6372d409c10ba2be8a0599e1217e5d037e053b908c2b5136bad148f7719cb
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1086,9 +1086,11 @@ Here, the `cost` and `price` fields will be displayed as wrapped in `number_to_c
|
|
|
1086
1086
|
You can also use a binary modifier, which can apply to booleans, datetimes, times, dates or anything else. When using the binary modify, a specific value is displayed if the field is truthy and another one is display if the field is falsy.
|
|
1087
1087
|
You specify it using a pipe | character like so:
|
|
1088
1088
|
|
|
1089
|
+
Example binary modification:
|
|
1090
|
+
|
|
1089
1091
|
`--modify=paid_at{paid|unpaid}`
|
|
1090
1092
|
|
|
1091
|
-
|
|
1093
|
+
Here, even though `paid_at` is a datetime field, it will display as-if it is a binary -- showing either the truthy
|
|
1092
1094
|
label or the falsy label depending on if `paid_at` is or is not null in the database.
|
|
1093
1095
|
For all fields except booleans, this affects only the viewable output —
|
|
1094
1096
|
what you see on the list page and on the edit page for show-only fields.
|
|
@@ -1099,20 +1101,25 @@ You will need to separately specify them as show-only if you want them to be non
|
|
|
1099
1101
|
|
|
1100
1102
|
Notice that each modifiers can be used with specific field types.
|
|
1101
1103
|
|
|
1102
|
-
| user modifier | what it does | Field types | |
|
|
1103
|
-
|
|
1104
|
-
| $ | wraps output in `number_to_currency()` | floats and integers | |
|
|
1104
|
+
| user modifier | what it does | Field types | | |
|
|
1105
|
+
|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|---|----|
|
|
1106
|
+
| $ | wraps output in `number_to_currency()` | floats and integers | | |
|
|
1105
1107
|
| (truthy label)\|(falsy label) | specify a binary switch with a pipe (\|) character if the value is truthy, it will display as "truthy label" if the value is falsy, it will display as "falsy label" | booleans, datetimes, dates, times | | |
|
|
1106
|
-
| partials | applies to enums only, you must have a partial whose name matches each enum type | enums only | |
|
|
1107
|
-
| tinymce | applies to text fields only, be sure to setup TineMCE globally | text fields only | |
|
|
1108
|
-
| typeahead | turns a foreign key (only) into a searchable typeahead field | foreign keys only | |
|
|
1109
|
-
| timezone | turns a string (varchar) into a drop down of timezones | foreign keys only | |
|
|
1110
|
-
| include_blank | special modifier for association fields, adds include_blank to the created dropdown
|
|
1108
|
+
| partials | applies to enums only, you must have a partial whose name matches each enum type | enums only | | |
|
|
1109
|
+
| tinymce | applies to text fields only, be sure to setup TineMCE globally | text fields only | | |
|
|
1110
|
+
| typeahead | turns a foreign key (only) into a searchable typeahead field | foreign keys only | | |
|
|
1111
|
+
| timezone | turns a string (varchar) into a drop down of timezones | foreign keys only | | |
|
|
1112
|
+
| include_blank | special modifier for association fields, adds include_blank to the created dropdown | |
|
|
1113
|
+
| urlwrap | wrap this field in a URL | any printable field | | |
|
|
1111
1114
|
| none | special modifier for using badges |
|
|
1112
1115
|
|
|
1113
1116
|
Except for "(truthy label)" and "(falsy label)" which use the special syntax, use the modifier _exactly_ as it is named.
|
|
1114
1117
|
|
|
1115
|
-
|
|
1118
|
+
Some modifiers take a 3rd parameter in `[` and `]` markers after the modification marker. The 3rd parameters function depends on which modifier you are using.
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
#### Binary (use | to separate "true value" from "false value")
|
|
1122
|
+
Can take a bootstrap badge name as 3rd parameter
|
|
1116
1123
|
|
|
1117
1124
|
`--modify=opened_at{opened|closed}[bg-primary|bg-secondary]`
|
|
1118
1125
|
Applies a badge `bg-primary` to rows with opened_at truthy and `bg-secondary` to rows with opened_at falsy.
|
|
@@ -1120,10 +1127,50 @@ Applies a badge `bg-primary` to rows with opened_at truthy and `bg-secondary` to
|
|
|
1120
1127
|
to display a badge on everything, use the `none` modifier with the
|
|
1121
1128
|
`--modify=opened_at{none}[bg-dark]`
|
|
1122
1129
|
|
|
1130
|
+
#### $
|
|
1123
1131
|
For the `$` modifier only, if the field name ends with `_cents`, the modifier will automatically divide the field by 100 before displaying it.
|
|
1124
|
-
|
|
1125
1132
|
(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.)
|
|
1126
1133
|
|
|
1134
|
+
|
|
1135
|
+
#### Typeahead
|
|
1136
|
+
3rd parameter (in `[...]`) used to specify the nested set IF the typeahead itself is nested (optional)
|
|
1137
|
+
- see the typeahead section for details
|
|
1138
|
+
|
|
1139
|
+
#### urlwrap
|
|
1140
|
+
|
|
1141
|
+
Use to wrap the field contents in a clickable link.
|
|
1142
|
+
|
|
1143
|
+
`rails generate hot_glue:scaffold BskyUser --gd --modify='handle{urlwrap}[bsky_url]'`
|
|
1144
|
+
|
|
1145
|
+
Here, we are telling Hot Glue that we want to modify the field called `handle` to be wrapped in a URL.
|
|
1146
|
+
We form that URL but calling the helper method `bsky_url` (must be defined in your helpers)
|
|
1147
|
+
|
|
1148
|
+
When we do make that call, notice that we pass two arguments to bsky_url (not seen):
|
|
1149
|
+
1) the field we are modifying
|
|
1150
|
+
2) the object
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
`bsky_url(bsky_user.handle, bsky_user)`
|
|
1154
|
+
|
|
1155
|
+
(`bsky_user.handle` is the field to be modified, what will become the link text. `bsky_user` is the instance of the model
|
|
1156
|
+
object as it is displayed to the screen)
|
|
1157
|
+
|
|
1158
|
+
its implementation might look like this:
|
|
1159
|
+
|
|
1160
|
+
```
|
|
1161
|
+
module BskyUserHelper
|
|
1162
|
+
|
|
1163
|
+
def bsky_url(link_text, bsky_user)
|
|
1164
|
+
link_to link_text, "https://#{bsky_user.handle}", target: "_blank"
|
|
1165
|
+
end
|
|
1166
|
+
end
|
|
1167
|
+
```
|
|
1168
|
+
In this case I happen to be turning piece of text _that is the link itself_ into a link,
|
|
1169
|
+
which is why you see `"https://#{bsky_user.handle}"` in the URL being generated, but this is arbitrary.
|
|
1170
|
+
You can make any piece of text into a link, the helper method is only used to construct the link.
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
1127
1174
|
### `--alt-foreign-key-lookup=`
|
|
1128
1175
|
|
|
1129
1176
|
Use for a join table to specify that a field should be looked up by a different field. For example, when you want to lookup a user by a (complete) email address.
|
|
@@ -2284,6 +2331,15 @@ These automatic pickups for partials are detected at build time. This means that
|
|
|
2284
2331
|
|
|
2285
2332
|
# VERSION HISTORY
|
|
2286
2333
|
|
|
2334
|
+
#### 2025-10-28 - v0.6.31
|
|
2335
|
+
|
|
2336
|
+
- new modification directive: `urlwrap`: use to wrap the field contents in a clickable link.
|
|
2337
|
+
See docs for "urlwrap" in the `--modify=` section above
|
|
2338
|
+
|
|
2339
|
+
- Fixes for typeaheads: corrects search url when the typeahead is built against a two-word model name
|
|
2340
|
+
|
|
2341
|
+
- Fixes for source reflection on has_many associations
|
|
2342
|
+
|
|
2287
2343
|
#### 2025-10-19 - v0.6.30
|
|
2288
2344
|
- fixes references from search typeaheads to a typeahead controller which is nested
|
|
2289
2345
|
- `--nested` can now take square braces if the relationship from child to parent (belongs_to) uses a non-standard association name; @downnest_object fix for data array; changes to object_scope to accomodate new paradigm
|
|
@@ -103,8 +103,7 @@ class AssociationField < Field
|
|
|
103
103
|
|
|
104
104
|
search_url = "#{namespace ? namespace + "_" : ""}" +
|
|
105
105
|
modify_as[:nested].join("_") + ( modify_as[:nested].any? ? "_" : "") +
|
|
106
|
-
+ "#{assoc.
|
|
107
|
-
|
|
106
|
+
+ "#{assoc.name.to_s.pluralize}_typeahead_index_url"
|
|
108
107
|
|
|
109
108
|
if @modify_as[:nested].any?
|
|
110
109
|
search_url << "(" + modify_as[:nested].collect{|x| "#{x}"}.join(",") + ")"
|
|
@@ -204,7 +203,10 @@ class AssociationField < Field
|
|
|
204
203
|
assoc_name = name.to_s.gsub("_id","")
|
|
205
204
|
assoc = eval("#{class_name}.reflect_on_association(:#{assoc_name})")
|
|
206
205
|
if modify_as && modify_as[:typeahead]
|
|
207
|
-
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
search_url = "#{namespace ? namespace + "_" : ""}#{ modify_as[:nested][0] ? modify_as[:nested][0] + "_" : ""}#{assoc.name.to_s.pluralize}_typeahead_index_url"
|
|
209
|
+
|
|
208
210
|
|
|
209
211
|
# \"q[0][#{name}_search]\"
|
|
210
212
|
# @q['0']['#{name}_search']
|
|
@@ -146,7 +146,13 @@ class Field
|
|
|
146
146
|
|
|
147
147
|
elsif modify_as[:timezone]
|
|
148
148
|
res += "<%= #{singular}.#{name} %>"
|
|
149
|
+
elsif modify_as[:urlwrap]
|
|
150
|
+
# helper_method = modify_as[:helper_method].split(" ")[0]
|
|
151
|
+
# param = modify_as[:helper_method].split(" ")[1]
|
|
152
|
+
|
|
153
|
+
res += "<%= #{modify_as[:helper_method]}(#{singular}.#{name}, #{singular}) %>"
|
|
149
154
|
elsif modify_as[:enum]
|
|
155
|
+
|
|
150
156
|
elsif modify_as[:none]
|
|
151
157
|
field_view_output
|
|
152
158
|
# res += "<%= render partial: #{singular}.#{name}, locals: {#{singular}: #{singular}} %>"
|
|
@@ -300,6 +300,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
300
300
|
setting =~ /(.*){(.*)}/
|
|
301
301
|
key, lookup_as = $1, $2
|
|
302
302
|
end
|
|
303
|
+
|
|
303
304
|
if ["$"].include?($2)
|
|
304
305
|
@modify_as[key.to_sym] = {cast: $2, badges: $3}
|
|
305
306
|
elsif $2.include?("|")
|
|
@@ -322,6 +323,10 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
322
323
|
@modify_as[key.to_sym] = {timezone: 1, badges: $3}
|
|
323
324
|
elsif $2 == "include_blank"
|
|
324
325
|
@modify_as[key.to_sym] = {include_blank: true}
|
|
326
|
+
elsif $2 == "urlwrap"
|
|
327
|
+
helper_method = $3
|
|
328
|
+
@modify_as[key.to_sym] = { urlwrap: true,
|
|
329
|
+
helper_method: helper_method }
|
|
325
330
|
elsif $2 == "none"
|
|
326
331
|
@modify_as[key.to_sym] = {none: 1, badges: $3}
|
|
327
332
|
else
|
|
@@ -1443,15 +1448,15 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
1443
1448
|
.to_a.find{|x|
|
|
1444
1449
|
|
|
1445
1450
|
if x.source_reflection
|
|
1446
|
-
x.
|
|
1447
|
-
|
|
1448
|
-
# raise "#{singular_class} class declaration is missing source reflection for the `has_many :#{x.name}` association"
|
|
1451
|
+
x.table_name == plural
|
|
1449
1452
|
end
|
|
1450
1453
|
}.plural_name
|
|
1454
|
+
|
|
1451
1455
|
else
|
|
1452
1456
|
association = plural
|
|
1453
1457
|
end
|
|
1454
1458
|
|
|
1459
|
+
|
|
1455
1460
|
if @auth && !@god
|
|
1456
1461
|
if @nested_set.none?
|
|
1457
1462
|
@auth + ".#{association}"
|
|
@@ -1851,7 +1856,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
1851
1856
|
else
|
|
1852
1857
|
if !@self_auth
|
|
1853
1858
|
|
|
1854
|
-
res << spaces(4) + "@#{ plural_name } = #{ object_scope.gsub("@",'') }#{ n_plus_one_includes }#{
|
|
1859
|
+
res << spaces(4) + "@#{ plural_name } = #{ object_scope.gsub("@",'') }#{record_scope}#{ n_plus_one_includes }#{".all" if n_plus_one_includes.blank? && record_scope.blank? }"
|
|
1855
1860
|
|
|
1856
1861
|
if @search_fields
|
|
1857
1862
|
res << @search_fields.collect{ |field|
|
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.31
|
|
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-10-
|
|
11
|
+
date: 2025-10-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|