hot-glue 0.5.3 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +0 -1
- data/.gitignore +12 -5
- data/README.md +162 -42
- data/lib/generators/hot_glue/install_generator.rb +13 -13
- data/lib/generators/hot_glue/layout/builder.rb +11 -8
- data/lib/generators/hot_glue/layout_strategy/base.rb +31 -0
- data/lib/generators/hot_glue/layout_strategy/bootstrap.rb +41 -0
- data/lib/generators/hot_glue/layout_strategy/hot_glue.rb +82 -0
- data/lib/generators/hot_glue/layout_strategy/tailwind.rb +28 -0
- data/lib/generators/hot_glue/markup_templates/base.rb +3 -3
- data/lib/generators/hot_glue/markup_templates/erb.rb +90 -80
- data/lib/generators/hot_glue/scaffold_generator.rb +103 -110
- data/lib/generators/hot_glue/templates/controller.rb.erb +14 -40
- data/lib/generators/hot_glue/templates/erb/_form.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_line.erb +3 -3
- data/lib/generators/hot_glue/templates/erb/_list.erb +6 -11
- data/lib/generators/hot_glue/templates/erb/_new_button.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_new_form.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_show.erb +3 -3
- data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +2 -2
- data/lib/generators/hot_glue/templates/erb/destroy.turbo_stream.erb +2 -2
- data/lib/generators/hot_glue/templates/erb/edit.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/edit.turbo_stream.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/index.erb +3 -6
- data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +1 -1
- data/lib/generators/hot_glue/templates/system_spec.rb.erb +3 -1
- data/lib/hot-glue.rb +0 -4
- data/lib/hotglue/engine.rb +1 -1
- data/lib/hotglue/version.rb +1 -1
- metadata +6 -3
- data/lib/generators/hot_glue/helpers.rb +0 -13
@@ -7,11 +7,18 @@ require_relative './markup_templates/erb'
|
|
7
7
|
# require_relative './markup_templates/slim'
|
8
8
|
|
9
9
|
require_relative './layout/builder'
|
10
|
+
require_relative './layout_strategy/base'
|
11
|
+
require_relative './layout_strategy/bootstrap'
|
12
|
+
require_relative './layout_strategy/hot_glue'
|
13
|
+
require_relative './layout_strategy/tailwind'
|
14
|
+
|
10
15
|
|
11
16
|
module HotGlue
|
12
17
|
class Error < StandardError
|
13
18
|
end
|
14
19
|
|
20
|
+
|
21
|
+
|
15
22
|
def self.construct_downnest_object(input)
|
16
23
|
res = input.split(",").map { |child|
|
17
24
|
child_name = child.gsub("+","")
|
@@ -21,18 +28,14 @@ module HotGlue
|
|
21
28
|
Hash[*res.collect{|hash| hash.collect{|key,value| [key,value].flatten}.flatten}.flatten]
|
22
29
|
end
|
23
30
|
|
24
|
-
def self.optionalized_ternary(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
def self.optionalized_ternary(namespace: nil,
|
32
|
+
target:,
|
33
|
+
nested_set:,
|
34
|
+
modifier: "",
|
35
|
+
with_params: false,
|
36
|
+
top_level: false,
|
37
|
+
put_form: false)
|
32
38
|
instance_sym = top_level ? "@" : ""
|
33
|
-
|
34
|
-
put_form = params[:put_form] || false
|
35
|
-
|
36
39
|
if nested_set.nil? || nested_set.empty?
|
37
40
|
return modifier + "#{(namespace + '_') if namespace}#{target}_path" + (("(#{instance_sym}#{target})" if put_form) || "")
|
38
41
|
elsif nested_set[0][:optional] == false
|
@@ -50,17 +53,23 @@ module HotGlue
|
|
50
53
|
nonoptional[:optional] = false
|
51
54
|
rest_of_nest = nested_set[1..-1]
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
56
|
+
is_present_path = HotGlue.optionalized_ternary(
|
57
|
+
namespace: namespace,
|
58
|
+
target: target,
|
59
|
+
modifier: modifier,
|
60
|
+
top_level: top_level,
|
61
|
+
with_params: with_params,
|
62
|
+
put_form: put_form,
|
63
|
+
nested_set: [nonoptional, *rest_of_nest])
|
64
|
+
|
65
|
+
is_missing_path = HotGlue.optionalized_ternary(
|
66
|
+
namespace: namespace,
|
67
|
+
target: target,
|
68
|
+
modifier: modifier,
|
69
|
+
top_level: top_level,
|
70
|
+
with_params: with_params,
|
71
|
+
put_form: put_form,
|
72
|
+
nested_set: rest_of_nest )
|
64
73
|
return "defined?(#{instance_sym + nested_set[0][:singular]}) ? #{is_present_path} : #{is_missing_path}"
|
65
74
|
end
|
66
75
|
end
|
@@ -78,8 +87,6 @@ module HotGlue
|
|
78
87
|
display_column = "display_name"
|
79
88
|
elsif assoc_class.new.respond_to?("email")
|
80
89
|
display_column = "email"
|
81
|
-
# else # SHOULD BE UNREACHABLE
|
82
|
-
# raise("this should have been caught by the checker in the initializer")
|
83
90
|
end
|
84
91
|
display_column
|
85
92
|
end
|
@@ -89,6 +96,7 @@ module HotGlue
|
|
89
96
|
|
90
97
|
source_root File.expand_path('templates', __dir__)
|
91
98
|
attr_accessor :path, :singular, :plural, :singular_class, :nest_with
|
99
|
+
attr_accessor :columns, :downnest_children, :layout_object
|
92
100
|
|
93
101
|
class_option :singular, type: :string, default: nil
|
94
102
|
class_option :plural, type: :string, default: nil
|
@@ -122,7 +130,8 @@ module HotGlue
|
|
122
130
|
class_option :smart_layout, type: :boolean, default: false
|
123
131
|
class_option :markup, type: :string, default: nil # deprecated -- use in app config instead
|
124
132
|
class_option :layout, type: :string, default: nil # if used here it will override what is in the config
|
125
|
-
class_option :hawk, type: :string, default: nil
|
133
|
+
class_option :hawk, type: :string, default: nil
|
134
|
+
class_option :with_turbo_streams, type: :boolean, default: false
|
126
135
|
|
127
136
|
class_option :no_list_label, type: :boolean, default: false
|
128
137
|
|
@@ -149,6 +158,7 @@ module HotGlue
|
|
149
158
|
raise(HotGlue::Error, message)
|
150
159
|
end
|
151
160
|
|
161
|
+
@meta_args = meta_args
|
152
162
|
|
153
163
|
if options['specs_only'] && options['no_specs']
|
154
164
|
raise(HotGlue::Error, "*** Oops: You seem to have specified both the --specs-only flag and --no-specs flags. this doesn't make any sense, so I am aborting. Aborting.")
|
@@ -179,32 +189,38 @@ module HotGlue
|
|
179
189
|
yaml_from_config = YAML.load(File.read("config/hot_glue.yml"))
|
180
190
|
@markup = yaml_from_config[:markup]
|
181
191
|
|
182
|
-
if
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
elsif @markup == "haml"
|
187
|
-
raise(HotGlue::Error, "HAML IS NOT IMPLEMENTED")
|
192
|
+
if options['layout']
|
193
|
+
layout = options['layout']
|
194
|
+
else
|
195
|
+
layout = yaml_from_config[:layout]
|
188
196
|
|
197
|
+
if !['hotglue', 'bootstrap', 'tailwind'].include? layout
|
198
|
+
raise "Invalid option #{layout} in Hot glue config (config/hot_glue.yml). You must either use --layout= when generating or have a file config/hotglue.yml; specify layout as either 'hotglue' or 'bootstrap'"
|
199
|
+
end
|
189
200
|
end
|
190
201
|
|
202
|
+
@layout_strategy =
|
203
|
+
case layout
|
204
|
+
when 'bootstrap'
|
205
|
+
LayoutStrategy::Bootstrap.new(self)
|
206
|
+
when 'tailwind'
|
207
|
+
LayoutStrategy::Tailwind.new(self)
|
208
|
+
when 'hotglue'
|
209
|
+
LayoutStrategy::HotGlue.new(self)
|
210
|
+
end
|
191
211
|
|
192
|
-
if !options['layout']
|
193
|
-
@layout = yaml_from_config[:layout]
|
194
212
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
213
|
+
if @markup == "erb"
|
214
|
+
@template_builder = HotGlue::ErbTemplate.new(layout_strategy: @layout_strategy)
|
215
|
+
elsif @markup == "slim"
|
216
|
+
raise(HotGlue::Error, "SLIM IS NOT IMPLEMENTED")
|
217
|
+
elsif @markup == "haml"
|
218
|
+
raise(HotGlue::Error, "HAML IS NOT IMPLEMENTED")
|
200
219
|
end
|
201
220
|
|
202
221
|
args = meta_args[0]
|
203
|
-
|
204
|
-
|
205
222
|
@singular = args.first.tableize.singularize # should be in form hello_world
|
206
223
|
|
207
|
-
|
208
224
|
if @singular.include?("/")
|
209
225
|
@singular = @singular.split("/").last
|
210
226
|
end
|
@@ -291,8 +307,7 @@ module HotGlue
|
|
291
307
|
raise HotGlue::Error, "You specified both --smart-layout and also specified grouping mode (there is a : character in your field include list); you must remove the colon(s) from your --include tag or remove the --smart-layout option"
|
292
308
|
end
|
293
309
|
|
294
|
-
|
295
|
-
@container_name = @layout == "hotglue" ? "scaffold-container" : "container-fluid"
|
310
|
+
@container_name = @layout_strategy.container_name
|
296
311
|
@downnest = options['downnest'] || false
|
297
312
|
|
298
313
|
@downnest_children = [] # TODO: defactor @downnest_children in favor of downnest_object
|
@@ -352,7 +367,6 @@ module HotGlue
|
|
352
367
|
plural: arg.pluralize,
|
353
368
|
optional: is_optional
|
354
369
|
}
|
355
|
-
|
356
370
|
}
|
357
371
|
puts "NESTING: #{@nested_set}"
|
358
372
|
end
|
@@ -360,7 +374,6 @@ module HotGlue
|
|
360
374
|
# OBJECT OWNERSHIP & NESTING
|
361
375
|
@reference_name = HotGlue.derrive_reference_name(singular_class)
|
362
376
|
if @auth && @self_auth
|
363
|
-
# byebug
|
364
377
|
@object_owner_sym = @auth.gsub("current_", "").to_sym
|
365
378
|
@object_owner_eval = @auth
|
366
379
|
@object_owner_optional = false
|
@@ -368,18 +381,15 @@ module HotGlue
|
|
368
381
|
|
369
382
|
|
370
383
|
elsif @auth && ! @self_auth && @nested_set.none? && !@auth.include?(".")
|
371
|
-
# byebug
|
372
384
|
@object_owner_sym = @auth.gsub("current_", "").to_sym
|
373
385
|
@object_owner_eval = @auth
|
374
386
|
@object_owner_optional = false
|
375
387
|
@object_owner_name = @auth.gsub("current_", "").to_s
|
376
388
|
|
377
389
|
elsif @auth && @auth.include?(".")
|
378
|
-
# byebug
|
379
390
|
@object_owner_sym = nil
|
380
391
|
@object_owner_eval = @auth
|
381
392
|
else
|
382
|
-
# byebug
|
383
393
|
if @nested_set.any?
|
384
394
|
@object_owner_sym = @nested_set.last[:singular].to_sym
|
385
395
|
@object_owner_eval = "@#{@nested_set.last[:singular]}"
|
@@ -404,18 +414,16 @@ module HotGlue
|
|
404
414
|
|
405
415
|
buttons_width = ((!@no_edit && 1) || 0) + ((!@no_delete && 1) || 0) + @magic_buttons.count
|
406
416
|
|
407
|
-
builder = HotGlue::Layout::Builder.new(
|
408
|
-
include_setting: options['include'],
|
417
|
+
builder = HotGlue::Layout::Builder.new(include_setting: options['include'],
|
409
418
|
downnest_object: @downnest_object,
|
410
419
|
buttons_width: buttons_width,
|
411
420
|
columns: @columns,
|
412
|
-
smart_layout: @smart_layout
|
413
|
-
})
|
421
|
+
smart_layout: @smart_layout )
|
414
422
|
@layout_object = builder.construct
|
415
423
|
|
416
424
|
@menu_file_exists = true if @nested_set.none? && File.exists?("#{Rails.root}/app/views/#{namespace_with_trailing_dash}_menu.#{@markup}")
|
417
425
|
|
418
|
-
|
426
|
+
@turbo_streams = !!options['with_turbo_streams']
|
419
427
|
end
|
420
428
|
|
421
429
|
def setup_hawk_keys
|
@@ -446,7 +454,6 @@ module HotGlue
|
|
446
454
|
if @object_owner_sym && ! @self_auth
|
447
455
|
auth_assoc_field = auth_assoc + "_id" unless @god
|
448
456
|
assoc = eval("#{singular_class}.reflect_on_association(:#{@object_owner_sym})")
|
449
|
-
# byebug
|
450
457
|
if assoc
|
451
458
|
@ownership_field = assoc.name.to_s + "_id"
|
452
459
|
elsif ! @nested_set.any?
|
@@ -585,19 +592,10 @@ module HotGlue
|
|
585
592
|
end
|
586
593
|
|
587
594
|
def list_column_headings
|
588
|
-
if @layout == "bootstrap"
|
589
|
-
column_width = @layout_object[:columns][:size_each]
|
590
|
-
col_identifier = "col-md-#{column_width}"
|
591
|
-
elsif @layout == "hotglue"
|
592
|
-
column_width = each_col * @columns.count
|
593
|
-
col_identifier = "scaffold-cell"
|
594
|
-
end
|
595
|
-
|
596
595
|
@template_builder.list_column_headings(
|
597
596
|
columns: @layout_object[:columns][:container],
|
598
|
-
col_identifier:
|
599
|
-
|
600
|
-
column_width: column_width
|
597
|
+
col_identifier: @layout_strategy.column_classes_for_column_headings,
|
598
|
+
column_width: @layout_strategy.column_width
|
601
599
|
)
|
602
600
|
end
|
603
601
|
|
@@ -618,6 +616,11 @@ module HotGlue
|
|
618
616
|
}.join(", ")
|
619
617
|
end
|
620
618
|
|
619
|
+
|
620
|
+
def regenerate_me_code
|
621
|
+
"rails generate hot_glue:scaffold #{ @meta_args[0][0] } #{@meta_args[1].join(" ")}"
|
622
|
+
end
|
623
|
+
|
621
624
|
def object_parent_mapping_as_argument_for_specs
|
622
625
|
if @nested_set.any?
|
623
626
|
", " + @nested_set.last[:singular] + ": " + @nested_set.last[:singular]
|
@@ -898,6 +901,15 @@ module HotGlue
|
|
898
901
|
)
|
899
902
|
end
|
900
903
|
|
904
|
+
def nav_template
|
905
|
+
"#{namespace_with_trailing_dash}nav"
|
906
|
+
end
|
907
|
+
|
908
|
+
|
909
|
+
def include_nav_template
|
910
|
+
File.exists?("#{Rails.root}/app/views/#{namespace_with_trailing_dash}_nav.html.#{@markup}")
|
911
|
+
end
|
912
|
+
|
901
913
|
def copy_view_files
|
902
914
|
return if @specs_only
|
903
915
|
all_views.each do |view|
|
@@ -940,6 +952,29 @@ module HotGlue
|
|
940
952
|
|
941
953
|
end
|
942
954
|
|
955
|
+
def append_model_callbacks
|
956
|
+
# somehow the generator invokes this
|
957
|
+
|
958
|
+
if options['with_turbo_streams'] == true
|
959
|
+
dest_filename = cc_filename_with_extensions("#{singular_class.underscore}", "rb")
|
960
|
+
dest_filepath = File.join("#{'spec/dummy/' if Rails.env.test?}app/models", dest_filename)
|
961
|
+
|
962
|
+
|
963
|
+
puts "appending turbo callbacks to #{dest_filepath}"
|
964
|
+
|
965
|
+
text = File.read(dest_filepath)
|
966
|
+
|
967
|
+
append_text = "class #{singular_class} < ApplicationRecord\n"
|
968
|
+
if !text.include?("include ActionView::RecordIdentifier")
|
969
|
+
append_text << " include ActionView::RecordIdentifier\n"
|
970
|
+
end
|
971
|
+
append_text << " after_update_commit lambda { broadcast_replace_to self, target: \"#{@namespace}__\#{dom_id(self)}\", partial: \"#{@namespace}/#{@plural}/line\" }\n after_destroy_commit lambda { broadcast_remove_to self, target: \"#{@namespace}__\#{dom_id(self)}\"}\n"
|
972
|
+
|
973
|
+
replace = text.gsub(/class #{singular_class} < ApplicationRecord/, append_text)
|
974
|
+
File.open(dest_filepath, "w") {|file| file.puts replace}
|
975
|
+
end
|
976
|
+
end
|
977
|
+
|
943
978
|
def namespace_with_dash
|
944
979
|
if @namespace
|
945
980
|
"/#{@namespace}"
|
@@ -1003,24 +1038,19 @@ module HotGlue
|
|
1003
1038
|
end
|
1004
1039
|
|
1005
1040
|
def all_form_fields
|
1006
|
-
col_identifier = (@layout == "hotglue") ? "scaffold-cell" : "col-md-#{@layout_object[:columns][:size_each]}"
|
1007
|
-
|
1008
1041
|
@template_builder.all_form_fields(
|
1009
1042
|
columns: @layout_object[:columns][:container],
|
1010
1043
|
show_only: @show_only,
|
1011
1044
|
singular_class: singular_class,
|
1012
1045
|
singular: singular,
|
1013
1046
|
hawk_keys: @hawk_keys,
|
1014
|
-
col_identifier:
|
1047
|
+
col_identifier: @layout_strategy.column_classes_for_form_fields,
|
1015
1048
|
ownership_field: @ownership_field,
|
1016
1049
|
form_labels_position: @form_labels_position,
|
1017
1050
|
form_placeholder_labels: @form_placeholder_labels
|
1018
1051
|
)
|
1019
1052
|
end
|
1020
1053
|
|
1021
|
-
def column_width
|
1022
|
-
@each_col ||= each_col
|
1023
|
-
end
|
1024
1054
|
|
1025
1055
|
def list_label
|
1026
1056
|
if(eval("#{class_name}.class_variable_defined?(:@@table_label_plural)"))
|
@@ -1038,39 +1068,15 @@ module HotGlue
|
|
1038
1068
|
end
|
1039
1069
|
end
|
1040
1070
|
|
1041
|
-
def each_col
|
1042
|
-
return col_width if @columns.count == 0
|
1043
|
-
(col_width/(@columns.count)).to_i
|
1044
|
-
end
|
1045
|
-
|
1046
|
-
def col_width
|
1047
|
-
downnest_size = case (@downnest_children.count)
|
1048
|
-
|
1049
|
-
when 0
|
1050
|
-
downnest_size = 0
|
1051
|
-
when 1
|
1052
|
-
downnest_size = 40
|
1053
|
-
|
1054
|
-
else
|
1055
|
-
downnest_size = 60
|
1056
|
-
|
1057
|
-
end
|
1058
|
-
100 - downnest_size - 5
|
1059
|
-
end
|
1060
|
-
|
1061
1071
|
def all_line_fields
|
1062
|
-
col_identifier = (@layout == "hotglue") ? "scaffold-cell" : "col-md-#{@layout_object[:columns][:size_each]}"
|
1063
|
-
|
1064
1072
|
@template_builder.all_line_fields(
|
1065
|
-
perc_width:
|
1073
|
+
perc_width: @layout_strategy.each_col, #undefined method `each_col'
|
1066
1074
|
columns: @layout_object[:columns][:container],
|
1067
1075
|
show_only: @show_only,
|
1068
1076
|
singular_class: singular_class,
|
1069
1077
|
singular: singular,
|
1070
|
-
|
1071
|
-
col_identifier: col_identifier,
|
1078
|
+
col_identifier: @layout_strategy.column_classes_for_line_fields,
|
1072
1079
|
inline_list_labels: @inline_list_labels
|
1073
|
-
|
1074
1080
|
)
|
1075
1081
|
end
|
1076
1082
|
|
@@ -1129,15 +1135,6 @@ module HotGlue
|
|
1129
1135
|
@template_builder.paginate(plural: plural)
|
1130
1136
|
end
|
1131
1137
|
|
1132
|
-
# def delete_confirmation_syntax
|
1133
|
-
# if !@stimulus_syntax
|
1134
|
-
# "{confirm: 'Are you sure?'}"
|
1135
|
-
# else
|
1136
|
-
# "{controller: 'confirmable', 'confirm-message': \"Are you sure you want to delete \#{ #{@singular}.#{ display_class } } \", 'action': 'confirmation#confirm'}"
|
1137
|
-
# end
|
1138
|
-
# end
|
1139
|
-
|
1140
|
-
|
1141
1138
|
def controller_magic_button_update_actions
|
1142
1139
|
@magic_buttons.collect{ |magic_button|
|
1143
1140
|
" if #{singular}_params[:#{magic_button}]
|
@@ -1169,7 +1166,6 @@ module HotGlue
|
|
1169
1166
|
end
|
1170
1167
|
end
|
1171
1168
|
|
1172
|
-
|
1173
1169
|
def n_plus_one_includes
|
1174
1170
|
if @associations.any?
|
1175
1171
|
".includes(" + @associations.map{|x| ":#{x.to_s}"}.join(", ") + ")"
|
@@ -1213,6 +1209,3 @@ module HotGlue
|
|
1213
1209
|
end
|
1214
1210
|
end
|
1215
1211
|
end
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
@@ -1,4 +1,7 @@
|
|
1
1
|
class <%= controller_class_name %> < <%= controller_descends_from %>
|
2
|
+
# regenerate this controller with
|
3
|
+
# <%= regenerate_me_code %>
|
4
|
+
|
2
5
|
helper :hot_glue
|
3
6
|
include HotGlue::ControllerHelper
|
4
7
|
|
@@ -68,22 +71,13 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
68
71
|
|
69
72
|
def index
|
70
73
|
load_all_<%= plural %>
|
71
|
-
respond_to do |format|
|
72
|
-
format.html
|
73
|
-
end
|
74
74
|
end
|
75
75
|
|
76
|
-
<% if create_action %> def new
|
77
|
-
<%
|
78
|
-
@<%= 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 %>)
|
79
|
-
|
80
|
-
<% elsif @object_owner_optional && any_nested? %>
|
76
|
+
<% if create_action %> def new <% if @object_owner_sym %>
|
77
|
+
@<%= 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? %>
|
81
78
|
@<%= singular_name %> = <%= class_name %>.new({}.merge(<%= @nested_set.last[:singular] %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {})) <% else %>
|
82
79
|
@<%= singular_name %> = <%= class_name %>.new(<% if any_nested? %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)
|
83
80
|
<% end %>
|
84
|
-
respond_to do |format|
|
85
|
-
format.html
|
86
|
-
end
|
87
81
|
end
|
88
82
|
|
89
83
|
def create
|
@@ -95,46 +89,30 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
95
89
|
if @<%= singular_name %>.save
|
96
90
|
flash[:notice] = "Successfully created #{@<%= singular %>.<%= display_class %>}"
|
97
91
|
load_all_<%= plural %>
|
98
|
-
|
99
|
-
format.turbo_stream
|
100
|
-
format.html { redirect_to <%= path_helper_plural %> }
|
101
|
-
end
|
92
|
+
render :create
|
102
93
|
else
|
103
94
|
flash[:alert] = "Oops, your <%= singular_name %> could not be created. #{@hawk_alarm}"
|
104
|
-
|
105
|
-
format.turbo_stream
|
106
|
-
format.html
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
<% end %> def show
|
112
|
-
respond_to do |format|
|
113
|
-
format.html
|
95
|
+
render :create, status: :unprocessable_entity
|
114
96
|
end
|
115
97
|
end
|
116
98
|
|
99
|
+
<% end %>
|
117
100
|
<% unless @no_edit %> def edit
|
118
|
-
|
119
|
-
format.turbo_stream
|
120
|
-
format.html
|
121
|
-
end
|
101
|
+
render :edit
|
122
102
|
end
|
123
103
|
|
124
104
|
<% end %><% if @build_update_action %> def update
|
125
105
|
modified_params = modify_date_inputs_on_params(<%= singular %>_params<%= @auth ? ', ' + @auth : '' %>)<%= controller_update_params_tap_away_magic_buttons %><% if @hawk_keys.any? %>
|
126
106
|
modified_params = hawk_params( {<%= hawk_to_ruby %>}, modified_params)<% end %>
|
127
|
-
<%= controller_magic_button_update_actions %>
|
107
|
+
<%= controller_magic_button_update_actions %>
|
108
|
+
if @<%= singular_name %>.update(modified_params)
|
109
|
+
<% if @display_list_after_update %> load_all_<%= plural %><% end %>
|
128
110
|
flash[:notice] = (flash[:notice] || "") << "Saved #{@<%= singular %>.<%= display_class %>}"
|
129
111
|
flash[:alert] = @hawk_alarm if @hawk_alarm
|
112
|
+
render :update
|
130
113
|
else
|
131
114
|
flash[:alert] = (flash[:alert] || "") << "<%= singular_name.titlecase %> could not be saved. #{@hawk_alarm}"
|
132
|
-
|
133
|
-
end
|
134
|
-
<% if @display_list_after_update %> load_all_<%= plural %><% end %>
|
135
|
-
respond_to do |format|
|
136
|
-
format.turbo_stream
|
137
|
-
format.html
|
115
|
+
render :update, status: :unprocessable_entity
|
138
116
|
end
|
139
117
|
end
|
140
118
|
|
@@ -145,10 +123,6 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
145
123
|
flash[:alert] = "<%= singular_name.titlecase %> could not be deleted."
|
146
124
|
end
|
147
125
|
load_all_<%= plural %>
|
148
|
-
respond_to do |format|
|
149
|
-
format.turbo_stream
|
150
|
-
format.html { redirect_to <%= path_helper_plural %> }
|
151
|
-
end
|
152
126
|
end<% end %>
|
153
127
|
|
154
128
|
def <%=singular_name%>_params
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="row">
|
2
2
|
<%= all_form_fields %>
|
3
3
|
|
4
|
-
<div class="<%= @
|
4
|
+
<div class="<%= @layout_strategy.column_classes_for_form_fields %>">
|
5
5
|
<\%= link_to "Cancel", <%= path_helper_plural %>, {class: "btn btn-secondary"} %><% if @no_field_form %>
|
6
6
|
<\%= f.hidden_field "_________" %><% end %>
|
7
7
|
<\%= f.submit "Save", class: "btn btn-primary pull-right" %>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<div class='
|
1
|
+
<% if @turbo_streams %><\%= turbo_stream_from <%= singular %> %>
|
2
|
+
<% end %><\%= turbo_frame_tag "<%= @namespace %>__#{ dom_id(<%= singular %>) }" do %>
|
3
|
+
<div class='<%= @layout_strategy.row_classes %>' data-id='<\%= <%= singular %>.id %>' data-edit='false'>
|
4
4
|
<\%= render partial: '<%= show_path_partial %>', locals: { <%= singular %>: <%= singular %> }<% @nested_set.each do |nest_arg| %>.merge(defined?(<%= nest_arg[:singular] %>) ? {<%= nest_arg[:singular] %>: <%= nest_arg[:singular] %>, nested_for: "<%= nest_arg[:singular] %>-#{<%= nest_arg[:singular] %>.id}"} : {})<% end %> %>
|
5
5
|
|
6
6
|
</div>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<\%= turbo_frame_tag "<%= plural %>-list" <%= nested_for_turbo_id_list_constructor %> do %>
|
2
|
-
<div class="<%= @container_name %>
|
1
|
+
<\%= turbo_frame_tag "<%= @namespace %>__<%= plural %>-list" <%= nested_for_turbo_id_list_constructor %> do %>
|
2
|
+
<div class="<%= @container_name %> <%= @layout_strategy.list_classes %>">
|
3
3
|
<% unless @no_list || @no_list_label || (@nested_set.any? && !@nested_set.collect{|x| x[:optional]}.any?) %>
|
4
4
|
<% unless list_label.nil? %><h4>
|
5
5
|
<%= list_label %>
|
@@ -10,14 +10,12 @@
|
|
10
10
|
|
11
11
|
<% unless @no_list %>
|
12
12
|
<% unless @no_list_heading %>
|
13
|
-
<div class="
|
13
|
+
<div class="<%= @layout_strategy.row_classes %> <%= @layout_strategy.row_heading_classes %>">
|
14
14
|
<%= list_column_headings %>
|
15
15
|
<% if @downnest_object.any? %>
|
16
|
-
|
17
|
-
<% downnest_column_style = @layout == "hotglue" ? 'style="flex-basis: ' + each_downnest_width.to_s + '%;' : "" %>
|
18
|
-
|
16
|
+
<%= @layout_strategy.downnest_column_style %>
|
19
17
|
<% @downnest_object.each do |downnest,i| %>
|
20
|
-
<div class=" scaffold-col-heading<%=
|
18
|
+
<div class=" scaffold-col-heading <%= @layout_strategy.downnest_portal_column_width(downnest) %> <%= @layout_strategy.downnest_column_style %>">
|
21
19
|
<strong>
|
22
20
|
<%= downnest.titleize %>
|
23
21
|
</strong>
|
@@ -25,10 +23,7 @@
|
|
25
23
|
<% end %>
|
26
24
|
<% end %>
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
<div class=' scaffold-col-heading scaffold-col-heading-buttons<%= " col-md-#{ @layout_object[:buttons][:size] }" if @layout=="bootstrap" %>' <%= button_column_style %>>
|
31
|
-
|
26
|
+
<div class=' scaffold-col-heading scaffold-col-heading-buttons <%= @layout_strategy.column_classes_for_column_headings %>' <%= @layout_strategy.button_column_style %>>
|
32
27
|
</div>
|
33
28
|
</div>
|
34
29
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<\%= turbo_frame_tag "<%= singular %>-new" do %>
|
1
|
+
<\%= turbo_frame_tag "<%= @namespace %>__<%= singular %>-new" do %>
|
2
2
|
<div>
|
3
3
|
<\%= link_to "New <%= thing_label %>", <%= new_path_name %>, disable_with: "Loading...", class: "new-<%= singular %>-button btn btn-primary pull-right <%= 'btn-sm' if @nested_set.any? %> " %>
|
4
4
|
</div>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<% if downnest_object.nil?; raise "no relationship for downnested portal `#{downnest}` found on `#{singular_class}`; please check relationship for has_many :#{downnest}"; end; %>
|
10
10
|
<% downnest_class = downnest_object.class_name %>
|
11
11
|
<% downnest_object_name = eval("#{downnest_class}.table_name") %>
|
12
|
-
<% downnest_style =
|
12
|
+
<% downnest_style = @layout_strategy.downnest_style %>
|
13
13
|
<div class="<%= " col-md-#{@layout_object[:portals][downnest][:size]}" if @layout == "bootstrap" %> scaffold-downnest" <%= downnest_style %> >
|
14
14
|
<\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest_object_name %>/list", locals: {
|
15
15
|
<%= @singular %>: <%= @singular %>,
|
@@ -22,8 +22,8 @@
|
|
22
22
|
<% end %>
|
23
23
|
<% end %>
|
24
24
|
|
25
|
-
|
26
|
-
<div class="<%= @col_identifier %> scaffold-line-buttons <%=
|
25
|
+
<%= @layout_strategy.button_style %>
|
26
|
+
<div class="<%= @col_identifier %> scaffold-line-buttons <%= @layout_strategy.button_classes %>" <%= @layout_strategy.button_style %>>
|
27
27
|
<%= magic_button_output %>
|
28
28
|
|
29
29
|
<% if destroy_action %>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<\% if @<%= singular %>.errors.none? %>
|
2
|
-
<\%= turbo_stream.replace "<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
|
2
|
+
<\%= turbo_stream.replace "<%= @namespace %>__<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
|
3
3
|
<\%= 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
4
|
<\% end %>
|
5
5
|
<\% end %>
|
6
|
-
<\%= turbo_stream.replace "<%= singular %>-new" do %>
|
6
|
+
<\%= turbo_stream.replace "<%= @namespace %>__<%= singular %>__<%= singular %>-new" do %>
|
7
7
|
<\% if @<%= singular %>.errors.none? %>
|
8
8
|
<\%= render partial: "new_button", locals: {}<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {" + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> %>
|
9
9
|
<\% else %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<\%= turbo_stream.replace "<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
|
1
|
+
<\%= turbo_stream.replace "<%= @namespace %>__<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
|
2
2
|
<\%= 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() %> \%>
|
3
|
-
<\% end %>
|
3
|
+
<\% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<\%= link_to "<i class='fa fa-arrow-circle-left 2x'></i> Back to list".html_safe, <%= path_helper_plural %> %>
|
2
2
|
|
3
|
-
<\%= turbo_frame_tag "<%=
|
3
|
+
<\%= turbo_frame_tag "<%= @namespace %>__#{dom_id(@<%= singular %>)}" do %>
|
4
4
|
|
5
5
|
<div class="cell editable" style="position: relative;">
|
6
6
|
|