hot-glue 0.4.4 → 0.4.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +71 -0
- data/.gitignore +4 -1
- data/Gemfile +5 -1
- data/Gemfile.lock +17 -17
- data/{LICENCE → LICENSE} +10 -6
- data/README.md +293 -246
- data/README2.md +79 -0
- data/config/database.yml +8 -83
- data/db/schema.rb +1 -0
- data/lib/generators/hot_glue/install_generator.rb +0 -1
- data/lib/generators/hot_glue/layout/builder.rb +42 -31
- data/lib/generators/hot_glue/markup_templates/erb.rb +97 -86
- data/lib/generators/hot_glue/scaffold_generator.rb +249 -82
- data/lib/generators/hot_glue/templates/controller.rb.erb +51 -47
- data/lib/generators/hot_glue/templates/erb/_form.erb +3 -2
- data/lib/generators/hot_glue/templates/erb/_line.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_list.erb +26 -20
- data/lib/generators/hot_glue/templates/erb/_new_form.erb +3 -2
- data/lib/generators/hot_glue/templates/erb/_show.erb +11 -7
- data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +4 -4
- data/lib/generators/hot_glue/templates/erb/destroy.turbo_stream.erb +2 -2
- data/lib/generators/hot_glue/templates/erb/edit.erb +2 -2
- data/lib/generators/hot_glue/templates/erb/index.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/new.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +2 -2
- data/lib/hotglue/version.rb +3 -1
- metadata +6 -26
- data/db/schema.rb +0 -60
- data/lib/generators/hot_glue/markup_templates/haml.rb +0 -243
- data/lib/generators/hot_glue/markup_templates/slim.rb +0 -9
@@ -3,8 +3,8 @@ require 'ffaker'
|
|
3
3
|
|
4
4
|
require_relative './markup_templates/base'
|
5
5
|
require_relative './markup_templates/erb'
|
6
|
-
require_relative './markup_templates/haml'
|
7
|
-
require_relative './markup_templates/slim'
|
6
|
+
# require_relative './markup_templates/haml'
|
7
|
+
# require_relative './markup_templates/slim'
|
8
8
|
|
9
9
|
require_relative './layout/builder'
|
10
10
|
|
@@ -12,6 +12,50 @@ module HotGlue
|
|
12
12
|
class Error < StandardError
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.optionalized_ternary(params)
|
16
|
+
namespace = params[:namespace] || nil
|
17
|
+
target = params[:target]
|
18
|
+
nested_set = params[:nested_set]
|
19
|
+
modifier = params[:modifier] || ""
|
20
|
+
with_params = params[:with_params] || false
|
21
|
+
top_level = params[:top_level] || false
|
22
|
+
|
23
|
+
instance_sym = top_level ? "@" : ""
|
24
|
+
|
25
|
+
put_form = params[:put_form] || false
|
26
|
+
|
27
|
+
if nested_set.nil? || nested_set.empty?
|
28
|
+
return modifier + "#{(namespace + '_') if namespace}#{target}_path" + (("(#{instance_sym}#{target})" if put_form) || "")
|
29
|
+
elsif nested_set[0][:optional] == false
|
30
|
+
return modifier + ((namespace + "_" if namespace) || "") + nested_set.collect{|x|
|
31
|
+
x[:singular] + "_"
|
32
|
+
}.join() + target + "_path" + (("(#{nested_set.collect{
|
33
|
+
|x| instance_sym + x[:singular] }.join(",")
|
34
|
+
}#{ put_form ? ',' + instance_sym + target : '' })" if with_params) || "")
|
35
|
+
|
36
|
+
else
|
37
|
+
# copy the first item, make a ternery in this cycle, and recursively move to both the
|
38
|
+
# is present path and the is optional path
|
39
|
+
|
40
|
+
nonoptional = nested_set[0].dup
|
41
|
+
nonoptional[:optional] = false
|
42
|
+
rest_of_nest = nested_set[1..-1]
|
43
|
+
|
44
|
+
all_params = {namespace: namespace,
|
45
|
+
target: target,
|
46
|
+
modifier: modifier,
|
47
|
+
top_level: top_level,
|
48
|
+
with_params: with_params,
|
49
|
+
put_form: put_form}
|
50
|
+
is_present_path = HotGlue.optionalized_ternary(all_params.merge({ nested_set: [nonoptional, *rest_of_nest]}) )
|
51
|
+
|
52
|
+
is_missing_path = HotGlue.optionalized_ternary(all_params.merge({ nested_set: rest_of_nest}) )
|
53
|
+
|
54
|
+
|
55
|
+
return "defined?(#{instance_sym + nested_set[0][:singular]}) ? #{is_present_path} : #{is_missing_path}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
15
59
|
def self.derrive_reference_name(thing_as_string)
|
16
60
|
assoc_class = eval(thing_as_string)
|
17
61
|
|
@@ -41,7 +85,10 @@ module HotGlue
|
|
41
85
|
class_option :singular, type: :string, default: nil
|
42
86
|
class_option :plural, type: :string, default: nil
|
43
87
|
class_option :singular_class, type: :string, default: nil
|
44
|
-
class_option :nest, type: :string, default:
|
88
|
+
class_option :nest, type: :string, default: nil # DEPRECATED —— DO NOT USE
|
89
|
+
class_option :nested, type: :string, default: ""
|
90
|
+
|
91
|
+
|
45
92
|
class_option :namespace, type: :string, default: nil
|
46
93
|
class_option :auth, type: :string, default: nil
|
47
94
|
class_option :auth_identifier, type: :string, default: nil
|
@@ -59,15 +106,18 @@ module HotGlue
|
|
59
106
|
class_option :big_edit, type: :boolean, default: false
|
60
107
|
class_option :show_only, type: :string, default: ""
|
61
108
|
|
62
|
-
class_option :
|
109
|
+
class_option :ujs_syntax, type: :boolean, default: nil
|
63
110
|
|
64
111
|
class_option :downnest, type: :string, default: nil
|
65
112
|
class_option :magic_buttons, type: :string, default: nil
|
113
|
+
class_option :small_buttons, type: :boolean, default: nil
|
114
|
+
|
66
115
|
class_option :display_list_after_update, type: :boolean, default: false
|
67
116
|
class_option :smart_layout, type: :boolean, default: false
|
68
117
|
class_option :markup, type: :string, default: nil # deprecated -- use in app config instead
|
69
118
|
class_option :layout, type: :string, default: nil # if used here it will override what is in the config
|
70
|
-
|
119
|
+
class_option :no_list_labels, type: :boolean, default: false
|
120
|
+
class_option :before_list_labels, type: :boolean, default: false
|
71
121
|
|
72
122
|
def initialize(*meta_args)
|
73
123
|
super
|
@@ -138,14 +188,34 @@ module HotGlue
|
|
138
188
|
end
|
139
189
|
|
140
190
|
args = meta_args[0]
|
191
|
+
|
192
|
+
|
141
193
|
@singular = args.first.tableize.singularize # should be in form hello_world
|
142
194
|
@plural = options['plural'] || @singular + "s" # supply to override; leave blank to use default
|
195
|
+
@namespace = options['namespace'] || nil
|
196
|
+
|
197
|
+
|
198
|
+
use_controller_name = plural.titleize.gsub(" ", "")
|
199
|
+
|
200
|
+
@controller_build_name = (( @namespace.titleize.gsub(" ","") + "::" if @namespace) || "") + use_controller_name + "Controller"
|
201
|
+
@controller_build_folder = use_controller_name.underscore
|
202
|
+
@controller_build_folder_singular = singular
|
203
|
+
|
204
|
+
if ! @controller_build_folder.ends_with?("s")
|
205
|
+
raise "can't build with controller name #{@controller_build_folder} because it doesn't end with an 's'"
|
206
|
+
end
|
207
|
+
|
143
208
|
@auth = options['auth'] || "current_user"
|
144
209
|
@auth_identifier = options['auth_identifier'] || (! @god && @auth.gsub("current_", "")) || nil
|
145
210
|
|
146
211
|
|
147
|
-
|
148
|
-
|
212
|
+
|
213
|
+
if options['nest']
|
214
|
+
raise "STOP: the flag --nest has been replaced with --nested; please re-run using the --nested flag"
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
@nested = (!options['nested'].empty? && options['nested']) || nil
|
149
219
|
|
150
220
|
@singular_class = @singular.titleize.gsub(" ", "")
|
151
221
|
@exclude_fields = []
|
@@ -164,7 +234,6 @@ module HotGlue
|
|
164
234
|
@show_only += options['show_only'].split(",").collect(&:to_sym)
|
165
235
|
end
|
166
236
|
|
167
|
-
|
168
237
|
@god = options['god'] || options['gd'] || false
|
169
238
|
@specs_only = options['specs_only'] || false
|
170
239
|
|
@@ -177,13 +246,16 @@ module HotGlue
|
|
177
246
|
|
178
247
|
@no_edit = options['no_edit'] || false
|
179
248
|
@no_list = options['no_list'] || false
|
180
|
-
|
249
|
+
@no_list_labels = options['no_list_labels'] || false
|
181
250
|
@display_list_after_update = options['display_list_after_update'] || false
|
182
251
|
@smart_layout = options['smart_layout']
|
183
252
|
|
253
|
+
if options['include'].include?(":") && @smart_layout
|
254
|
+
raise "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"
|
255
|
+
end
|
184
256
|
|
185
|
-
@container_name = @layout == "hotglue" ? "scaffold-container" : "container-fluid"
|
186
257
|
|
258
|
+
@container_name = @layout == "hotglue" ? "scaffold-container" : "container-fluid"
|
187
259
|
@downnest = options['downnest'] || false
|
188
260
|
|
189
261
|
@downnest_children = []
|
@@ -198,26 +270,60 @@ module HotGlue
|
|
198
270
|
end
|
199
271
|
|
200
272
|
# when in self auth, the object is the same as the authenticated object
|
273
|
+
|
201
274
|
if @auth && auth_identifier == @singular
|
202
275
|
@self_auth = true
|
203
276
|
end
|
204
277
|
|
278
|
+
if @self_auth && !@no_create
|
279
|
+
raise "This controller appears to be the same as the authentication object but in this context you cannot build a new/create action; please re-run with --no-create flag"
|
280
|
+
end
|
281
|
+
|
282
|
+
# old syntax
|
205
283
|
@nested_args = []
|
206
|
-
|
207
|
-
|
284
|
+
|
285
|
+
# new syntax
|
286
|
+
# @nested_set = [
|
287
|
+
# {
|
288
|
+
# singular: ...,
|
289
|
+
# plural: ...,
|
290
|
+
# optional: false
|
291
|
+
# }]
|
292
|
+
@nested_set = []
|
293
|
+
|
294
|
+
if ! @nested.nil?
|
295
|
+
|
296
|
+
|
297
|
+
@nested_args = @nested.split("/").collect{|x| x.gsub("~","")}
|
298
|
+
|
299
|
+
@nested_set = @nested.split("/").collect { |arg|
|
300
|
+
is_optional = arg.start_with?("~")
|
301
|
+
arg.gsub!("~","")
|
302
|
+
{
|
303
|
+
singular: arg,
|
304
|
+
plural: arg.pluralize,
|
305
|
+
optional: is_optional
|
306
|
+
}
|
307
|
+
|
308
|
+
}
|
309
|
+
|
310
|
+
puts "@nested_set is #{@nested_set}"
|
208
311
|
@nested_args_plural = {}
|
312
|
+
|
313
|
+
|
209
314
|
@nested_args.each do |a|
|
210
315
|
@nested_args_plural[a] = a + "s"
|
211
316
|
end
|
212
317
|
end
|
213
|
-
@nestable = @nested_args.any?
|
214
|
-
|
215
318
|
|
216
319
|
@magic_buttons = []
|
217
320
|
if options['magic_buttons']
|
218
321
|
@magic_buttons = options['magic_buttons'].split(',')
|
219
322
|
end
|
220
323
|
|
324
|
+
|
325
|
+
@small_buttons = options['small_buttons'] || false
|
326
|
+
|
221
327
|
@build_update_action = !@no_edit || !@magic_buttons.empty?
|
222
328
|
# if the magic buttons are present, build the update action anyway
|
223
329
|
|
@@ -225,27 +331,41 @@ module HotGlue
|
|
225
331
|
if @auth && ! @self_auth && @nested_args.none?
|
226
332
|
@object_owner_sym = @auth.gsub("current_", "").to_sym
|
227
333
|
@object_owner_eval = @auth
|
334
|
+
@object_owner_optional = false
|
228
335
|
else
|
229
336
|
|
230
337
|
if @nested_args.any?
|
231
|
-
@object_owner_sym = @
|
232
|
-
@object_owner_eval = "@#{@
|
338
|
+
@object_owner_sym = @nested_set.last[:singular].to_sym
|
339
|
+
@object_owner_eval = "@#{@nested_set.last[:singular]}"
|
340
|
+
@object_owner_name = @nested_set.last[:singular]
|
341
|
+
@object_owner_optional = @nested_set.last[:optional]
|
233
342
|
else
|
234
343
|
@object_owner_sym = ""
|
235
344
|
@object_owner_eval = ""
|
236
345
|
end
|
237
346
|
end
|
238
347
|
|
348
|
+
|
349
|
+
@ujs_syntax = options['ujs_syntax']
|
350
|
+
|
351
|
+
if !@ujs_syntax
|
352
|
+
@ujs_syntax = !defined?(Turbo::Engine)
|
353
|
+
end
|
239
354
|
@reference_name = HotGlue.derrive_reference_name(singular_class)
|
240
355
|
|
241
356
|
identify_object_owner
|
242
357
|
setup_fields
|
243
358
|
|
359
|
+
if (@columns - @show_only - (@object_owner_sym.empty? ? [] : [@ownership_field.to_sym])).empty?
|
360
|
+
@no_field_form = true
|
361
|
+
end
|
362
|
+
|
363
|
+
buttons_width = ((!@no_edit && 1) || 0) + ((!@no_delete && 1) || 0) + @magic_buttons.count
|
364
|
+
|
244
365
|
builder = HotGlue::Layout::Builder.new({
|
245
366
|
include_setting: options['include'],
|
246
367
|
downnest_children: @downnest_children,
|
247
|
-
|
248
|
-
no_delete: @no_delete,
|
368
|
+
buttons_width: buttons_width,
|
249
369
|
columns: @columns,
|
250
370
|
smart_layout: @smart_layout
|
251
371
|
})
|
@@ -263,21 +383,19 @@ module HotGlue
|
|
263
383
|
|
264
384
|
if assoc
|
265
385
|
@ownership_field = assoc.name.to_s + "_id"
|
266
|
-
elsif
|
267
|
-
|
386
|
+
elsif ! @nested_args.any?
|
387
|
+
|
388
|
+
exit_message = "*** Oops: It looks like is no association from class called #{@singular_class} to the current_#{@object_owner_sym}. If your user is called something else, pass with flag auth=current_X where X is the model for your users as lowercase. Also, be sure to implement current_X as a method on your controller. (If you really don't want to implement a current_X on your controller and want me to check some other method for your current user, see the section in the docs for auth_identifier.) To make a controller that can read all records, specify with --god."
|
389
|
+
raise(HotGlue::Error, exit_message)
|
268
390
|
|
269
391
|
else
|
270
|
-
|
271
|
-
|
392
|
+
|
393
|
+
if eval(singular_class + ".reflect_on_association(:#{@object_owner_sym.to_s})").nil? && !eval(singular_class + ".reflect_on_association(:#{@object_owner_sym.to_s.singularize})").nil?
|
394
|
+
exit_message = "*** Oops: you tried to nest #{singular_class} within a route for `#{@object_owner_sym}` but I can't find an association for this relationship. Did you mean `#{@object_owner_sym.to_s.singularize}` (singular) instead?"
|
272
395
|
else
|
273
|
-
@
|
274
|
-
@nested_args.each do |arg|
|
275
|
-
if ! @auth_check.reflect_on_association("#{arg}s".to_sym)
|
276
|
-
exit_message = "*** Oops: your nesting chain does not have a association for #{arg}s on #{@auth_check} something is wrong."
|
277
|
-
end
|
278
|
-
end
|
396
|
+
exit_message = "*** Oops: Missing relationship from class #{singular_class} to :#{@object_owner_sym} maybe add `belongs_to :#{@object_owner_sym}` to #{singular_class}\n (If your user is called something else, pass with flag auth=current_X where X is the model for your auth object as lowercase. Also, be sure to implement current_X as a method on your controller. If you really don't want to implement a current_X on your controller and want me to check some other method for your current user, see the section in the docs for --auth-identifier flag). To make a controller that can read all records, specify with --god."
|
279
397
|
end
|
280
|
-
|
398
|
+
|
281
399
|
raise(HotGlue::Error, exit_message)
|
282
400
|
end
|
283
401
|
end
|
@@ -357,7 +475,7 @@ module HotGlue
|
|
357
475
|
def copy_controller_and_spec_files
|
358
476
|
@default_colspan = @columns.size
|
359
477
|
unless @specs_only
|
360
|
-
template "controller.rb.erb", File.join("#{'spec/dummy/' if Rails.env.test?}app/controllers#{namespace_with_dash}", "#{
|
478
|
+
template "controller.rb.erb", File.join("#{'spec/dummy/' if Rails.env.test?}app/controllers#{namespace_with_dash}", "#{@controller_build_folder}_controller.rb")
|
361
479
|
if @namespace
|
362
480
|
begin
|
363
481
|
eval(controller_descends_from)
|
@@ -461,10 +579,7 @@ module HotGlue
|
|
461
579
|
|
462
580
|
|
463
581
|
def controller_class_name
|
464
|
-
|
465
|
-
res << @namespace.titleize + "::" if @namespace
|
466
|
-
res << plural.titleize.gsub(" ", "") + "Controller"
|
467
|
-
res
|
582
|
+
@controller_build_name
|
468
583
|
end
|
469
584
|
|
470
585
|
def singular_name
|
@@ -480,7 +595,7 @@ module HotGlue
|
|
480
595
|
end
|
481
596
|
|
482
597
|
def path_helper_args
|
483
|
-
if @nested_args.any? && @
|
598
|
+
if @nested_args.any? && @nested
|
484
599
|
[(@nested_args).collect{|a| "#{a}"} , singular].join(",")
|
485
600
|
else
|
486
601
|
singular
|
@@ -488,49 +603,88 @@ module HotGlue
|
|
488
603
|
end
|
489
604
|
|
490
605
|
def path_helper_singular
|
491
|
-
if @
|
492
|
-
"#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_" if @nested_args.any?)}#{
|
606
|
+
if @nested
|
607
|
+
"#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_" if @nested_args.any?)}#{@controller_build_folder_singular}_path"
|
493
608
|
else
|
494
|
-
"#{@namespace+"_" if @namespace}#{
|
609
|
+
"#{@namespace+"_" if @namespace}#{@controller_build_folder_singular}_path"
|
495
610
|
end
|
496
611
|
end
|
497
612
|
|
498
613
|
def path_helper_plural
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
614
|
+
HotGlue.optionalized_ternary(namespace: @namespace,
|
615
|
+
target: @controller_build_folder,
|
616
|
+
nested_set: @nested_set)
|
617
|
+
end
|
618
|
+
|
619
|
+
def form_path_new_helper
|
620
|
+
HotGlue.optionalized_ternary(namespace: @namespace,
|
621
|
+
target: @controller_build_folder,
|
622
|
+
nested_set: @nested_set,
|
623
|
+
with_params: true,
|
624
|
+
top_level: false)
|
625
|
+
end
|
626
|
+
|
627
|
+
def form_path_edit_helper
|
628
|
+
HotGlue.optionalized_ternary(namespace: @namespace,
|
629
|
+
target: @singular,
|
630
|
+
nested_set: @nested_set,
|
631
|
+
with_params: true,
|
632
|
+
put_form: true,
|
633
|
+
top_level: true)
|
634
|
+
end
|
635
|
+
|
636
|
+
|
637
|
+
def delete_path_helper
|
638
|
+
HotGlue.optionalized_ternary(namespace: @namespace,
|
639
|
+
target: @singular,
|
640
|
+
nested_set: @nested_set,
|
641
|
+
with_params: true,
|
642
|
+
put_form: true)
|
643
|
+
end
|
644
|
+
|
645
|
+
def edit_path_helper
|
646
|
+
HotGlue.optionalized_ternary(namespace: @namespace,
|
647
|
+
target: @singular,
|
648
|
+
nested_set: @nested_set,
|
649
|
+
modifier: "edit_",
|
650
|
+
with_params: true,
|
651
|
+
put_form: true)
|
504
652
|
end
|
505
653
|
|
506
654
|
def path_arity
|
507
655
|
res = ""
|
508
|
-
if @nested_args.any? && @
|
656
|
+
if @nested_args.any? && @nested
|
509
657
|
res << nested_objects_arity + ", "
|
510
658
|
end
|
511
659
|
res << "@" + singular
|
512
660
|
end
|
513
661
|
|
514
662
|
def line_path_partial
|
515
|
-
"#{@namespace+"/" if @namespace}#{
|
663
|
+
"#{@namespace+"/" if @namespace}#{@controller_build_folder}/line"
|
516
664
|
end
|
517
665
|
|
518
666
|
def show_path_partial
|
519
|
-
"#{@namespace+"/" if @namespace}#{
|
667
|
+
"#{@namespace+"/" if @namespace}#{@controller_build_folder}/show"
|
520
668
|
end
|
521
669
|
|
522
670
|
def list_path_partial
|
523
|
-
"#{@namespace+"/" if @namespace}#{
|
671
|
+
"#{@namespace+"/" if @namespace}#{@controller_build_folder}/list"
|
524
672
|
end
|
525
673
|
|
526
674
|
def new_path_name
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
base
|
675
|
+
|
676
|
+
HotGlue.optionalized_ternary(namespace: @namespace,
|
677
|
+
target: singular,
|
678
|
+
nested_set: @nested_set,
|
679
|
+
modifier: "new_",
|
680
|
+
with_params: true)
|
681
|
+
# base = "new_#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_") if @nested_args.any?}#{@controller_build_folder_singular}_path"
|
682
|
+
# if @nested_args.any?
|
683
|
+
# base += "(" + @nested_args.collect { |arg|
|
684
|
+
# "#{arg}.id"
|
685
|
+
# }.join(", ") + ")"
|
686
|
+
# end
|
687
|
+
# base
|
534
688
|
end
|
535
689
|
|
536
690
|
def nested_assignments
|
@@ -545,7 +699,7 @@ module HotGlue
|
|
545
699
|
|
546
700
|
def nest_assignments_operator(top_level = false, leading_comma = false)
|
547
701
|
if @nested_args.any?
|
548
|
-
"#{
|
702
|
+
"#{", " if leading_comma}#{top_level ? nested_assignments_top_level : nested_assignments }"
|
549
703
|
else
|
550
704
|
""
|
551
705
|
end
|
@@ -614,10 +768,14 @@ module HotGlue
|
|
614
768
|
|
615
769
|
def magic_button_output
|
616
770
|
@template_builder.magic_button_output(
|
617
|
-
|
618
|
-
|
771
|
+
path: HotGlue.optionalized_ternary(namespace: @namespace,
|
772
|
+
target: @singular,
|
773
|
+
nested_set: @nested_set,
|
774
|
+
with_params: true,
|
775
|
+
put_form: true),
|
619
776
|
singular: singular,
|
620
|
-
magic_buttons: @magic_buttons
|
777
|
+
magic_buttons: @magic_buttons,
|
778
|
+
small_buttons: @small_buttons
|
621
779
|
)
|
622
780
|
end
|
623
781
|
|
@@ -630,7 +788,7 @@ module HotGlue
|
|
630
788
|
|
631
789
|
|
632
790
|
dest_filepath = File.join("#{'spec/dummy/' if Rails.env.test?}app/views#{namespace_with_dash}",
|
633
|
-
|
791
|
+
@controller_build_folder, dest_filename)
|
634
792
|
|
635
793
|
|
636
794
|
template source_filename, dest_filepath
|
@@ -644,7 +802,7 @@ module HotGlue
|
|
644
802
|
source_filename = cc_filename_with_extensions( "#{@markup}/#{view}.turbo_stream.#{@markup}")
|
645
803
|
dest_filename = cc_filename_with_extensions("#{view}", "turbo_stream.#{@markup}")
|
646
804
|
dest_filepath = File.join("#{'spec/dummy/' if Rails.env.test?}app/views#{namespace_with_dash}",
|
647
|
-
|
805
|
+
@controller_build_folder, dest_filename)
|
648
806
|
|
649
807
|
|
650
808
|
template source_filename, dest_filepath
|
@@ -652,6 +810,15 @@ module HotGlue
|
|
652
810
|
|
653
811
|
end
|
654
812
|
end
|
813
|
+
|
814
|
+
# menu_file = "app/views#{namespace_with_dash}/menu.erb"
|
815
|
+
#
|
816
|
+
# if File.exists?(menu_file)
|
817
|
+
# # TODO: can I insert the new menu item into the menu programatically here?
|
818
|
+
# # not sure how i would acheive this without nokogiri
|
819
|
+
#
|
820
|
+
# end
|
821
|
+
|
655
822
|
end
|
656
823
|
|
657
824
|
def namespace_with_dash
|
@@ -717,19 +884,15 @@ module HotGlue
|
|
717
884
|
end
|
718
885
|
|
719
886
|
def all_form_fields
|
720
|
-
|
721
|
-
if !@smart_layout
|
722
|
-
col_identifier = @layout == "hotglue" ? "scaffold-cell" : "col-md-1"
|
723
|
-
else
|
724
|
-
col_identifier = @layout == "hotglue" ? "scaffold-cell" : "col-md-2"
|
725
|
-
end
|
887
|
+
col_identifier = (@layout == "hotglue") ? "scaffold-cell" : "col-md-#{@layout_object[:columns][:size_each]}"
|
726
888
|
|
727
889
|
@template_builder.all_form_fields(
|
728
890
|
columns: @layout_object[:columns][:container],
|
729
891
|
show_only: @show_only,
|
730
892
|
singular_class: singular_class,
|
731
893
|
singular: singular,
|
732
|
-
col_identifier: col_identifier
|
894
|
+
col_identifier: col_identifier,
|
895
|
+
ownership_field: @ownership_field
|
733
896
|
)
|
734
897
|
end
|
735
898
|
|
@@ -758,6 +921,7 @@ module HotGlue
|
|
758
921
|
end
|
759
922
|
|
760
923
|
def all_line_fields
|
924
|
+
col_identifier = (@layout == "hotglue") ? "scaffold-cell" : "col-md-#{@layout_object[:columns][:size_each]}"
|
761
925
|
|
762
926
|
@template_builder.all_line_fields(
|
763
927
|
perc_width: column_width,
|
@@ -765,13 +929,14 @@ module HotGlue
|
|
765
929
|
show_only: @show_only,
|
766
930
|
singular_class: singular_class,
|
767
931
|
singular: singular,
|
768
|
-
layout: @layout
|
932
|
+
layout: @layout,
|
933
|
+
col_identifier: col_identifier
|
769
934
|
)
|
770
935
|
end
|
771
936
|
|
772
937
|
def controller_descends_from
|
773
|
-
if defined?(@namespace.titlecase + "::BaseController")
|
774
|
-
@namespace.titlecase + "::BaseController"
|
938
|
+
if defined?(@namespace.titlecase.gsub(" ", "") + "::BaseController")
|
939
|
+
@namespace.titlecase.gsub(" ", "") + "::BaseController"
|
775
940
|
else
|
776
941
|
"ApplicationController"
|
777
942
|
end
|
@@ -825,13 +990,13 @@ module HotGlue
|
|
825
990
|
@template_builder.paginate(plural: plural)
|
826
991
|
end
|
827
992
|
|
828
|
-
def delete_confirmation_syntax
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
end
|
993
|
+
# def delete_confirmation_syntax
|
994
|
+
# if !@stimulus_syntax
|
995
|
+
# "{confirm: 'Are you sure?'}"
|
996
|
+
# else
|
997
|
+
# "{controller: 'confirmable', 'confirm-message': \"Are you sure you want to delete \#{ #{@singular}.#{ display_class } } \", 'action': 'confirmation#confirm'}"
|
998
|
+
# end
|
999
|
+
# end
|
835
1000
|
|
836
1001
|
|
837
1002
|
def controller_magic_button_update_actions
|
@@ -858,10 +1023,10 @@ module HotGlue
|
|
858
1023
|
|
859
1024
|
|
860
1025
|
def nested_for_turbo_id_list_constructor
|
861
|
-
if @
|
862
|
-
""
|
1026
|
+
if @nested_set.any?
|
1027
|
+
'+ (((\'__\' + nested_for) if defined?(nested_for)) || "")'
|
863
1028
|
else
|
864
|
-
"
|
1029
|
+
""
|
865
1030
|
end
|
866
1031
|
end
|
867
1032
|
|
@@ -869,9 +1034,11 @@ module HotGlue
|
|
869
1034
|
instance_symbol = "@" if top_level
|
870
1035
|
instance_symbol = "" if !top_level
|
871
1036
|
if @nested_args.none?
|
872
|
-
""
|
1037
|
+
"\"\""
|
873
1038
|
else
|
874
|
-
|
1039
|
+
@nested_set.collect{|arg|
|
1040
|
+
"(((\"__#{arg[:singular]}-\#{" + "@" + arg[:singular] + ".id}\") if @" + arg[:singular] + ") || \"\")"
|
1041
|
+
}.join(" + ")
|
875
1042
|
end
|
876
1043
|
end
|
877
1044
|
|