hot-glue 0.7.1 → 0.7.3
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 +1 -1
- data/LICENSE +0 -4
- data/README.md +72 -3
- data/lib/generators/hot_glue/scaffold_generator.rb +90 -50
- data/lib/generators/hot_glue/templates/controller.rb.erb +9 -5
- data/lib/generators/hot_glue/templates/erb/_edit.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/edit.erb +8 -2
- data/lib/generators/hot_glue/templates/erb/index.erb +2 -1
- data/lib/hotglue/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 00062223cad2c1adb79987dc16eec8e5a1cb612f18106c6b01878346630737d7
|
|
4
|
+
data.tar.gz: fd0fcf30cccc20b02e552d44628cf4856e08582338e296eea08699ff1318b85d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ec04a5a3a6783caac2efc0035b409d9ac768a0d8094729b2f9551cdb363629f6433e24364a8caaaee675877ad996cbc51a219d666b9bfa05055143d372f3f77
|
|
7
|
+
data.tar.gz: '028e4f5fc7cb0a490ee715df7201976f79d026ff8916b5b0c9568901e215b61f61d54d4987a2748f40d48b7f91620acf719f59f6d52ed586853de6756eaefd61'
|
data/Gemfile.lock
CHANGED
data/LICENSE
CHANGED
|
@@ -9,9 +9,5 @@ The above copyright notice and this permission notice shall be included in all c
|
|
|
9
9
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
TO PURCHASE A COMMERCIAL USAGE LICENSE PLEASE VISIT
|
|
14
|
-
https://heliosdev.shop/hot-glue-license
|
|
15
|
-
|
|
16
12
|
OR PURCHASE THE TUTORIALS AT
|
|
17
13
|
https://school.jasonfleetwoodboldt.com/8188/?utm_source=github.com
|
data/README.md
CHANGED
|
@@ -712,6 +712,49 @@ current_user's has_many association (so, for any other "my" family, would be `cu
|
|
|
712
712
|
|
|
713
713
|
This is covered in [Example #4 in the Hot Glue Tutorial](https://school.jfbcodes.com/8188)
|
|
714
714
|
|
|
715
|
+
|
|
716
|
+
##### Using the object inside of the hawk
|
|
717
|
+
In the example above, we aren't using the name of the scaffold within the hawk.
|
|
718
|
+
|
|
719
|
+
However, if you are using the object's name in the hawk (for example `thing` for a `ThingsController`), the view will need this as a local variable `thing` and
|
|
720
|
+
the controller will need this as an instsance variable `@thing`
|
|
721
|
+
|
|
722
|
+
In this special case, Hot Glue converts the local variable `thing` used within your hawk code into instance variable `@thing`
|
|
723
|
+
|
|
724
|
+
For example, if we were building a Job scaffold, here we want restrict follow_up_target_id to a list
|
|
725
|
+
of eligible targets (in our case, with an email address that matches the company's website), we could use a view helper.
|
|
726
|
+
|
|
727
|
+
Notice that `targets_by_company` is defined in the helper below, and we pass it a relation from the current object which is `job`
|
|
728
|
+
|
|
729
|
+
`hot_glue:scaffold Job --hawk='follow_up_target_id{targets_by_company(job.company)}' --code-in-controller='include JobHelper;`
|
|
730
|
+
(notice that it is `job` not `@job`)
|
|
731
|
+
|
|
732
|
+
// app/helpers/job_helper.rb
|
|
733
|
+
```
|
|
734
|
+
module JobHelper
|
|
735
|
+
def targets_by_company(company)
|
|
736
|
+
domain = company.website
|
|
737
|
+
Target.where("email LIKE ?", "%#{domain}%" )
|
|
738
|
+
end
|
|
739
|
+
end
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
The generated controller code looks like:
|
|
743
|
+
```
|
|
744
|
+
modified_params = hawk_params({follow_up_target_id: [targets_by_company(@job.company)]}, modified_params)
|
|
745
|
+
```
|
|
746
|
+
(`hawk_param` is defined in Hot Glue itself. Notice that the `@` was appended to the front of `job`)
|
|
747
|
+
|
|
748
|
+
The edit form will look like this:
|
|
749
|
+
```
|
|
750
|
+
<%= f.collection_select(:follow_up_target_id, targets_by_company(job.company), :id, :name, { prompt: true, selected: job.follow_up_target_id }) %>
|
|
751
|
+
```
|
|
752
|
+
(In the _form view, the `job` is a local variable as we do not rely on the instance variables in subviews.)
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
715
758
|
### `--with-turbo-streams`
|
|
716
759
|
|
|
717
760
|
If and only if you specify `--with-turbo-streams`, your views will contain `turbo_stream_from` directives. Whereas your views will always contain `turbo_frame_tags` (whether or not this flag is specified) and will use the Turbo stream replacement mechanism for non-idempotent actions (create & update). This flag just brings the magic of live-reload to the scaffold interfaces themselves.
|
|
@@ -2420,6 +2463,30 @@ These automatic pickups for partials are detected at build time. This means that
|
|
|
2420
2463
|
|
|
2421
2464
|
# VERSION HISTORY
|
|
2422
2465
|
|
|
2466
|
+
#### 2025-12-24 - v0.7.3
|
|
2467
|
+
|
|
2468
|
+
`--list-back-link-to-parent` (default: false)
|
|
2469
|
+
|
|
2470
|
+
If the parent is itself a big edit, and we got to the nested edit (also a big edit) through a tab showing subview list (loaded lazily via Turbo's built-in mechanism),
|
|
2471
|
+
then we don't typically want the "back to" link at the top of the edit page to take us back to the list of the current object.
|
|
2472
|
+
|
|
2473
|
+
That's because although the list of the current object exists as its own page, it isn't in the normal flow of what the user sees (it is via a lazy-loaded subview).
|
|
2474
|
+
|
|
2475
|
+
The user came to _this_ edit page from the parent's edit page, so we should go back to the parent's edit page.
|
|
2476
|
+
|
|
2477
|
+
Use `--list-back-link-to-parent` to tell this build to use a "Back to ____" link at the top of the edit page (where ____ is the name of the parent)
|
|
2478
|
+
|
|
2479
|
+
Otherwise, the link at the top of the edit page will read "Back to list" and take the user back to the list view of the current build.
|
|
2480
|
+
|
|
2481
|
+
|
|
2482
|
+
#### 2025-12-12 - v0.7.2
|
|
2483
|
+
- Using the object (of the scaffold being built) inside of the hawk now adds `@` to a variable named as the singular name of the scaffold;
|
|
2484
|
+
see "Using the object inside of the hawk"
|
|
2485
|
+
- error catching for missing parent relationships
|
|
2486
|
+
- fixes path for magic button when the controller has a prefix
|
|
2487
|
+
- fix nav active target for a controller with a prefix (the nav template uses the snake_case of the full controller name including prefix)
|
|
2488
|
+
|
|
2489
|
+
|
|
2423
2490
|
#### 2025-11-12 - v0.7.1
|
|
2424
2491
|
- 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
2492
|
-
|
|
@@ -2429,12 +2496,11 @@ These automatic pickups for partials are detected at build time. This means that
|
|
|
2429
2496
|
|
|
2430
2497
|
- `--code-in-controller` option for inserting controller code directly into your controller
|
|
2431
2498
|
|
|
2432
|
-
|
|
2433
2499
|
#### 2025-11-05 - v0.7
|
|
2434
2500
|
|
|
2435
2501
|
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.
|
|
2436
2502
|
|
|
2437
|
-
Remember that Hot Glue's opinionated design has two ways a field is displayed: show (which appears on the list view and is always just viewable), and form (which is
|
|
2503
|
+
Remember that Hot Glue's opinionated design has two ways a field is displayed: show (which appears on the list view and is always just viewable), and form (which is used by both the new and edit actions to display a form). Within the `form` output, the form might be used for either new or edit, and further refinements can be applied to new or edit.
|
|
2438
2504
|
|
|
2439
2505
|
Here's a quick review those methods now:
|
|
2440
2506
|
|
|
@@ -2464,10 +2530,13 @@ Here's a quick review those methods now:
|
|
|
2464
2530
|
Today, with v0.7 of this gem, I'm introducing three more features that are all available from within the `--include` setting.
|
|
2465
2531
|
|
|
2466
2532
|
• Omitted fields: using `-` is omit on list & show; use `=` to omit the field on the form (new & edit)
|
|
2533
|
+
|
|
2467
2534
|
• Dynamic blocks (which can also be omitted using
|
|
2535
|
+
|
|
2468
2536
|
• Set column widths when using specified grouping made (--include contains `:`)
|
|
2469
2537
|
|
|
2470
|
-
For details, see "Layout & Manipulation Features"
|
|
2538
|
+
For details, see "Omitted fields", "Dynamic Blocks", and "Omitted Dynamic Blocks" in the "Layout & Manipulation Features"
|
|
2539
|
+
(those three features were introduced in v0.7)
|
|
2471
2540
|
|
|
2472
2541
|
|
|
2473
2542
|
|
|
@@ -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, :lazy
|
|
34
|
+
:phantom_update_params, :lazy, :list_back_link_to_parent
|
|
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
|
|
|
@@ -130,6 +130,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
130
130
|
class_option :search_position, default: 'vertical' # choices are vertical or horizontal
|
|
131
131
|
class_option :search_clear_button, default: false
|
|
132
132
|
class_option :search_autosearch, default: false
|
|
133
|
+
class_option :list_back_link_to_parent, default: nil
|
|
134
|
+
|
|
133
135
|
|
|
134
136
|
# FOR THE PREDICATE SEARCH
|
|
135
137
|
# TDB
|
|
@@ -492,6 +494,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
492
494
|
@include_object_names = options['include_object_names'] || get_default_from_config(key: :include_object_names)
|
|
493
495
|
|
|
494
496
|
|
|
497
|
+
@list_back_link_to_parent = options['list_back_link_to_parent'] || false
|
|
495
498
|
|
|
496
499
|
if @god
|
|
497
500
|
# @auth = nil
|
|
@@ -754,51 +757,56 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
754
757
|
|
|
755
758
|
if options['phantom_search']
|
|
756
759
|
ps_input = options['phantom_search']
|
|
760
|
+
@phantom_search = {}
|
|
757
761
|
|
|
758
|
-
ps_input =~ /(.*)\[(.*)\]/
|
|
759
|
-
type_and_label, settings = $1, $2
|
|
760
762
|
|
|
763
|
+
ps_input.split(",").each do |input_setting|
|
|
764
|
+
input_setting =~ /(.*)\[(.*)\]/
|
|
765
|
+
type_and_label, settings = $1, $2
|
|
761
766
|
|
|
762
|
-
type = type_and_label.split("_")[0]
|
|
763
|
-
label = type_and_label.split("_")[1]
|
|
764
767
|
|
|
765
|
-
|
|
766
|
-
|
|
768
|
+
type = type_and_label.split("_")[0]
|
|
769
|
+
label = type_and_label.split("_")[1]
|
|
767
770
|
|
|
771
|
+
choices = settings.split("|")
|
|
768
772
|
|
|
769
|
-
@phantom_search[label.to_sym] = {
|
|
770
|
-
type: type,
|
|
771
|
-
name: label.humanize,
|
|
772
|
-
choices: []
|
|
773
|
-
}
|
|
774
773
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
choice_label = choice.split(":")[0]
|
|
781
|
-
choice_scope_negative = choice.split(":")[1]
|
|
782
|
-
choice_scope = choice.split(":")[2]
|
|
783
|
-
end
|
|
774
|
+
@phantom_search[label.to_sym] = {
|
|
775
|
+
type: type,
|
|
776
|
+
name: label.humanize,
|
|
777
|
+
choices: []
|
|
778
|
+
}
|
|
784
779
|
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
780
|
+
choices.each do |choice|
|
|
781
|
+
if type == "radio"
|
|
782
|
+
choice_label = choice.split(":")[0]
|
|
783
|
+
choice_scope = choice.split(":")[1]
|
|
784
|
+
elsif type == "checkboxes"
|
|
785
|
+
choice_label = choice.split(":")[0]
|
|
786
|
+
choice_scope_negative = choice.split(":")[1]
|
|
787
|
+
choice_scope = choice.split(":")[2]
|
|
788
|
+
end
|
|
788
789
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
790
|
+
if choice_scope.nil? || choice_scope.strip.empty?
|
|
791
|
+
choice_scope = "all"
|
|
792
|
+
end
|
|
792
793
|
|
|
793
|
-
|
|
794
|
-
|
|
794
|
+
if choice_scope_negative.nil? || choice_scope_negative.strip.empty?
|
|
795
|
+
choice_scope_negative = "all"
|
|
796
|
+
end
|
|
795
797
|
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
798
|
+
choice_scope = ".#{choice_scope}" if !choice_scope.start_with?(".")
|
|
799
|
+
choice_scope_negative = ".#{choice_scope_negative}" if !choice_scope_negative.start_with?(".")
|
|
800
|
+
|
|
801
|
+
@phantom_search[label.to_sym][:choices] << {
|
|
802
|
+
label: choice_label,
|
|
803
|
+
scope: choice_scope,
|
|
804
|
+
scope_negative: choice_scope_negative,
|
|
805
|
+
}
|
|
806
|
+
end
|
|
801
807
|
end
|
|
808
|
+
|
|
809
|
+
|
|
802
810
|
puts "phantom search #{@phantom_search}"
|
|
803
811
|
else
|
|
804
812
|
@phantom_search = {}
|
|
@@ -906,6 +914,11 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
906
914
|
|
|
907
915
|
end
|
|
908
916
|
|
|
917
|
+
def controller_prefix_snake
|
|
918
|
+
@controller_prefix&.underscore
|
|
919
|
+
end
|
|
920
|
+
|
|
921
|
+
|
|
909
922
|
def setup_hawk_keys
|
|
910
923
|
@hawk_keys = {}
|
|
911
924
|
|
|
@@ -1046,6 +1059,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
1046
1059
|
|
|
1047
1060
|
if @object_owner_sym && !@self_auth
|
|
1048
1061
|
auth_assoc_field = auth_assoc + "_id" unless @god
|
|
1062
|
+
|
|
1049
1063
|
assoc = eval("#{singular_class}.reflect_on_association(:#{@object_owner_sym})")
|
|
1050
1064
|
|
|
1051
1065
|
if assoc
|
|
@@ -1352,17 +1366,21 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
1352
1366
|
top_level: top_level)
|
|
1353
1367
|
end
|
|
1354
1368
|
|
|
1355
|
-
def edit_parent_path_helper
|
|
1369
|
+
def edit_parent_path_helper(top_level = false)
|
|
1356
1370
|
# the path to the edit route of the PARENT
|
|
1357
1371
|
if @nested_set.any? && @nested
|
|
1358
1372
|
"edit_#{@namespace + "_" if @namespace}#{(@nested_set.collect { |x| x[:singular] }.join("_") + "_" if @nested_set.any?)}path(" +
|
|
1359
|
-
"#{@nested_set.collect { |x| x[:singular] }.join(", ")}" + ")"
|
|
1373
|
+
"#{@nested_set.collect { |x| (top_level ? "@": "" ) + x[:singular] }.join(", ")}" + ")"
|
|
1360
1374
|
|
|
1361
1375
|
else
|
|
1362
1376
|
"edit_#{@namespace + "_" if @namespace}path"
|
|
1363
1377
|
end
|
|
1364
1378
|
end
|
|
1365
1379
|
|
|
1380
|
+
def parent_object_name
|
|
1381
|
+
@nested_set.last[:singular]
|
|
1382
|
+
end
|
|
1383
|
+
|
|
1366
1384
|
def datetime_fields_list
|
|
1367
1385
|
@columns.each_with_object({}) do |col, hash|
|
|
1368
1386
|
column = @the_object.columns_hash[col.to_s]
|
|
@@ -1386,7 +1404,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
1386
1404
|
def form_path_edit_helper
|
|
1387
1405
|
HotGlue.optionalized_ternary(namespace: @namespace,
|
|
1388
1406
|
target: @singular,
|
|
1389
|
-
prefix: (@controller_prefix ?
|
|
1407
|
+
prefix: (@controller_prefix ? controller_prefix_snake + "_" : ""),
|
|
1390
1408
|
nested_set: @nested_set,
|
|
1391
1409
|
with_params: false,
|
|
1392
1410
|
put_form: true,
|
|
@@ -1394,17 +1412,18 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
1394
1412
|
end
|
|
1395
1413
|
|
|
1396
1414
|
def delete_path_helper
|
|
1397
|
-
HotGlue.optionalized_ternary(namespace: @namespace,
|
|
1398
|
-
prefix: (@controller_prefix ?
|
|
1415
|
+
res = HotGlue.optionalized_ternary(namespace: @namespace,
|
|
1416
|
+
prefix: (@controller_prefix ? controller_prefix_snake + "_" : ""),
|
|
1399
1417
|
target: @singular,
|
|
1400
1418
|
nested_set: @nested_set,
|
|
1401
1419
|
with_params: false,
|
|
1402
1420
|
put_form: true)
|
|
1421
|
+
res
|
|
1403
1422
|
end
|
|
1404
1423
|
|
|
1405
1424
|
def edit_path_helper
|
|
1406
1425
|
HotGlue.optionalized_ternary(namespace: @namespace,
|
|
1407
|
-
prefix: (@controller_prefix ?
|
|
1426
|
+
prefix: (@controller_prefix ? controller_prefix_snake + "_" : ""),
|
|
1408
1427
|
target: @singular,
|
|
1409
1428
|
nested_set: @nested_set,
|
|
1410
1429
|
modifier: "edit_",
|
|
@@ -1415,7 +1434,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
1415
1434
|
def new_path_name
|
|
1416
1435
|
HotGlue.optionalized_ternary(namespace: @namespace,
|
|
1417
1436
|
target: singular,
|
|
1418
|
-
prefix: (@controller_prefix ?
|
|
1437
|
+
prefix: (@controller_prefix ? controller_prefix_snake + "_" : ""),
|
|
1419
1438
|
nested_set: @nested_set,
|
|
1420
1439
|
modifier: "new_",
|
|
1421
1440
|
with_params: false)
|
|
@@ -1476,14 +1495,23 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
1476
1495
|
if @nested_set.any? && @nested_set.last[:parent_name]
|
|
1477
1496
|
last_parent = @nested_set.last[:parent_name]
|
|
1478
1497
|
foreign_key = eval("#{singular_class}.reflect_on_association(:#{last_parent})").foreign_key
|
|
1479
|
-
|
|
1498
|
+
possible_associations = eval(singular_class).reflect_on_association(@nested_set.last[:parent_name].to_sym)
|
|
1480
1499
|
.klass.reflect_on_all_associations(:has_many)
|
|
1481
|
-
.to_a
|
|
1500
|
+
.to_a
|
|
1482
1501
|
|
|
1502
|
+
|
|
1503
|
+
association = possible_associations.find{|x|
|
|
1483
1504
|
if x.source_reflection
|
|
1484
1505
|
x.table_name == plural
|
|
1485
1506
|
end
|
|
1486
|
-
}
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
if !association
|
|
1510
|
+
klass = eval(singular_class).reflect_on_association(@nested_set.last[:parent_name].to_sym)
|
|
1511
|
+
.klass.to_s
|
|
1512
|
+
raise "Could not find relation #{plural} on #{klass}; maybe add `has_many :#{plural}` "
|
|
1513
|
+
end
|
|
1514
|
+
association = association.plural_name
|
|
1487
1515
|
|
|
1488
1516
|
else
|
|
1489
1517
|
association = plural
|
|
@@ -1552,16 +1580,19 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
1552
1580
|
end
|
|
1553
1581
|
|
|
1554
1582
|
def magic_button_output
|
|
1583
|
+
|
|
1584
|
+
|
|
1555
1585
|
@template_builder.magic_button_output(
|
|
1556
1586
|
path: HotGlue.optionalized_ternary( namespace: @namespace,
|
|
1587
|
+
prefix: (@controller_prefix ? controller_prefix_snake + "_" : ""),
|
|
1557
1588
|
target: @singular,
|
|
1558
1589
|
nested_set: @nested_set,
|
|
1559
1590
|
with_params: false,
|
|
1560
1591
|
put_form: true),
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1592
|
+
big_edit: @big_edit,
|
|
1593
|
+
singular: singular,
|
|
1594
|
+
magic_buttons: @magic_buttons,
|
|
1595
|
+
small_buttons: @small_buttons
|
|
1565
1596
|
)
|
|
1566
1597
|
end
|
|
1567
1598
|
|
|
@@ -1967,9 +1998,18 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
|
1967
1998
|
[name, file_format].compact.join(".")
|
|
1968
1999
|
end
|
|
1969
2000
|
|
|
1970
|
-
def hawk_to_ruby
|
|
2001
|
+
def hawk_to_ruby(in_controller: false) # false for views; true for controller
|
|
2002
|
+
|
|
2003
|
+
|
|
1971
2004
|
res = @hawk_keys.collect { |k, v|
|
|
1972
|
-
|
|
2005
|
+
bind_to_array = v[:bind_to]
|
|
2006
|
+
|
|
2007
|
+
bind_to = bind_to_array.collect{|bt|
|
|
2008
|
+
bt.gsub!(singular, "@#{singular}") if in_controller
|
|
2009
|
+
bt
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
"#{k.to_s}: [#{bind_to.join(".")}]"
|
|
1973
2013
|
}.join(", ")
|
|
1974
2014
|
res
|
|
1975
2015
|
end
|
|
@@ -30,9 +30,12 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
|
30
30
|
next_object = nil
|
|
31
31
|
collect_objects = @nested_set.reverse.collect {|x|
|
|
32
32
|
assoc_name = x[:parent_name] || x[:singular]
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if eval("#{next_object || class_name}.reflect_on_association(:#{assoc_name})").nil?
|
|
34
|
+
raise "***** Unable to find the association `#{assoc_name}` on the class #{next_object || class_name} ..... you probably want to add `belongs_to :#{assoc_name}` to the #{next_object || class_name} object?"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
36
39
|
next_object = eval("#{next_object || class_name}.reflect_on_association(:#{assoc_name})").class_name
|
|
37
40
|
}
|
|
38
41
|
root_object = collect_objects.last
|
|
@@ -119,7 +122,8 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
|
119
122
|
|
|
120
123
|
<%= controller_attachment_orig_filename_pickup_syntax %>
|
|
121
124
|
<%= creation_syntax %>
|
|
122
|
-
<%=
|
|
125
|
+
<%= @code_after_new ? @code_after_new.gsub(";","\n") + "\n" : "" %>
|
|
126
|
+
<% if @hawk_keys.any? %> modified_params = hawk_params({<%= hawk_to_ruby(in_controller: true) %>}, modified_params)<% end %>
|
|
123
127
|
|
|
124
128
|
<% if @pundit %><% @related_sets.each do |key, related_set| %>
|
|
125
129
|
check_<%= related_set[:association_ids_method].to_s %>_permissions(modified_params, :create)<% end %><% end %>
|
|
@@ -219,7 +223,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
|
219
223
|
"#{field_name}: #{field_name}" unless @update_show_only.include?(lookup.to_sym)
|
|
220
224
|
}.join(",") %>)
|
|
221
225
|
<% end %>
|
|
222
|
-
<% if @hawk_keys.any? %> modified_params = hawk_params({<%= hawk_to_ruby %>}, modified_params)<% end %>
|
|
226
|
+
<% if @hawk_keys.any? %> modified_params = hawk_params({<%= hawk_to_ruby(in_controller: true) %>}, modified_params)<% end %>
|
|
223
227
|
<%= controller_attachment_orig_filename_pickup_syntax %>
|
|
224
228
|
@<%= singular_name %>.assign_attributes(modified_params)
|
|
225
229
|
<% if @pundit && !@pundit_policy_override %>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<\%= turbo_frame_tag "<%= @namespace %>__#{dom_id(<%= singular %>)}" do %>
|
|
2
2
|
<div class="cell editable" style="position: relative;">
|
|
3
3
|
<\% if <%= singular %>.errors.any? %>
|
|
4
|
-
<\%= render(partial: "<%= namespace_with_trailing_dash %>errors", locals: {resource: <%= singular
|
|
4
|
+
<\%= render(partial: "<%= namespace_with_trailing_dash %>errors", locals: {resource: <%= "#{singular}" %> }) %>
|
|
5
5
|
<\% end %>
|
|
6
6
|
<h2>Editing <%= singular + " " if @include_object_names %><\%= <%= singular %>.<%= display_class %> %></h2>
|
|
7
7
|
<\%= form_with model: <%= singular %>,
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
<% if @big_edit %>
|
|
2
|
-
<% if include_nav_template %><%= @layout_strategy.page_begin
|
|
2
|
+
<% if include_nav_template %><%= @layout_strategy.page_begin %>
|
|
3
|
+
<\%= render partial: "<%= nav_template %>", locals: {nav: "<%= "#{@controller_prefix ? controller_prefix_snake + "_": ""}#{@plural}" %>"} %><%= @layout_strategy.page_end %><% end %>
|
|
3
4
|
|
|
4
5
|
<div class="container">
|
|
5
6
|
<div class="row">
|
|
6
7
|
<div class="col-md-12">
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
<% if @list_back_link_to_parent %>
|
|
10
|
+
<\%= link_to "⬅️ Back to <%= parent_object_name %>".html_safe, <%= edit_parent_path_helper(true) %> %>
|
|
11
|
+
<% else %>
|
|
12
|
+
<\%= link_to "⬅️ Back to list".html_safe, <%= path_helper_plural(true) %> %>
|
|
13
|
+
<% end %>
|
|
8
14
|
<% end %>
|
|
9
15
|
<\%= render partial: "edit", locals: {<%= singular %>: @<%= singular %><%= @nested_set.any? ? ", " + (@nested_set.collect{|x| "#{x[:singular]}: @#{x[:singular]}"}.join(", ") ) : "" %>} %>
|
|
10
16
|
<% if @big_edit %>
|
|
@@ -1,7 +1,8 @@
|
|
|
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
|
-
<% if include_nav_template %><%= @layout_strategy.page_begin
|
|
4
|
+
<% if include_nav_template %><%= @layout_strategy.page_begin %>
|
|
5
|
+
<\%= render partial: "<%= nav_template %>", locals: {nav: "<%= "#{@controller_prefix ? controller_prefix_snake + "_": ""}#{@plural}" %>"} %><%= @layout_strategy.page_end %><% end %>
|
|
5
6
|
<% if @index_before_list_partial %><\%= render partial: "index_before_list" %><% end %>
|
|
6
7
|
|
|
7
8
|
<%= @layout_strategy.page_begin %>
|
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.7.
|
|
4
|
+
version: 0.7.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: 2025-
|
|
11
|
+
date: 2025-12-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -139,7 +139,7 @@ files:
|
|
|
139
139
|
- script/test
|
|
140
140
|
homepage: https://heliosdev.shop/p/hot-glue?utm_source=rubygems.org&utm_campaign=rubygems_link
|
|
141
141
|
licenses:
|
|
142
|
-
-
|
|
142
|
+
- MIT
|
|
143
143
|
metadata:
|
|
144
144
|
source_code_uri: https://github.com/hot-glue-for-rails/hot-glue
|
|
145
145
|
homepage: https://heliosdev.shop/hot-glue
|