hot-glue 0.2.9E → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -2
- data/Gemfile.lock +3 -3
- data/LICENCE +11 -4
- data/README.md +0 -698
- data/app/helpers/hot_glue/controller_helper.rb +2 -1
- data/lib/generators/hot_glue/install_generator.rb +121 -33
- data/lib/generators/hot_glue/markup_templates/erb.rb +41 -28
- data/lib/generators/hot_glue/markup_templates/haml.rb +3 -1
- data/lib/generators/hot_glue/scaffold_generator.rb +159 -35
- data/lib/generators/hot_glue/templates/controller.rb.erb +34 -20
- data/lib/generators/hot_glue/templates/erb/_form.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_line.erb +3 -2
- data/lib/generators/hot_glue/templates/erb/_list.erb +29 -14
- data/lib/generators/hot_glue/templates/erb/_new_button.erb +3 -1
- data/lib/generators/hot_glue/templates/erb/_show.erb +17 -9
- 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/index.erb +11 -8
- data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +1 -1
- data/lib/generators/hot_glue/templates/haml/_list.haml +2 -2
- data/lib/generators/hot_glue/templates/haml/index.haml +1 -1
- data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_dark_knight.scss +158 -0
- data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_bootstrap.scss +154 -0
- data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_los_gatos.scss +182 -0
- data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_mountain_view.scss +179 -0
- data/lib/hotglue/version.rb +1 -1
- metadata +14 -20
@@ -55,13 +55,16 @@ module HotGlue
|
|
55
55
|
class_option :no_paginate, type: :boolean, default: false
|
56
56
|
class_option :big_edit, type: :boolean, default: false
|
57
57
|
class_option :show_only, type: :string, default: ""
|
58
|
-
class_option :markup, type: :string, default: "erb"
|
59
58
|
class_option :stimulus_syntax, type: :boolean, default: nil
|
60
59
|
class_option :downnest, type: :string, default: nil
|
61
60
|
class_option :nestable, type: :boolean, default: false
|
62
61
|
class_option :magic_buttons, type: :string, default: nil
|
63
62
|
class_option :display_list_after_update, type: :boolean, default: false
|
64
63
|
|
64
|
+
class_option :markup, type: :string, default: nil # deprecated -- use in app config instead
|
65
|
+
class_option :layout, type: :string, default: nil # deprecated -- use in app config instead
|
66
|
+
|
67
|
+
|
65
68
|
def initialize(*meta_args)
|
66
69
|
super
|
67
70
|
|
@@ -69,11 +72,18 @@ module HotGlue
|
|
69
72
|
@the_object = eval(class_name)
|
70
73
|
rescue StandardError => e
|
71
74
|
message = "*** Oops: It looks like there is no object for #{class_name}. Please define the object + database table first."
|
72
|
-
|
75
|
+
puts message
|
76
|
+
exit
|
77
|
+
# raise(HotGlue::Error, message)
|
73
78
|
end
|
74
79
|
|
75
|
-
if
|
76
|
-
|
80
|
+
if !options['spec_only'].nil? && !options['no_spec'].nil?
|
81
|
+
puts "*** 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. sorry."
|
82
|
+
end
|
83
|
+
|
84
|
+
if !options['exclude'].empty? && !options['include'].empty?
|
85
|
+
puts "*** Oops: You seem to have specified both --include and --exclude. Please use one or the other. Aborting."
|
86
|
+
exit
|
77
87
|
end
|
78
88
|
|
79
89
|
if @stimulus_syntax.nil?
|
@@ -84,17 +94,36 @@ module HotGlue
|
|
84
94
|
end
|
85
95
|
end
|
86
96
|
|
87
|
-
if options['markup']
|
97
|
+
if !options['markup'].nil?
|
98
|
+
puts "Using --markup flag in the generator is deprecated; instead, use a file at config/hot_glue.yml with a key markup set to `erb` or `haml`"
|
99
|
+
exit
|
100
|
+
end
|
101
|
+
|
102
|
+
if !options['markup'].nil?
|
103
|
+
puts "Using --layout flag in the generator is deprecated; instead, use a file at config/hot_glue.yml with a key markup set to `erb` or `haml`"
|
104
|
+
exit
|
105
|
+
end
|
106
|
+
|
107
|
+
yaml_from_config = YAML.load(File.read("config/hot_glue.yml"))
|
108
|
+
@markup = yaml_from_config[:markup]
|
109
|
+
|
110
|
+
if @markup == "erb"
|
88
111
|
@template_builder = HotGlue::ErbTemplate.new
|
89
|
-
elsif
|
112
|
+
elsif @markup == "slim"
|
90
113
|
puts "SLIM IS NOT IMPLEMENTED; please see https://github.com/jasonfb/hot-glue/issues/3"
|
91
114
|
abort
|
92
115
|
@template_builder = HotGlue::SlimTemplate.new
|
93
116
|
|
94
|
-
elsif
|
117
|
+
elsif @markup == "haml"
|
95
118
|
@template_builder = HotGlue::HamlTemplate.new
|
96
119
|
end
|
97
|
-
|
120
|
+
|
121
|
+
|
122
|
+
@layout = yaml_from_config[:layout]
|
123
|
+
|
124
|
+
if !['hotglue', 'bootstrap'].include? @layout
|
125
|
+
raise "Invalid option #{@layout} in Hot glue config (config/hot_glue.yml). You must pass either hotglue (default) or bootstrap to config"
|
126
|
+
end
|
98
127
|
|
99
128
|
|
100
129
|
args = meta_args[0]
|
@@ -138,7 +167,17 @@ module HotGlue
|
|
138
167
|
@display_list_after_update = options['display_list_after_update'] || false
|
139
168
|
|
140
169
|
|
141
|
-
|
170
|
+
|
171
|
+
@col_identifier = @layout == "hotglue" ? "scaffold-cell" : "col"
|
172
|
+
@container_name = @layout == "hotglue" ? "scaffold-container" : "container-fluid"
|
173
|
+
|
174
|
+
@downnest = options['downnest'] || false
|
175
|
+
|
176
|
+
@downnest_children = []
|
177
|
+
|
178
|
+
if @downnest
|
179
|
+
@downnest_children = @downnest.split(",")
|
180
|
+
end
|
142
181
|
|
143
182
|
|
144
183
|
if @god
|
@@ -158,6 +197,7 @@ module HotGlue
|
|
158
197
|
@nested_args_plural[a] = a + "s"
|
159
198
|
end
|
160
199
|
end
|
200
|
+
@nestable = @nested_args.any?
|
161
201
|
|
162
202
|
|
163
203
|
@magic_buttons = []
|
@@ -168,7 +208,7 @@ module HotGlue
|
|
168
208
|
@build_update_action = !@no_edit || !@magic_buttons.empty?
|
169
209
|
# if the magic buttons are present, build the update action anyway
|
170
210
|
|
171
|
-
@nestable = options['nestable'] || false
|
211
|
+
# @nestable = options['nestable'] || false
|
172
212
|
|
173
213
|
if @auth && ! @self_auth && @nested_args.none?
|
174
214
|
@object_owner_sym = @auth.gsub("current_", "").to_sym
|
@@ -206,21 +246,19 @@ module HotGlue
|
|
206
246
|
|
207
247
|
else
|
208
248
|
if @god
|
209
|
-
|
210
|
-
exit_message= "*** Oops: god mode could not find the association(?). something is wrong."
|
249
|
+
exit_message= "*** Oops: Gd mode could not find the association(#{@object_owner_sym}). Something is wrong."
|
211
250
|
else
|
212
251
|
@auth_check = "current_user"
|
213
252
|
@nested_args.each do |arg|
|
214
253
|
|
215
254
|
if !@auth_check.method("#{arg}s")
|
216
|
-
exit_message= "*** Oops: your nesting chain does not have a
|
255
|
+
exit_message = "*** Oops: your nesting chain does not have a association for #{arg}s on #{@auth_check} something is wrong."
|
217
256
|
end
|
218
|
-
byebug
|
219
|
-
puts ""
|
220
257
|
end
|
221
258
|
end
|
259
|
+
puts exit_message
|
260
|
+
exit
|
222
261
|
|
223
|
-
raise(HotGlue::Error, exit_message)
|
224
262
|
end
|
225
263
|
end
|
226
264
|
end
|
@@ -262,14 +300,18 @@ module HotGlue
|
|
262
300
|
eval(assoc.class_name)
|
263
301
|
rescue NameError => e
|
264
302
|
exit_message = "*** Oops: The model #{singular_class} is missing an association for #{assoc_name} or the model doesn't exist. TODO: Please implement a model for #{assoc_name.titlecase}; your model #{singular_class.titlecase} should have_many :#{assoc_name}s. To make a controller that can read all records, specify with --god."
|
265
|
-
|
303
|
+
puts exit_message
|
304
|
+
exit
|
305
|
+
# raise(HotGlue::Error, exit_message)
|
266
306
|
|
267
307
|
end
|
268
308
|
|
269
309
|
|
270
310
|
if assoc.nil?
|
271
|
-
exit_message= "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
272
|
-
|
311
|
+
exit_message = "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
312
|
+
puts exit_message
|
313
|
+
exit
|
314
|
+
# raise(HotGlue::Error,exit_message)
|
273
315
|
end
|
274
316
|
|
275
317
|
assoc_class = eval(assoc.class_name)
|
@@ -282,7 +324,7 @@ module HotGlue
|
|
282
324
|
}.any?
|
283
325
|
# do nothing here
|
284
326
|
else
|
285
|
-
exit_message= "*** Oops: Missing a label for #{assoc.class_name.upcase}. Can't find any column to use as the display label for the #{assoc.name.to_s} association on the #{singular_class} model . TODO: Please implement just one of: 1) name, 2) to_label, 3) full_name, 4) display_name, or 5) email directly on your #{assoc.class_name.upcase} model (either as database field or model methods), then RERUN THIS GENERATOR. (If more than one is implemented, the field to use will be chosen based on the rank here, e.g., if name is present it will be used; if not, I will look for a to_label, etc)"
|
327
|
+
exit_message = "*** Oops: Missing a label for #{assoc.class_name.upcase}. Can't find any column to use as the display label for the #{assoc.name.to_s} association on the #{singular_class} model . TODO: Please implement just one of: 1) name, 2) to_label, 3) full_name, 4) display_name, or 5) email directly on your #{assoc.class_name.upcase} model (either as database field or model methods), then RERUN THIS GENERATOR. (If more than one is implemented, the field to use will be chosen based on the rank here, e.g., if name is present it will be used; if not, I will look for a to_label, etc)"
|
286
328
|
raise(HotGlue::Error,exit_message)
|
287
329
|
end
|
288
330
|
end
|
@@ -299,8 +341,6 @@ module HotGlue
|
|
299
341
|
nil
|
300
342
|
end
|
301
343
|
|
302
|
-
|
303
|
-
|
304
344
|
def copy_controller_and_spec_files
|
305
345
|
@default_colspan = @columns.size
|
306
346
|
unless @specs_only
|
@@ -323,7 +363,18 @@ module HotGlue
|
|
323
363
|
end
|
324
364
|
|
325
365
|
def list_column_headings
|
326
|
-
@
|
366
|
+
if @nested_args.any?
|
367
|
+
column_width = each_col * @columns.count
|
368
|
+
|
369
|
+
"<div class='#{@col_identifier}' style='flex-basis: #{column_width}%'>"
|
370
|
+
else
|
371
|
+
@template_builder.list_column_headings(
|
372
|
+
column_width: each_col,
|
373
|
+
columns: @columns,
|
374
|
+
col_identifier: @col_identifier
|
375
|
+
)
|
376
|
+
end
|
377
|
+
|
327
378
|
|
328
379
|
end
|
329
380
|
|
@@ -396,7 +447,7 @@ module HotGlue
|
|
396
447
|
end
|
397
448
|
|
398
449
|
def path_helper_args
|
399
|
-
if @nested_args.any? && @
|
450
|
+
if @nested_args.any? && @nest
|
400
451
|
[(@nested_args).collect{|a| "#{a}"} , singular].join(",")
|
401
452
|
else
|
402
453
|
singular
|
@@ -404,7 +455,7 @@ module HotGlue
|
|
404
455
|
end
|
405
456
|
|
406
457
|
def path_helper_singular
|
407
|
-
if @
|
458
|
+
if @nest
|
408
459
|
"#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_" if @nested_args.any?)}#{singular}_path"
|
409
460
|
else
|
410
461
|
"#{@namespace+"_" if @namespace}#{singular}_path"
|
@@ -412,7 +463,7 @@ module HotGlue
|
|
412
463
|
end
|
413
464
|
|
414
465
|
def path_helper_plural
|
415
|
-
if ! @
|
466
|
+
if ! @nest
|
416
467
|
"#{@namespace+"_" if @namespace}#{plural}_path"
|
417
468
|
else
|
418
469
|
"#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_" if @nested_args.any?)}#{plural}_path"
|
@@ -421,7 +472,7 @@ module HotGlue
|
|
421
472
|
|
422
473
|
def path_arity
|
423
474
|
res = ""
|
424
|
-
if @nested_args.any? && @
|
475
|
+
if @nested_args.any? && @nest
|
425
476
|
res << nested_objects_arity + ", "
|
426
477
|
end
|
427
478
|
res << "@" + singular
|
@@ -461,7 +512,7 @@ module HotGlue
|
|
461
512
|
|
462
513
|
def nest_assignments_operator(top_level = false, leading_comma = false)
|
463
514
|
if @nested_args.any?
|
464
|
-
"#{', ' if leading_comma}#{top_level ? nested_assignments_top_level : nested_assignments }"
|
515
|
+
"#{', ' + "\n " if leading_comma}#{top_level ? nested_assignments_top_level : nested_assignments }"
|
465
516
|
else
|
466
517
|
""
|
467
518
|
end
|
@@ -487,7 +538,12 @@ module HotGlue
|
|
487
538
|
"@" + @nested_args.last + ".#{plural}"
|
488
539
|
end
|
489
540
|
else
|
490
|
-
@
|
541
|
+
if @nested_args.none?
|
542
|
+
@singular_class
|
543
|
+
else
|
544
|
+
"@" + @nested_args.last + ".#{plural}"
|
545
|
+
end
|
546
|
+
|
491
547
|
end
|
492
548
|
end
|
493
549
|
|
@@ -553,8 +609,10 @@ module HotGlue
|
|
553
609
|
formats.each do |format|
|
554
610
|
source_filename = cc_filename_with_extensions("#{@markup}/#{view}", "#{@markup}")
|
555
611
|
dest_filename = cc_filename_with_extensions("#{view}", "#{@markup}")
|
612
|
+
|
613
|
+
|
556
614
|
dest_filepath = File.join("#{'spec/dummy/' if Rails.env.test?}app/views#{namespace_with_dash}",
|
557
|
-
|
615
|
+
plural, dest_filename)
|
558
616
|
|
559
617
|
|
560
618
|
template source_filename, dest_filepath
|
@@ -568,7 +626,7 @@ module HotGlue
|
|
568
626
|
source_filename = cc_filename_with_extensions( "#{@markup}/#{view}.turbo_stream.#{@markup}")
|
569
627
|
dest_filename = cc_filename_with_extensions("#{view}", "turbo_stream.#{@markup}")
|
570
628
|
dest_filepath = File.join("#{'spec/dummy/' if Rails.env.test?}app/views#{namespace_with_dash}",
|
571
|
-
|
629
|
+
plural, dest_filename)
|
572
630
|
|
573
631
|
|
574
632
|
template source_filename, dest_filepath
|
@@ -626,20 +684,48 @@ module HotGlue
|
|
626
684
|
end
|
627
685
|
|
628
686
|
def all_form_fields
|
687
|
+
|
629
688
|
@template_builder.all_form_fields(
|
630
689
|
columns: @columns,
|
631
690
|
show_only: @show_only,
|
632
691
|
singular_class: singular_class,
|
633
|
-
singular: singular
|
692
|
+
singular: singular,
|
693
|
+
col_identifier: @col_identifier
|
634
694
|
)
|
635
695
|
end
|
636
696
|
|
697
|
+
def column_width
|
698
|
+
@each_col ||= each_col
|
699
|
+
end
|
700
|
+
|
701
|
+
def each_col
|
702
|
+
(col_width/@columns.count).to_i
|
703
|
+
end
|
704
|
+
|
705
|
+
def col_width
|
706
|
+
downnest_size = case (@downnest_children.count)
|
707
|
+
|
708
|
+
when 0
|
709
|
+
downnest_size = 0
|
710
|
+
when 1
|
711
|
+
downnest_size = 40
|
712
|
+
|
713
|
+
else
|
714
|
+
downnest_size = 60
|
715
|
+
|
716
|
+
end
|
717
|
+
100 - downnest_size - 5
|
718
|
+
end
|
719
|
+
|
637
720
|
def all_line_fields
|
721
|
+
|
638
722
|
@template_builder.all_line_fields(
|
723
|
+
perc_width: column_width,
|
639
724
|
columns: @columns,
|
640
725
|
show_only: @show_only,
|
641
726
|
singular_class: singular_class,
|
642
|
-
singular: singular
|
727
|
+
singular: singular,
|
728
|
+
layout: @layout
|
643
729
|
)
|
644
730
|
end
|
645
731
|
|
@@ -710,8 +796,16 @@ module HotGlue
|
|
710
796
|
|
711
797
|
def controller_magic_button_update_actions
|
712
798
|
@magic_buttons.collect{ |magic_button|
|
713
|
-
"
|
714
|
-
|
799
|
+
" begin
|
800
|
+
if #{singular}_params[:#{magic_button}]
|
801
|
+
res = @#{singular}.#{magic_button}!
|
802
|
+
res = \"#{magic_button.titleize}ed.\" if res === true
|
803
|
+
flash[:notice] = (flash[:notice] || \"\") << (res ? res + \" \" : \"\")
|
804
|
+
end
|
805
|
+
rescue ActiveRecord::RecordInvalid => e
|
806
|
+
@#{singular}.errors.add(:base, e.message)
|
807
|
+
flash[:alert] = (flash[:alert] || \"\") << 'There was ane error #{magic_button}ing your #{@singular}: '
|
808
|
+
end" }.join("\n") + "\n"
|
715
809
|
end
|
716
810
|
|
717
811
|
def controller_update_params_tap_away_magic_buttons
|
@@ -720,6 +814,36 @@ module HotGlue
|
|
720
814
|
}.join("")
|
721
815
|
end
|
722
816
|
|
817
|
+
|
818
|
+
def nested_for_turbo_id_list_constructor
|
819
|
+
if @nested_args.none?
|
820
|
+
""
|
821
|
+
else
|
822
|
+
"+ ('__' + nested_for)"
|
823
|
+
end
|
824
|
+
end
|
825
|
+
|
826
|
+
def nested_for_turbo_nested_constructor(top_level = true)
|
827
|
+
instance_symbol = "@" if top_level
|
828
|
+
instance_symbol = "" if !top_level
|
829
|
+
if @nested_args.none?
|
830
|
+
""
|
831
|
+
else
|
832
|
+
"__" + @nested_args.collect{|a| "#{a}-" + '#{' + instance_symbol + a + '.id}'}.join("__")
|
833
|
+
end
|
834
|
+
end
|
835
|
+
|
836
|
+
def nested_for_assignments_constructor(top_level = true)
|
837
|
+
instance_symbol = "@" if top_level
|
838
|
+
instance_symbol = "" if !top_level
|
839
|
+
if @nested_args.none?
|
840
|
+
""
|
841
|
+
else
|
842
|
+
", \n nested_for: \"" + @nested_args.collect{|a| "#{a}-" + '#{' + instance_symbol + a + ".id}"}.join("__") + "\""
|
843
|
+
end
|
844
|
+
end
|
845
|
+
|
846
|
+
|
723
847
|
private # thor does something fancy like sending the class all of its own methods during some strange run sequence
|
724
848
|
# does not like public methods
|
725
849
|
def cc_filename_with_extensions(name, file_format = format)
|
@@ -15,17 +15,37 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
15
15
|
# TODO: implement current_user or use Devise
|
16
16
|
<% end %>
|
17
17
|
|
18
|
-
<% if
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
<% if @nested_args.any? %>
|
19
|
+
def <%= @nested_args[0] %>
|
20
|
+
<% if @god
|
21
|
+
next_object = nil
|
22
|
+
collect_objects = @nested_args.reverse.collect {|x|
|
23
|
+
if eval("#{next_object || class_name}.reflect_on_association(:#{x})").nil?
|
24
|
+
raise "***** Unable to find the association `#{x}` on the class #{next_object || class_name} ..... you probably want to add `belongs_to :#{x}` to the #{next_object || class_name} object?"
|
25
|
+
end
|
26
|
+
next_object = eval("#{next_object || class_name}.reflect_on_association(:#{x})").class_name
|
27
|
+
}
|
28
|
+
root_object = collect_objects.last
|
29
|
+
else
|
30
|
+
root_object = @auth + "." + @nested_args[0] + "s"
|
31
|
+
end
|
32
|
+
|
33
|
+
%>
|
34
|
+
<% if !@god %> @<%= @nested_args[0] %> ||= <%= root_object %>.find(params[:<%= @nested_args[0] %>_id])
|
35
|
+
<% else %> @<%= @nested_args[0] %> ||= <%= root_object %>.find(params[:<%= @nested_args[0] %>_id]) <% end %>
|
36
|
+
end
|
37
|
+
<% end %>
|
38
|
+
|
39
|
+
<% if any_nested? %><% nest_chain = [@nested_args[0]]; this_scope = @nested_args[0] + 's'; %> <% @nested_args[1..-1].each { |arg|
|
40
|
+
this_scope = "#{nest_chain.last}.#{arg}s"
|
24
41
|
nest_chain << arg
|
25
42
|
%>
|
26
43
|
def <%= arg %>
|
27
44
|
@<%= arg %> ||= <%= this_scope %>.find(params[:<%= arg %>_id])
|
28
|
-
end<% }
|
45
|
+
end<% } %>
|
46
|
+
|
47
|
+
<% end %>
|
48
|
+
|
29
49
|
|
30
50
|
<% if !@self_auth %>
|
31
51
|
def load_<%= singular_name %>
|
@@ -37,8 +57,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
37
57
|
end<% end %>
|
38
58
|
|
39
59
|
def load_all_<%= plural %>
|
40
|
-
|
41
|
-
<% else %>@<%= plural_name %> = [<%= auth_object %>]<% end %>
|
60
|
+
@<%= plural_name %> = <%= object_scope.gsub("@",'') %>.page(params[:page])
|
42
61
|
end
|
43
62
|
|
44
63
|
def index
|
@@ -92,12 +111,11 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
92
111
|
end
|
93
112
|
|
94
113
|
<% end %><% if @build_update_action %> def update
|
95
|
-
<%= controller_magic_button_update_actions %>
|
96
|
-
|
97
|
-
if @<%= singular_name %>.update(modify_date_inputs_on_params(<%= singular %>_params<%= @auth ? ', ' + @auth : '' %>)<%= controller_update_params_tap_away_magic_buttons %>)
|
98
|
-
flash[:notice] = "Saved #{@<%= singular %>.<%= display_class %>}"
|
114
|
+
<%= controller_magic_button_update_actions %> if @<%= singular_name %>.update(modify_date_inputs_on_params(<%= singular %>_params<%= @auth ? ', ' + @auth : '' %>)<%= controller_update_params_tap_away_magic_buttons %>)
|
115
|
+
flash[:notice] = (flash[:notice] || "") << "Saved #{@<%= singular %>.<%= display_class %>}"
|
99
116
|
else
|
100
|
-
flash[:alert] = "<%= singular_name.titlecase %> could not be saved."
|
117
|
+
flash[:alert] = (flash[:alert] || "") << "<%= singular_name.titlecase %> could not be saved."
|
118
|
+
|
101
119
|
end
|
102
120
|
<% if @display_list_after_update %> load_all_<%= plural %><% end %>
|
103
121
|
respond_to do |format|
|
@@ -117,9 +135,9 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
117
135
|
format.turbo_stream
|
118
136
|
format.html { redirect_to <%= path_helper_plural %> }
|
119
137
|
end
|
120
|
-
end
|
138
|
+
end<% end %>
|
121
139
|
|
122
|
-
|
140
|
+
def <%=singular_name%>_params
|
123
141
|
params.require(:<%=singular_name%>).permit( <%= @columns + @magic_buttons.collect(&:to_sym) %> )
|
124
142
|
end
|
125
143
|
|
@@ -130,10 +148,6 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
130
148
|
def namespace
|
131
149
|
<% if @namespace %>"<%= @namespace %>/" <% else %>""<% end %>
|
132
150
|
end
|
133
|
-
|
134
|
-
def common_scope
|
135
|
-
@nested_args
|
136
|
-
end
|
137
151
|
end
|
138
152
|
|
139
153
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="row">
|
2
2
|
<%= all_form_fields %>
|
3
3
|
|
4
|
-
<div class="col">
|
4
|
+
<div class="<% @layout == "hotglue" ? 'scaffold-cell' : 'col' %>">
|
5
5
|
<\%= link_to "Cancel", <%= path_helper_plural %>, {class: "btn btn-secondary"} %>
|
6
6
|
<\%= f.submit "Save", class: "btn btn-primary pull-right" %>
|
7
7
|
</div>
|
@@ -1,7 +1,8 @@
|
|
1
1
|
|
2
2
|
<\%= turbo_frame_tag "<%= singular %>__#{ <%= singular %>.id }" do %>
|
3
|
-
<div class='row' data-id='<\%= <%= singular %>.id %>' data-edit='false'>
|
4
|
-
<\%= render partial: '<%= show_path_partial %>', locals: { <%= singular %>: <%= singular %><%= nest_assignments_operator(false, true) if @nestable %> } %>
|
3
|
+
<div class='row scaffold-row' data-id='<\%= <%= singular %>.id %>' data-edit='false'>
|
4
|
+
<\%= render partial: '<%= show_path_partial %>', locals: { <%= singular %>: <%= singular %><%= nest_assignments_operator(false, true) if @nestable %><%= (", nested_for: \"" + @nested_args.collect{|a| a + "-" + '#{'+ a + '.id}' }.join("__") + "\"") if @nestable %> } %>
|
5
|
+
|
5
6
|
</div>
|
6
7
|
<\% end %>
|
7
8
|
|
@@ -1,27 +1,42 @@
|
|
1
|
-
<\%= turbo_frame_tag "<%= plural %>-list" do %>
|
2
|
-
<div class="
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<% unless @no_create %><%= '<%= render partial: "' + ((@namespace+"/" if @namespace) || "") + plural + '/new_button", locals: {' + nested_assignments + '}' + '%\>'.gsub('\\',"") %><% end %>
|
7
|
-
</div>
|
8
|
-
</div>
|
1
|
+
<\%= turbo_frame_tag "<%= plural %>-list" <%= nested_for_turbo_id_list_constructor %> do %>
|
2
|
+
<div class="<%= @container_name %> scaffold-list">
|
3
|
+
<% unless @nested_args.any? %><h4><%= plural.gsub("_", " ").upcase %></h4><% end %>
|
4
|
+
|
5
|
+
<% unless @no_create %><%= '<%= render partial: "' + ((@namespace+"/" if @namespace) || "") + plural + '/new_button", locals: {' + nested_assignments + '}' + '%\>'.gsub('\\',"") %><% end %>
|
9
6
|
|
10
7
|
|
11
|
-
<div class="row">
|
8
|
+
<div class="row scaffold-row">
|
12
9
|
<%= list_column_headings %>
|
13
|
-
|
10
|
+
<% if @downnest_children.any? %>
|
11
|
+
<% each_downnest_width = @downnest_children.count == 1 ? 40 : (60/@downnest_children.count).floor %>
|
12
|
+
<% downnest_column_style = @layout == "hotglue" ? 'style="flex-basis: ' + each_downnest_width + '%;' : "" %>
|
13
|
+
|
14
|
+
<% @downnest_children.each do |downnest| %>
|
15
|
+
<div class="<%= @col_identifer %> scaffold-col-heading<%= ' col-md-3' if @layout=="bootstrap" %>" <%= downnest_column_style %>>
|
16
|
+
<h4>
|
17
|
+
<%= downnest.titleize %>
|
18
|
+
</h4>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<% button_column_style = @layout == "hotglue" ? 'style="flex-basis: 150px' : "" %>
|
24
|
+
|
25
|
+
<div class='<%= @col_identifer %> scaffold-col-heading scaffold-col-heading-buttons<%= ' col-md-2' if @layout=="bootstrap" %>' <%= button_column_style %>>
|
26
|
+
|
27
|
+
</div>
|
14
28
|
</div>
|
15
29
|
|
16
30
|
<\% if <%= plural %>.empty? %>
|
17
|
-
|
18
|
-
|
19
|
-
|
31
|
+
<div>
|
32
|
+
None
|
33
|
+
</div>
|
20
34
|
<\% end %>
|
21
35
|
<\% <%= plural %>.each do |<%= singular %>| %>
|
22
|
-
<\%= render partial: '<%= line_path_partial %>', locals: {<%= singular %>: <%= singular %><%= nested_assignments_with_leading_comma if @nestable %> } %>
|
36
|
+
<\%= render partial: '<%= line_path_partial %>', locals: {<%= singular %>: <%= singular %><%= nested_assignments_with_leading_comma if @nestable %><%= ", nested_for: nested_for" if @nestable %> } %>
|
23
37
|
<\% end %>
|
24
38
|
|
25
39
|
<%= @no_paginate ? "" : paginate %>
|
40
|
+
</div>
|
26
41
|
</div>
|
27
42
|
<\% end %>
|
@@ -1,3 +1,5 @@
|
|
1
1
|
<\%= turbo_frame_tag "<%= singular %>-new" do %>
|
2
|
-
|
2
|
+
<div>
|
3
|
+
<\%= link_to "New <%= singular.titlecase %>", <%= new_path_name %>, disable_with: "Loading...", class: "new-<%= singular %>-button btn btn-primary pull-right <%= 'btn-sm' if @nested_args.any? %> " %>
|
4
|
+
</div>
|
3
5
|
<\% end %>
|
@@ -1,17 +1,25 @@
|
|
1
1
|
<%= all_line_fields %>
|
2
2
|
|
3
|
-
<% if @
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
<% if @downnest_children.any? %>
|
4
|
+
<% each_downnest_width = @downnest_children.count == 1 ? 33 : (53/@downnest_children.count).floor %>
|
5
|
+
|
6
|
+
<% @downnest_children.each do |downnest| %>
|
7
|
+
|
8
|
+
<% downnest_style = @layout == "hotglue" ? 'style="flex-basis: ' + each_downnest_width + '%"' : "" %>
|
9
|
+
<div class="<%= @col_identifier %><%= ' col-md-3' if @layout == "bootstrap" %> scaffold-downnest" <%= downnest_style %> >
|
10
|
+
<\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest %>/list", locals: {
|
11
|
+
nested_for: "<% if @nested_args.any? %>#{nested_for + "__" if nested_for}<% end %><%= @singular %>-#{<%= @singular %>.id}",
|
12
|
+
<%= @singular %>: <%= @singular %><%= nest_assignments_operator(false, true) %>,
|
13
|
+
<%= downnest %>: <%= @singular %>.<%= downnest %>} %>
|
8
14
|
</div>
|
15
|
+
<% end %>
|
9
16
|
<% end %>
|
10
17
|
|
11
|
-
|
18
|
+
<% button_style = @layout == "hotglue" ? 'style="flex-basis: ' + (100 - (column_width * @columns.count)).floor.to_s + '%;"' : "" %>
|
19
|
+
<div class="<%= @col_identifier %> scaffold-line-buttons <%= ' col-md-2' if @layout == "bootstrap" %>" <%= button_style %>>
|
12
20
|
<% if destroy_action %>
|
13
|
-
<\%= form_with url: <%= path_helper_singular %>(<%= path_helper_args %>), method: :delete do |f| %>
|
14
|
-
<\%= f.submit "Delete".html_safe,
|
21
|
+
<\%= form_with url: <%= path_helper_singular %>(<%= path_helper_args %>), html: {style: "display: inline-block;"}, method: :delete do |f| %>
|
22
|
+
<\%= f.submit "Delete".html_safe, data: <%= delete_confirmation_syntax %>, class: "delete-<%= singular %>-button btn btn-primary btn-sm" %>
|
15
23
|
<\% end %>
|
16
24
|
<% end %>
|
17
25
|
|
@@ -19,6 +27,6 @@
|
|
19
27
|
<%= magic_button_output %>
|
20
28
|
|
21
29
|
<% unless @no_edit %>
|
22
|
-
<\%= link_to "Edit <i class='fa fa-1x fa-list-alt'></i>".html_safe, edit_<%= path_helper_singular %>(<%= path_helper_args %>), <% if @big_edit %>'data-turbo' => 'false', <% end %>disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary " %>
|
30
|
+
<\%= link_to "Edit <i class='fa fa-1x fa-list-alt'></i>".html_safe, edit_<%= path_helper_singular %>(<%= path_helper_args %>), <% if @big_edit %>'data-turbo' => 'false', <% end %>disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary btn-sm" %>
|
23
31
|
<% end %>
|
24
32
|
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<\% if @<%= singular %>.errors.none? %>
|
2
|
-
<\%= turbo_stream.replace "<%= plural %>-list" do %>
|
3
|
-
<\%= render partial: "list", locals: {<%= plural %>: @<%= plural
|
2
|
+
<\%= turbo_stream.replace "<%= plural %>-list<%= nested_for_turbo_nested_constructor %>" do %>
|
3
|
+
<\%= render partial: "list", locals: {<%= plural %>: @<%= plural %><%= nested_for_assignments_constructor %><%= nest_assignments_operator(true, true) %>} %>
|
4
4
|
<\% end %>
|
5
5
|
<\% end %>
|
6
6
|
<\%= turbo_stream.replace "<%= singular %>-new" do %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<\%= turbo_stream.replace "<%=plural%>-list" do %>
|
2
|
-
<\%= render partial: "list", locals: {<%=plural%>: @<%=plural%> <%= nest_assignments_operator(true, true) %>} %>
|
1
|
+
<\%= turbo_stream.replace "<%= plural %>-list<%= nested_for_turbo_nested_constructor %>" do %>
|
2
|
+
<\%= render partial: "list", locals: {<%=plural%>: @<%=plural%> <%= nested_for_assignments_constructor %> <%= nest_assignments_operator(true, true) %>} %>
|
3
3
|
<\% end %>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<div class="cell editable" style="position: relative;">
|
6
6
|
|
7
7
|
<\% if @<%= singular %>.errors.any? %>
|
8
|
-
<\%= render(partial: "
|
8
|
+
<\%= render(partial: "<%= namespace_with_trailing_dash %>errors", locals: {resource: @<%= singular %> }) %>
|
9
9
|
<\% end %>
|
10
10
|
|
11
11
|
<h2>Editing <\%= @<%= @singular %>.<%= display_class %> %></h2>
|
@@ -1,9 +1,12 @@
|
|
1
|
-
<div class="
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
<div class="<%= @container_name %>">
|
2
|
+
<% if @layout == "bootstrap" %><div class="row"> <div class="col-md-12">
|
3
|
+
<% else %>
|
4
|
+
<div class=' scaffold-index-<%= plural %>'>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<div class="clearfix"></div>
|
8
|
+
<\%= render partial: '<%= list_path_partial %>',
|
9
|
+
locals: {<%= plural %>: @<%= plural %><%= nested_for_assignments_constructor %><%= nest_assignments_operator(true, true) if @nestable %> } \%>
|
10
|
+
|
11
|
+
<% if @layout == "bootstrap" %></div></div><% else %></div><% end %>
|
9
12
|
</div>
|