hot-glue 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -2
- data/lib/generators/hot_glue/fields/date_time_field.rb +1 -1
- data/lib/generators/hot_glue/layout_strategy/base.rb +4 -0
- data/lib/generators/hot_glue/layout_strategy/bootstrap.rb +4 -0
- data/lib/generators/hot_glue/markup_templates/erb.rb +7 -2
- data/lib/generators/hot_glue/scaffold_generator.rb +41 -22
- data/lib/generators/hot_glue/templates/controller.rb.erb +16 -11
- data/lib/generators/hot_glue/templates/erb/_edit.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_line.erb +1 -2
- data/lib/generators/hot_glue/templates/erb/_show.erb +3 -2
- data/lib/generators/hot_glue/templates/erb/edit.erb +2 -8
- data/lib/generators/hot_glue/templates/erb/edit.turbo_stream.erb +1 -1
- data/lib/generators/hot_glue/templates/typeahead_views/typeahead_controller.js +0 -1
- data/lib/hot-glue.rb +6 -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: 76c514956d7ff1717545fdb8f6d548e2cfe05b270b5309c91e6b58cc12a42700
|
4
|
+
data.tar.gz: 2cfc8788264527a2eb559054aad0069345c735c24bbc1a195b6a8174facc08da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cf0fd5f2a72c21f99fb79873e35e2c8ec62f6a3cd3fe24b879d6997d3b3d994ceb0482cca5c114e9fd2607e2c12c367d6611da493b68f19ac976c77ecd9c71f
|
7
|
+
data.tar.gz: 1f70c724db1fbdee83d0825b2aa06150b5de5edec9041c82342baef973a93050c0229c449eee4082556d47839a063eb5d52dd038da36430a47a1f2499a0cb809
|
data/README.md
CHANGED
@@ -914,7 +914,7 @@ This means you can be a somewhat lazy about your bang methods, but keep in mind
|
|
914
914
|
|
915
915
|
Finally, you can raise an ActiveRecord error which will also get passed to the user in the flash alert area.
|
916
916
|
|
917
|
-
For more information see [Example
|
917
|
+
For more information see [Example 6 in the Tutorial](https://school.jfbcodes.com/8188)
|
918
918
|
|
919
919
|
|
920
920
|
### `--downnest`
|
@@ -934,6 +934,24 @@ The 'Abcs' portal will display as 5 bootstrap columns instead of the typical 4.
|
|
934
934
|
This puts the downnested portals on top of one another (stacked top to bottom) instead of side-by-side (left to right). This is useful if you have a lot of downnested portals and you want to keep the page from getting too wide.
|
935
935
|
|
936
936
|
|
937
|
+
|
938
|
+
### `--record-scope=`
|
939
|
+
|
940
|
+
Record scope allows you to apply a model based scope for the controller being generated.
|
941
|
+
This is applied on top of all other scopes, searches, and modifiers applied to the built controller.
|
942
|
+
|
943
|
+
`bin/rails :generate hot_glue:scaffold Order --record-scope='.is_open'`
|
944
|
+
|
945
|
+
Be sure to use single quotes (`'`) and don't forget the dot (`.`) before your scope(s).
|
946
|
+
|
947
|
+
Make sure your Order model has a scope `is_open`, like so:
|
948
|
+
|
949
|
+
```
|
950
|
+
scope :is_open, -> {where(state == 'open')}
|
951
|
+
```
|
952
|
+
|
953
|
+
Now all records displayed through the generated controller
|
954
|
+
|
937
955
|
## FLAGS (Options with no values)
|
938
956
|
These options (flags) also uses `--` syntax but do not take any values. Everything is assumed (default) to be false unless specified.
|
939
957
|
|
@@ -999,10 +1017,17 @@ Omits list views.
|
|
999
1017
|
|
1000
1018
|
### `--big-edit`
|
1001
1019
|
|
1002
|
-
If you do not want inline editing of your list items but instead want to
|
1020
|
+
If you do not want inline editing of your list items but instead want to fallback to full-page style behavior for your edit views, use `--big-edit`.
|
1021
|
+
|
1022
|
+
The user will be taken to a full-screen edit page instead of an edit-in-place interaction.
|
1003
1023
|
|
1004
1024
|
When using `--big-edit`, any downnested portals will be displayed on the edit page instead of on the list page.
|
1005
1025
|
|
1026
|
+
Big edit makes all edit and magic button operations happen using `'data-turbo': false`, fully reloading the page and submitting HTML requests instead of TURBO_STREAM requests.
|
1027
|
+
|
1028
|
+
Likewise, the controller's `update` action always redirects instead of using Turbo.
|
1029
|
+
|
1030
|
+
|
1006
1031
|
### `--display-list-after-update`
|
1007
1032
|
|
1008
1033
|
After an update-in-place normally only the edit view is swapped out for the show view of the record you just edited.
|
@@ -1662,6 +1687,26 @@ These automatic pickups for partials are detected at buildtime. This means that
|
|
1662
1687
|
|
1663
1688
|
# VERSION HISTORY
|
1664
1689
|
|
1690
|
+
#### 2024-12-14 v0.6.9
|
1691
|
+
|
1692
|
+
• `--record-scope`
|
1693
|
+
Record scope allows you to apply a model based scope for the controller being generated.
|
1694
|
+
This is applied on top of all other scopes, searches, and modifiers applied to the built controller.
|
1695
|
+
|
1696
|
+
`bin/rails :generate hot_glue:scaffold Order --record-scope='.is_open'`
|
1697
|
+
|
1698
|
+
(You can chain multiple scopes.)
|
1699
|
+
|
1700
|
+
Be sure to use single quote marks (`'`) and don't forget the dot (`.`) before your scope(s).
|
1701
|
+
|
1702
|
+
Make sure your Order model has a scope `is_open`
|
1703
|
+
|
1704
|
+
• `--big-edit` now always uses non-turbo form submits, for update + magic buttons
|
1705
|
+
• refactor of modified datetime feature to prefer current user as set by the --auth setting (will not work in @gd mode). future implemenation will further refine
|
1706
|
+
• when using big edit, `update.turbo_stream.erb` is no longer written
|
1707
|
+
• removes Pundit policy_scope() around new operations
|
1708
|
+
• refactors to how parent objects from a nested controller pass these variables to lower-level partials; this implementation hard-cards the nested set as locals and also builds a `nested_for` key (string)
|
1709
|
+
|
1665
1710
|
|
1666
1711
|
#### 2024-12-05 - v0.6.8
|
1667
1712
|
• fixes in modify_date_inputs_on_params for current_user_object
|
@@ -40,7 +40,7 @@ class DateTimeField < Field
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def form_field_output
|
43
|
-
"<%=
|
43
|
+
"<%= f.datetime_field( :#{name}, value: #{singular}.#{name} && #{singular}.#{name}.change(sec: 0), class: '#{@layout_strategy.form_input_class}' ) %>"
|
44
44
|
end
|
45
45
|
|
46
46
|
def viewable_output
|
@@ -62,9 +62,14 @@ module HotGlue
|
|
62
62
|
text.lines.collect{|line| add_spaces + line}.join("")
|
63
63
|
end
|
64
64
|
|
65
|
-
def magic_button_output(path:,
|
65
|
+
def magic_button_output(path:,
|
66
|
+
singular:,
|
67
|
+
big_edit: ,
|
68
|
+
magic_buttons:, small_buttons: )
|
66
69
|
magic_buttons.collect{ |button_name|
|
67
|
-
"<%= form_with model: #{singular}, url: #{path}, html: {style: 'display: inline', data: {\"turbo-confirm\": 'Are you sure you want to #{button_name} this #{singular}?'
|
70
|
+
"<%= form_with model: #{singular}, url: #{path}, html: {style: 'display: inline', data: {\"turbo-confirm\": 'Are you sure you want to #{button_name} this #{singular}?' " +
|
71
|
+
(big_edit ? ", \"turbo\": false" : "") +
|
72
|
+
"}} do |f| %>" +
|
68
73
|
"<%= f.hidden_field :__#{button_name}, value: \"__#{button_name}\" %>" +
|
69
74
|
"<%= f.submit '#{button_name.titleize}'.html_safe, disabled: (#{singular}.respond_to?(:#{button_name}able?) && ! #{singular}.#{button_name}able? ), class: '#{singular}-button #{@layout_strategy.button_applied_classes} #{@layout_strategy.magic_button_classes}' %>" +
|
70
75
|
"<% end %>"
|
@@ -23,9 +23,12 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
23
23
|
:display_as, :downnest_children, :downnest_object, :hawk_keys, :layout_object,
|
24
24
|
:modify_as,
|
25
25
|
:nest_with, :path, :plural, :sample_file_path, :show_only_data, :singular,
|
26
|
-
:singular_class, :smart_layout, :stacked_downnesting,
|
27
|
-
:
|
28
|
-
:
|
26
|
+
:singular_class, :smart_layout, :stacked_downnesting,
|
27
|
+
:update_show_only, :ownership_field,
|
28
|
+
:layout_strategy, :form_placeholder_labels,
|
29
|
+
:form_labels_position, :pundit,
|
30
|
+
:self_auth, :namespace_value, :record_scope, :related_sets,
|
31
|
+
:search_clear_button, :search_autosearch
|
29
32
|
# important: using an attr_accessor called :namespace indirectly causes a conflict with Rails class_name method
|
30
33
|
# so we use namespace_value instead
|
31
34
|
|
@@ -97,6 +100,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
97
100
|
class_option :code_after_create, default: nil
|
98
101
|
class_option :code_before_update, default: nil
|
99
102
|
class_option :code_after_update, default: nil
|
103
|
+
class_option :record_scope, default: nil
|
104
|
+
|
100
105
|
|
101
106
|
class_option :search, default: nil # set or predicate
|
102
107
|
|
@@ -335,6 +340,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
335
340
|
@new_in_modal = options['new_in_modal'] || false
|
336
341
|
|
337
342
|
@smart_layout = options['smart_layout']
|
343
|
+
@record_scope = options['record_scope']
|
338
344
|
|
339
345
|
@pundit = options['pundit']
|
340
346
|
if @pundit.nil?
|
@@ -1195,10 +1201,16 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1195
1201
|
end
|
1196
1202
|
|
1197
1203
|
def current_user_object
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1204
|
+
|
1205
|
+
# TODO: in god mode, there's no way for the time input
|
1206
|
+
# to know who the current user under this design
|
1207
|
+
# for timeinput = user_centered , we need to know who the current user is
|
1208
|
+
# so we can set the time zone to the user's time zone
|
1209
|
+
#
|
1210
|
+
if options['auth']
|
1211
|
+
options['auth']
|
1212
|
+
elsif @god
|
1213
|
+
# do we use current_user here
|
1202
1214
|
"nil"
|
1203
1215
|
end
|
1204
1216
|
end
|
@@ -1209,14 +1221,15 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1209
1221
|
|
1210
1222
|
def magic_button_output
|
1211
1223
|
@template_builder.magic_button_output(
|
1212
|
-
path: HotGlue.optionalized_ternary(namespace: @namespace,
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1224
|
+
path: HotGlue.optionalized_ternary( namespace: @namespace,
|
1225
|
+
target: @singular,
|
1226
|
+
nested_set: @nested_set,
|
1227
|
+
with_params: true,
|
1228
|
+
put_form: true),
|
1229
|
+
big_edit: @big_edit,
|
1230
|
+
singular: singular,
|
1231
|
+
magic_buttons: @magic_buttons,
|
1232
|
+
small_buttons: @small_buttons
|
1220
1233
|
)
|
1221
1234
|
end
|
1222
1235
|
|
@@ -1245,7 +1258,6 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1245
1258
|
formats.each do |format|
|
1246
1259
|
source_filename = cc_filename_with_extensions("#{@markup}/#{view}", "#{@markup}")
|
1247
1260
|
dest_filename = cc_filename_with_extensions("#{view}", "#{@markup}")
|
1248
|
-
# byebug
|
1249
1261
|
dest_filepath = File.join("#{filepath_prefix}app/views#{namespace_with_dash}",
|
1250
1262
|
@controller_build_folder, dest_filename)
|
1251
1263
|
|
@@ -1361,7 +1373,10 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1361
1373
|
|
1362
1374
|
unless @no_edit
|
1363
1375
|
res << 'edit'
|
1364
|
-
|
1376
|
+
|
1377
|
+
unless @big_edit
|
1378
|
+
res << 'update'
|
1379
|
+
end
|
1365
1380
|
end
|
1366
1381
|
|
1367
1382
|
res
|
@@ -1527,10 +1542,12 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1527
1542
|
end
|
1528
1543
|
|
1529
1544
|
if pundit
|
1530
|
-
res << " @#{ plural_name } = policy_scope(#{ object_scope }).page(params[:page])#{ n_plus_one_includes }#{ ".per(per)" if @paginate_per_page_selector }"
|
1545
|
+
res << " @#{ plural_name } = policy_scope(#{ object_scope })#{record_scope}.page(params[:page])#{ n_plus_one_includes }#{ ".per(per)" if @paginate_per_page_selector }"
|
1531
1546
|
else
|
1532
1547
|
if !@self_auth
|
1533
|
-
|
1548
|
+
|
1549
|
+
res << spaces(4) + "@#{ plural_name } = #{ object_scope.gsub("@",'') }#{ n_plus_one_includes }#{record_scope}"
|
1550
|
+
|
1534
1551
|
if @search_fields
|
1535
1552
|
res << @search_fields.collect{ |field|
|
1536
1553
|
wqs = @columns_map[field.to_sym].where_query_statement
|
@@ -1539,12 +1556,14 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1539
1556
|
end
|
1540
1557
|
}.compact.join
|
1541
1558
|
end
|
1559
|
+
res << ".page(params[:page])#{ '.per(per)' if @paginate_per_page_selector }"
|
1560
|
+
|
1542
1561
|
elsif @nested_set[0] && @nested_set[0][:optional]
|
1543
|
-
res << "@#{ plural_name } = #{ class_name }.all"
|
1562
|
+
res << "@#{ plural_name } = #{ class_name }.#{record_scope}.all"
|
1544
1563
|
else
|
1545
|
-
res << "@#{ plural_name } = #{ class_name }.where(id: #{ auth_object.gsub("@",'') }.id)#{ n_plus_one_includes }"
|
1564
|
+
res << "@#{ plural_name } = #{ class_name }.#{record_scope}.where(id: #{ auth_object.gsub("@",'') }.id)#{ n_plus_one_includes }"
|
1546
1565
|
|
1547
|
-
res << ".page(params[:page])#{ ".per(per)" if @paginate_per_page_selector }"
|
1566
|
+
res << "#{record_scope}.page(params[:page])#{ ".per(per)" if @paginate_per_page_selector }"
|
1548
1567
|
end
|
1549
1568
|
end
|
1550
1569
|
res << "\n"
|
@@ -60,20 +60,20 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
60
60
|
<% if !@self_auth %>
|
61
61
|
def load_<%= singular_name %>
|
62
62
|
<% if @nested_set[0] && @nested_set[0][:optional] %>if params.include?(:<%= @nested_set.last[:singular] %>_id)
|
63
|
-
@<%= singular_name %> = <%= object_scope.gsub("@",'') %>.find(params[:id])
|
64
|
-
else <% end %>@<%= singular_name %> = <%= object_scope %>.find(params[:id])<% if @nested_set[0] && @nested_set[0][:optional] %>
|
63
|
+
@<%= singular_name %> = <%= object_scope.gsub("@",'') %><%= @record_scope %>.find(params[:id])
|
64
|
+
else <% end %>@<%= singular_name %> = <%= object_scope %><%= @record_scope %>.find(params[:id])<% if @nested_set[0] && @nested_set[0][:optional] %>
|
65
65
|
end<% end %>
|
66
66
|
end
|
67
67
|
<% else %>
|
68
68
|
def load_<%= singular_name %>
|
69
|
-
@<%= singular_name %> = (<%= auth_object.gsub("@",'') %><%= " if params.include?(:#{@nested_set[0][:singular]}_id)" if @nested_set.any? && @nested_set[0][:optional] %>)<% if @nested_set.any? && @nested_set[0][:optional] %> || <%= class_name %>.find(params[:id])<% end %>
|
69
|
+
@<%= singular_name %> = (<%= auth_object.gsub("@",'') %><%= " if params.include?(:#{@nested_set[0][:singular]}_id)" if @nested_set.any? && @nested_set[0][:optional] %>)<% if @nested_set.any? && @nested_set[0][:optional] %> || <%= class_name %>.find(params[:id])<% end %><%= @record_scope %>
|
70
70
|
end<% end %>
|
71
71
|
<% if @paginate_per_page_selector %>def per
|
72
72
|
params[:per] || 10
|
73
73
|
end<% end %>
|
74
74
|
<% unless @no_list %>
|
75
75
|
def load_all_<%= plural %>
|
76
|
-
|
76
|
+
<%= load_all_code %>
|
77
77
|
end
|
78
78
|
|
79
79
|
def index<% if @search == "set" %>
|
@@ -88,9 +88,9 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
88
88
|
end<% end %>
|
89
89
|
|
90
90
|
<% if create_action %> def new<% if @object_owner_sym %>
|
91
|
-
@<%= singular_name %> =
|
92
|
-
@<%= singular_name %> =
|
93
|
-
@<%= singular_name %> =
|
91
|
+
@<%= singular_name %> = <%= class_name %>.new<% if eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>(<%= @object_owner_sym %>: <%= @object_owner_eval %>)<% end %><% elsif @object_owner_optional && any_nested? %>
|
92
|
+
@<%= singular_name %> = <%= class_name %>.new({}.merge(<%= @nested_set.last[:singular] %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}))<% else %>
|
93
|
+
@<%= singular_name %> = <%= class_name %>.new(<% if any_nested? %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)<% end %>
|
94
94
|
<% if @pundit %>authorize @<%= singular_name %><% end %><% if @pundit %>
|
95
95
|
@action = 'new'
|
96
96
|
rescue Pundit::NotAuthorizedError
|
@@ -101,7 +101,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
101
101
|
|
102
102
|
def create
|
103
103
|
flash[:notice] = +''
|
104
|
-
modified_params = modify_date_inputs_on_params(<%= singular_name %>_params.dup, <%= current_user_object %>, <%= datetime_fields_list %>)<% if @object_owner_sym &&
|
104
|
+
modified_params = modify_date_inputs_on_params(<%= singular_name %>_params.dup, <%= current_user_object %>, <%= datetime_fields_list %>)<% if @object_owner_sym && eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>
|
105
105
|
modified_params = modified_params.merge(<%= @object_owner_sym %>: <%= @object_owner_eval %>) <% elsif @object_owner_optional && any_nested? %>
|
106
106
|
modified_params = modified_params.merge(<%= @object_owner_name %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}) <% end %>
|
107
107
|
|
@@ -123,6 +123,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
123
123
|
nested_set: @nested_set,
|
124
124
|
modifier: 'edit_',
|
125
125
|
with_params: true,
|
126
|
+
instance_last_item: true,
|
126
127
|
put_form: true).gsub("(#{singular}", "(@#{singular}") %><% end %>
|
127
128
|
else
|
128
129
|
flash[:alert] = "Oops, your <%= singular_name %> could not be created. #{@hawk_alarm}"
|
@@ -138,11 +139,13 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
138
139
|
<% unless @no_edit %>
|
139
140
|
def show<% if @pundit %>
|
140
141
|
authorize @<%= singular %><% end %>
|
141
|
-
redirect_to <%=
|
142
|
+
redirect_to <%= HotGlue.optionalized_ternary(namespace: @namespace,
|
142
143
|
target: @singular,
|
144
|
+
top_level: false,
|
143
145
|
nested_set: @nested_set,
|
144
146
|
modifier: 'edit_',
|
145
147
|
with_params: true,
|
148
|
+
instance_last_item: true,
|
146
149
|
put_form: true).gsub("(#{singular}", "(@#{singular}") %>
|
147
150
|
end
|
148
151
|
|
@@ -165,7 +168,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
165
168
|
end
|
166
169
|
<% end %>
|
167
170
|
|
168
|
-
modified_params = modify_date_inputs_on_params(<% if @update_show_only %>update_<% end %><%= singular_name %>_params.dup<%= controller_update_params_tap_away_magic_buttons %>, <%= current_user_object %>, <%= datetime_fields_list %>)
|
171
|
+
modified_params = modify_date_inputs_on_params(<% if @update_show_only %>update_<% end %><%= singular_name %>_params.dup<%= controller_update_params_tap_away_magic_buttons %>, <%= current_user_object %>, <%= datetime_fields_list %>)<% if @object_owner_sym && eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>
|
169
172
|
modified_params = modified_params.merge(<%= @object_owner_sym %>: <%= @object_owner_eval %>) <% elsif @object_owner_optional && any_nested? %>
|
170
173
|
modified_params = modified_params.merge(<%= @object_owner_name %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}) <% end %>
|
171
174
|
<% if @pundit %><% @related_sets.each do |key, related_set| %>
|
@@ -186,7 +189,9 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
186
189
|
<% if @display_list_after_update %> load_all_<%= plural %><% end %>
|
187
190
|
flash[:notice] << "Saved #{@<%= singular %>.<%= display_class %>}"
|
188
191
|
flash[:alert] = @hawk_alarm if @hawk_alarm
|
189
|
-
<% unless @big_edit %>render :update, status: :unprocessable_entity<% else %>
|
192
|
+
<% unless @big_edit %>render :update, status: :unprocessable_entity<% else %>
|
193
|
+
redirect_to <%= path_helper_plural(false) %>
|
194
|
+
<% end %>
|
190
195
|
else
|
191
196
|
flash[:alert] = "<%= singular_name.titlecase %> could not be saved. #{@hawk_alarm}"
|
192
197
|
@action = 'edit'
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<\%= render(partial: "<%= namespace_with_trailing_dash %>errors", locals: {resource: <%= singular %> }) %>
|
5
5
|
<\% end %>
|
6
6
|
<h2>Editing <\%= <%= singular %>.<%= display_class %> %></h2>
|
7
|
-
<\%= form_with model: <%= singular %>, url: <%= form_path_edit_helper %> do |f| %>
|
7
|
+
<\%= form_with model: <%= singular %>, url: <%= form_path_edit_helper %><%= ", html: {'data-turbo': false}" if @big_edit %> do |f| %>
|
8
8
|
<\%= 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 %> \%>
|
9
9
|
<% 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 %>
|
10
10
|
<\% end %>
|
@@ -1,8 +1,7 @@
|
|
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
|
5
|
-
|
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 %> } %>
|
6
5
|
</div>
|
7
6
|
<\% end %>
|
8
7
|
|
@@ -25,14 +25,15 @@
|
|
25
25
|
<% end %>
|
26
26
|
|
27
27
|
|
28
|
-
<% if @list_after_each_row_partial %><\%= render partial: "list_after_each_row", locals: {<%= @singular %>: <%= @singular
|
28
|
+
<% if @list_after_each_row_partial %><\%= render partial: "<%= namespace_with_trailing_dash %><%= @controller_build_folder %>/list_after_each_row", locals: {<%= @singular %>: <%= @singular %><% if @nested_set.any? %>, <%= @nested_set.collect{|x| x[:singular] + ": " + x[:singular] }.join(", ") %><% end %>} %>
|
29
|
+
<% end %>
|
29
30
|
|
30
31
|
<%= @layout_strategy.button_style %>
|
31
32
|
<div class=" scaffold-line-buttons <%= @layout_strategy.column_classes_for_button_column %>" <%= @layout_strategy.button_style %>>
|
32
33
|
<%= magic_button_output %>
|
33
34
|
|
34
35
|
<% if destroy_action %>
|
35
|
-
<\%= form_with url: <%= delete_path_helper %>, html: {data: {'<%= @ujs_syntax ? 'confirm' : 'turbo-confirm' %>': "Are you sure you want to delete #{ <%= @singular + "." + display_class %> }?"}, style: "display: inline-block;"}, method: :delete do |f| %>
|
36
|
+
<\%= form_with url: <%= delete_path_helper %>, html: {data: {'<%= @ujs_syntax ? 'confirm' : 'turbo-confirm' %>': "Are you sure you want to delete #{ <%= @singular + "." + display_class %> }?" }, style: "display: inline-block;"}, method: :delete do |f| %>
|
36
37
|
<\%= f.submit "Delete".html_safe, class: "delete-<%= singular %>-button btn btn-primary btn-sm" %>
|
37
38
|
<\% end %>
|
38
39
|
<% end %>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<div class="col-md-12">
|
5
5
|
<\%= 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) %> %>
|
6
6
|
<% end %>
|
7
|
-
<\%= render partial: "edit", locals: {<%= singular %>: @<%= singular %><%= @nested_set.
|
7
|
+
<\%= render partial: "edit", locals: {<%= singular %>: @<%= singular %><%= @nested_set.any? ? () : "" %>} %>
|
8
8
|
<% if @big_edit %>
|
9
9
|
</div>
|
10
10
|
</div>
|
@@ -21,13 +21,7 @@
|
|
21
21
|
<% downnest_object_name = eval("#{downnest_class}.table_name") %>
|
22
22
|
<% downnest_style = @layout_strategy.downnest_style %>
|
23
23
|
|
24
|
-
<\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest_object_name %>/list", locals: {
|
25
|
-
<%= @singular %>: @<%= @singular %>,
|
26
|
-
<%= downnest_object_name %>: @<%= @singular %>.<%= downnest %>
|
27
|
-
}
|
28
|
-
.merge({nested_for: "<% if @nested_set.any? %>#{nested_for + "__" if defined?(nested_for)}<% end %><%= @singular %>-#{@<%= @singular %>.id}"})
|
29
|
-
<%= @nested_set.collect{|arg| ".merge(defined?(@#{arg[:singular]}) ? {#{arg[:singular]}: @#{arg[:singular]}} : {} )"}.join("\n") %>
|
30
|
-
\%>
|
24
|
+
<\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest_object_name %>/list", locals: {<%= @singular %>: @<%= @singular %>, <%= downnest_object_name %>: @<%= @singular %>.<%= downnest %><% 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 %> } \%>
|
31
25
|
|
32
26
|
</div>
|
33
27
|
</div>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<\%= turbo_stream.replace "<%= @namespace %>__#{dom_id(
|
1
|
+
<\%= turbo_stream.replace "<%= @namespace %>__#{dom_id(@<%= singular %>)}" do %>
|
2
2
|
<\%= render 'edit', locals: { <%= singular %>: @<%= singular %><%= @nested_set.collect{|arg| ", #{arg[:singular]}: @#{arg[:singular]} " }.join("") %> } %>
|
3
3
|
<\% end %>
|
data/lib/hot-glue.rb
CHANGED
@@ -25,19 +25,22 @@ module HotGlue
|
|
25
25
|
modifier: "",
|
26
26
|
with_params: false,
|
27
27
|
top_level: false,
|
28
|
-
put_form: false
|
28
|
+
put_form: false,
|
29
|
+
instance_last_item: false )
|
29
30
|
instance_sym = top_level ? "@" : ""
|
30
31
|
|
32
|
+
|
31
33
|
if nested_set.nil? || nested_set.empty?
|
32
34
|
return modifier + "#{(namespace + '_') if namespace}#{target}_path" + (("(#{instance_sym}#{target})" if put_form) || "")
|
33
35
|
elsif nested_set[0][:optional] == false
|
34
36
|
|
35
|
-
|
37
|
+
res = modifier + ((namespace + "_" if namespace) || "") + nested_set.collect{|x|
|
36
38
|
x[:singular] + "_"
|
37
39
|
}.join() + target + "_path" + (("(#{nested_set.collect{
|
38
40
|
|x| instance_sym + x[:singular] }.join(",")
|
39
|
-
}#{ put_form ? ',' + instance_sym + target : '' })") || "")
|
41
|
+
}#{ put_form ? ',' + (instance_last_item ? "@" : instance_sym) + target : '' })") || "")
|
40
42
|
|
43
|
+
res
|
41
44
|
|
42
45
|
else
|
43
46
|
# copy the first item, make a ternery in this cycle, and recursively move to both the
|
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.9
|
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: 2024-12-
|
11
|
+
date: 2024-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|