hot-glue 0.5.14 → 0.5.16
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 +74 -0
- data/.github/workflows/test.yml +33 -14
- data/.gitignore +0 -2
- data/.ruby-version +1 -1
- data/Gemfile +4 -2
- data/Gemfile.lock +280 -0
- data/README.md +33 -4
- data/lib/generators/hot_glue/direct_upload_install_generator.rb +1 -1
- data/lib/generators/hot_glue/dropzone_install_generator.rb +1 -1
- data/lib/generators/hot_glue/field_factory.rb +6 -2
- data/lib/generators/hot_glue/fields/association_field.rb +73 -6
- data/lib/generators/hot_glue/fields/attachment_field.rb +7 -3
- data/lib/generators/hot_glue/fields/boolean_field.rb +31 -1
- data/lib/generators/hot_glue/fields/date_field.rb +13 -0
- data/lib/generators/hot_glue/fields/date_time_field.rb +30 -3
- data/lib/generators/hot_glue/fields/enum_field.rb +39 -6
- data/lib/generators/hot_glue/fields/field.rb +92 -8
- data/lib/generators/hot_glue/fields/float_field.rb +11 -0
- data/lib/generators/hot_glue/fields/integer_field.rb +4 -0
- data/lib/generators/hot_glue/fields/string_field.rb +17 -0
- data/lib/generators/hot_glue/fields/text_field.rb +17 -0
- data/lib/generators/hot_glue/fields/time_field.rb +20 -0
- data/lib/generators/hot_glue/fields/uuid_field.rb +1 -1
- data/lib/generators/hot_glue/flash_notices_install_generator.rb +1 -1
- data/lib/generators/hot_glue/install_generator.rb +15 -9
- data/lib/generators/hot_glue/layout/builder.rb +4 -2
- data/lib/generators/hot_glue/markup_templates/erb.rb +14 -279
- data/lib/generators/hot_glue/scaffold_generator.rb +133 -151
- data/lib/generators/hot_glue/templates/erb/_edit.erb +1 -1
- data/lib/hotglue/version.rb +1 -1
- data/script/test +9 -14
- metadata +5 -3
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require 'rails/generators/erb/scaffold/scaffold_generator'
|
3
2
|
require_relative './default_config_loader'
|
4
3
|
require 'ffaker'
|
@@ -12,23 +11,16 @@ require_relative './layout_strategy/bootstrap'
|
|
12
11
|
require_relative './layout_strategy/hot_glue'
|
13
12
|
require_relative './layout_strategy/tailwind'
|
14
13
|
|
15
|
-
|
16
|
-
|
17
14
|
class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
18
15
|
include DefaultConfigLoader
|
19
16
|
hook_for :form_builder, :as => :scaffold
|
20
17
|
|
21
18
|
source_root File.expand_path('templates', __dir__)
|
22
|
-
attr_accessor :alt_lookups, :attachments, :auth,
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:hawk_keys, :layout_object,
|
28
|
-
:nest_with,
|
29
|
-
:path, :plural,
|
30
|
-
:sample_file_path, :singular, :singular_class, :smart_layout,
|
31
|
-
:stacked_downnesting, :update_show_only
|
19
|
+
attr_accessor :alt_lookups, :attachments, :auth, :big_edit, :button_icons, :bootstrap_column_width, :columns,
|
20
|
+
:downnest_children, :downnest_object, :hawk_keys, :layout_object, :modify,
|
21
|
+
:nest_with, :path, :plural, :sample_file_path, :show_only_data, :singular,
|
22
|
+
:singular_class, :smart_layout, :stacked_downnesting, :update_show_only, :ownership_field,
|
23
|
+
:layout_strategy, :form_placeholder_labels, :form_labels_position
|
32
24
|
|
33
25
|
class_option :singular, type: :string, default: nil
|
34
26
|
class_option :plural, type: :string, default: nil
|
@@ -76,7 +68,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
76
68
|
|
77
69
|
# determines if the labels show up BEFORE or AFTER on the NEW/EDIT (form)
|
78
70
|
class_option :form_labels_position, type: :string, default: 'after' # choices are before, after, omit
|
79
|
-
class_option :form_placeholder_labels, type: :boolean,
|
71
|
+
class_option :form_placeholder_labels, type: :boolean, default: false # puts the field names into the placeholder labels
|
80
72
|
|
81
73
|
# determines if labels appear within the rows of the VIEWABLE list (does NOT affect the list heading)
|
82
74
|
class_option :inline_list_labels, default: 'omit' # choices are before, after, omit
|
@@ -84,8 +76,9 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
84
76
|
class_option :alt_foreign_key_lookup, default: '' #
|
85
77
|
class_option :attachments, default: ''
|
86
78
|
class_option :stacked_downnesting, default: false
|
87
|
-
class_option :bootstrap_column_width, default: nil #must be nil to detect if user has not passed
|
79
|
+
class_option :bootstrap_column_width, default: nil # must be nil to detect if user has not passed
|
88
80
|
class_option :button_icons, default: nil
|
81
|
+
class_option :modify, default: {}
|
89
82
|
|
90
83
|
def initialize(*meta_args)
|
91
84
|
super
|
@@ -101,17 +94,16 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
101
94
|
@meta_args = meta_args
|
102
95
|
|
103
96
|
if options['specs_only'] && options['no_specs']
|
104
|
-
raise(HotGlue::Error,
|
97
|
+
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.")
|
105
98
|
end
|
106
99
|
|
107
100
|
if !options['exclude'].empty? && !options['include'].empty?
|
108
|
-
exit_message =
|
101
|
+
exit_message = "*** Oops: You seem to have specified both --include and --exclude. Please use one or the other. Aborting."
|
109
102
|
puts exit_message
|
110
103
|
|
111
104
|
raise(HotGlue::Error, exit_message)
|
112
105
|
end
|
113
106
|
|
114
|
-
|
115
107
|
if @stimulus_syntax.nil?
|
116
108
|
@stimulus_syntax = true
|
117
109
|
end
|
@@ -121,7 +113,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
121
113
|
raise(HotGlue::Error, message)
|
122
114
|
end
|
123
115
|
|
124
|
-
@markup =
|
116
|
+
@markup = get_default_from_config(key: :markup)
|
125
117
|
@sample_file_path = get_default_from_config(key: :sample_file_path)
|
126
118
|
@bootstrap_column_width ||= get_default_from_config(key: :bootstrap_column_width) || 2
|
127
119
|
|
@@ -156,13 +148,13 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
156
148
|
|
157
149
|
@plural = options['plural'] || @singular.pluralize # respects what you set in inflections.rb, to override, use plural option
|
158
150
|
@namespace = options['namespace'] || nil
|
159
|
-
use_controller_name =
|
160
|
-
@controller_build_name = ((
|
151
|
+
use_controller_name = plural.titleize.gsub(" ", "")
|
152
|
+
@controller_build_name = ((@namespace.titleize.gsub(" ", "") + "::" if @namespace) || "") + use_controller_name + "Controller"
|
161
153
|
@controller_build_folder = use_controller_name.underscore
|
162
154
|
@controller_build_folder_singular = singular
|
163
155
|
|
164
156
|
@auth = options['auth'] || "current_user"
|
165
|
-
@auth_identifier = options['auth_identifier'] || (
|
157
|
+
@auth_identifier = options['auth_identifier'] || (!@god && @auth.gsub("current_", "")) || nil
|
166
158
|
|
167
159
|
if options['nest']
|
168
160
|
raise HotGlue::Error, "STOP: the flag --nest has been replaced with --nested; please re-run using the --nested flag"
|
@@ -179,20 +171,48 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
179
171
|
@include_fields = []
|
180
172
|
|
181
173
|
# semicolon to denote layout columns; commas separate fields
|
182
|
-
@include_fields += options['include'].split(":").collect{|x|x.split(",")}.flatten.collect(&:to_sym)
|
174
|
+
@include_fields += options['include'].split(":").collect { |x| x.split(",") }.flatten.collect(&:to_sym)
|
183
175
|
end
|
184
176
|
|
185
|
-
@
|
186
|
-
if !options['show_only'].empty?
|
187
|
-
|
177
|
+
# @show_only_data = {}
|
178
|
+
# if !options['show_only'].empty?
|
179
|
+
# show_only_input = options['show_only'].split(",")
|
180
|
+
# show_only_input.each do |setting|
|
181
|
+
# if setting.include?("[")
|
182
|
+
# setting =~ /(.*)\[(.*)\]/
|
183
|
+
# key, lookup_as = $1, $2
|
184
|
+
# @show_only_data[key.to_sym] = {cast: $2 }
|
185
|
+
# else
|
186
|
+
# @show_only_data[setting.to_sym] = {cast: nil}
|
187
|
+
# end
|
188
|
+
# end
|
189
|
+
# end
|
190
|
+
|
191
|
+
@show_only = options['show_only'].split(",").collect(&:to_sym)
|
192
|
+
if @show_only.any?
|
193
|
+
puts "show only field #{@show_only}}"
|
188
194
|
end
|
189
195
|
|
196
|
+
@modify = {}
|
197
|
+
if !options['modify'].empty?
|
198
|
+
modify_input = options['modify'].split(",")
|
199
|
+
modify_input.each do |setting|
|
200
|
+
setting =~ /(.*){(.*)}/
|
201
|
+
key, lookup_as = $1, $2
|
202
|
+
|
203
|
+
if ["$"].include?($2)
|
204
|
+
@modify[key.to_sym] = {cast: $2}
|
205
|
+
elsif $2.include?("|")
|
206
|
+
binary = $2.split("|")
|
207
|
+
@modify[key.to_sym] = {binary: {truthy: binary[0], falsy: binary[1]}}
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
190
211
|
@update_show_only = []
|
191
212
|
if !options['update_show_only'].empty?
|
192
213
|
@update_show_only += options['update_show_only'].split(",").collect(&:to_sym)
|
193
214
|
end
|
194
215
|
|
195
|
-
|
196
216
|
# syntax should be xyz_id{xyz_email},abc_id{abc_email}
|
197
217
|
# instead of a drop-down for the foreign entity, a text field will be presented
|
198
218
|
# You must ALSO use a factory that contains a parameter of the same name as the 'value' (for example, `xyz_email`)
|
@@ -202,48 +222,40 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
202
222
|
@alt_foreign_key_lookup = alt_lookups_entry.each do |setting|
|
203
223
|
setting =~ /(.*){(.*)}/
|
204
224
|
key, lookup_as = $1, $2
|
205
|
-
assoc = eval("#{class_name}.reflect_on_association(:#{key.to_s.gsub("_id","")}).class_name")
|
225
|
+
assoc = eval("#{class_name}.reflect_on_association(:#{key.to_s.gsub("_id", "")}).class_name")
|
206
226
|
|
207
|
-
data = {lookup_as: lookup_as.gsub("+",""),
|
208
|
-
|
209
|
-
|
227
|
+
data = { lookup_as: lookup_as.gsub("+", ""),
|
228
|
+
assoc: assoc,
|
229
|
+
with_create: lookup_as.include?("+") }
|
210
230
|
@alt_lookups[key] = data
|
211
231
|
end
|
212
232
|
|
213
233
|
puts "------ ALT LOOKUPS for #{@alt_lookups}"
|
214
234
|
|
215
|
-
@update_alt_lookups = @alt_lookups.collect{|key, value|
|
235
|
+
@update_alt_lookups = @alt_lookups.collect { |key, value|
|
216
236
|
@update_show_only.include?(key) ?
|
217
|
-
{
|
218
|
-
: nil}.compact
|
237
|
+
{ key: value }
|
238
|
+
: nil }.compact
|
219
239
|
|
220
|
-
@label = options['label'] || (
|
221
|
-
@list_label_heading =
|
240
|
+
@label = options['label'] || (eval("#{class_name}.class_variable_defined?(:@@table_label_singular)") ? eval("#{class_name}.class_variable_get(:@@table_label_singular)") : singular.gsub("_", " ").titleize)
|
241
|
+
@list_label_heading = options['list_label_heading'] || (eval("#{class_name}.class_variable_defined?(:@@table_label_plural)") ? eval("#{class_name}.class_variable_get(:@@table_label_plural)") : plural.gsub("_", " ").upcase)
|
222
242
|
|
223
|
-
@new_button_label = options['new_button_label'] || (
|
243
|
+
@new_button_label = options['new_button_label'] || (eval("#{class_name}.class_variable_defined?(:@@table_label_singular)") ? "New " + eval("#{class_name}.class_variable_get(:@@table_label_singular)") : "New " + singular.gsub("_", " ").titleize)
|
224
244
|
@new_form_heading = options['new_form_heading'] || "New #{@label}"
|
225
245
|
|
226
|
-
|
227
|
-
|
228
246
|
setup_hawk_keys
|
229
247
|
@form_placeholder_labels = options['form_placeholder_labels'] # true or false
|
230
|
-
@inline_list_labels = options['inline_list_labels']
|
231
|
-
|
248
|
+
@inline_list_labels = options['inline_list_labels'] || 'omit' # 'before','after','omit'
|
232
249
|
|
233
250
|
@form_labels_position = options['form_labels_position']
|
234
|
-
if !['before','after','omit'].include?(@form_labels_position)
|
251
|
+
if !['before', 'after', 'omit'].include?(@form_labels_position)
|
235
252
|
raise HotGlue::Error, "You passed '#{@form_labels_position}' as the setting for --form-labels-position but the only allowed options are before, after (default), and omit"
|
236
253
|
end
|
237
254
|
|
238
|
-
if !['before','after','omit'].include?(@inline_list_labels)
|
255
|
+
if !['before', 'after', 'omit'].include?(@inline_list_labels)
|
239
256
|
raise HotGlue::Error, "You passed '#{@inline_list_labels}' as the setting for --inline-list-labels but the only allowed options are before, after, and omit (default)"
|
240
257
|
end
|
241
258
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
259
|
@god = options['god'] || options['gd'] || false
|
248
260
|
@specs_only = options['specs_only'] || false
|
249
261
|
|
@@ -260,9 +272,6 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
260
272
|
@no_list_heading = options['no_list_heading'] || false
|
261
273
|
@stacked_downnesting = options['stacked_downnesting']
|
262
274
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
275
|
@display_list_after_update = options['display_list_after_update'] || false
|
267
276
|
@smart_layout = options['smart_layout']
|
268
277
|
|
@@ -276,7 +285,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
276
285
|
@downnest_children = [] # TODO: defactor @downnest_children in favor of downnest_object
|
277
286
|
@downnest_object = {}
|
278
287
|
if @downnest
|
279
|
-
@downnest_children = @downnest.split(",").map{|child| child.gsub("+","")}
|
288
|
+
@downnest_children = @downnest.split(",").map { |child| child.gsub("+", "") }
|
280
289
|
@downnest_object = HotGlue.construct_downnest_object(@downnest)
|
281
290
|
end
|
282
291
|
|
@@ -299,7 +308,6 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
299
308
|
@magic_buttons = options['magic_buttons'].split(',')
|
300
309
|
end
|
301
310
|
|
302
|
-
|
303
311
|
@small_buttons = options['small_buttons'] || false
|
304
312
|
|
305
313
|
@build_update_action = !@no_edit || !@magic_buttons.empty?
|
@@ -310,7 +318,6 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
310
318
|
@ujs_syntax = !defined?(Turbo::Engine)
|
311
319
|
end
|
312
320
|
|
313
|
-
|
314
321
|
# NEST CHAIN
|
315
322
|
# new syntax
|
316
323
|
# @nested_set = [
|
@@ -321,10 +328,10 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
321
328
|
# }]
|
322
329
|
@nested_set = []
|
323
330
|
|
324
|
-
if
|
331
|
+
if !@nested.nil?
|
325
332
|
@nested_set = @nested.split("/").collect { |arg|
|
326
333
|
is_optional = arg.start_with?("~")
|
327
|
-
arg.gsub!("~","")
|
334
|
+
arg.gsub!("~", "")
|
328
335
|
{
|
329
336
|
singular: arg,
|
330
337
|
plural: arg.pluralize,
|
@@ -342,8 +349,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
342
349
|
@object_owner_optional = false
|
343
350
|
@object_owner_name = @auth.gsub("current_", "").to_s
|
344
351
|
|
345
|
-
|
346
|
-
elsif @auth && ! @self_auth && @nested_set.none? && !@auth.include?(".")
|
352
|
+
elsif @auth && !@self_auth && @nested_set.none? && !@auth.include?(".")
|
347
353
|
@object_owner_sym = @auth.gsub("current_", "").to_sym
|
348
354
|
@object_owner_eval = @auth
|
349
355
|
@object_owner_optional = false
|
@@ -364,12 +370,11 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
364
370
|
end
|
365
371
|
end
|
366
372
|
|
367
|
-
|
368
373
|
@factory_creation = options['factory_creation'].gsub(";", "\n")
|
369
374
|
identify_object_owner
|
370
375
|
setup_fields
|
371
376
|
|
372
|
-
if
|
377
|
+
if (@columns - @show_only - (@ownership_field ? [@ownership_field.to_sym] : [])).empty?
|
373
378
|
@no_field_form = true
|
374
379
|
end
|
375
380
|
|
@@ -379,7 +384,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
379
384
|
@associations = []
|
380
385
|
@columns_map = {}
|
381
386
|
@columns.each do |col|
|
382
|
-
if !(@the_object.columns_hash.keys.include?(col.to_s) ||
|
387
|
+
if !(@the_object.columns_hash.keys.include?(col.to_s) || @attachments.keys.include?(col))
|
383
388
|
raise "couldn't find #{col} in either field list or attachments list"
|
384
389
|
end
|
385
390
|
|
@@ -388,7 +393,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
388
393
|
end
|
389
394
|
|
390
395
|
if @the_object.columns_hash.keys.include?(col.to_s)
|
391
|
-
type =
|
396
|
+
type = @the_object.columns_hash[col.to_s].type
|
392
397
|
elsif @attachments.keys.include?(col)
|
393
398
|
type = :attachment
|
394
399
|
end
|
@@ -402,10 +407,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
402
407
|
@columns_map[col] = this_column_object.field
|
403
408
|
end
|
404
409
|
|
405
|
-
|
406
|
-
|
407
410
|
# create the template object
|
408
|
-
if
|
411
|
+
if @markup == "erb"
|
409
412
|
@template_builder = HotGlue::ErbTemplate.new(
|
410
413
|
layout_strategy: @layout_strategy,
|
411
414
|
magic_buttons: @magic_buttons,
|
@@ -423,26 +426,22 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
423
426
|
attachments: @attachments,
|
424
427
|
columns_map: @columns_map
|
425
428
|
)
|
426
|
-
elsif
|
427
|
-
raise(HotGlue::Error,
|
428
|
-
elsif
|
429
|
-
raise(HotGlue::Error,
|
429
|
+
elsif @markup == "slim"
|
430
|
+
raise(HotGlue::Error, "SLIM IS NOT IMPLEMENTED")
|
431
|
+
elsif @markup == "haml"
|
432
|
+
raise(HotGlue::Error, "HAML IS NOT IMPLEMENTED")
|
430
433
|
end
|
431
434
|
|
432
435
|
builder = HotGlue::Layout::Builder.new(generator: self,
|
433
|
-
|
434
|
-
|
436
|
+
include_setting: options['include'],
|
437
|
+
buttons_width: buttons_width)
|
435
438
|
@layout_object = builder.construct
|
436
439
|
|
437
|
-
|
438
|
-
|
439
440
|
@menu_file_exists = true if @nested_set.none? && File.exist?("#{Rails.root}/app/views/#{namespace_with_trailing_dash}_menu.#{@markup}")
|
440
441
|
|
441
442
|
@turbo_streams = !!options['with_turbo_streams']
|
442
443
|
end
|
443
444
|
|
444
|
-
|
445
|
-
|
446
445
|
def setup_hawk_keys
|
447
446
|
@hawk_keys = {}
|
448
447
|
|
@@ -459,9 +458,9 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
459
458
|
end
|
460
459
|
|
461
460
|
hawk_scope = key.gsub("_id", "").pluralize
|
462
|
-
optional = eval(singular_class + ".reflect_on_association(:#{key.gsub('_id','')})").options[:optional]
|
461
|
+
optional = eval(singular_class + ".reflect_on_association(:#{key.gsub('_id', '')})").options[:optional]
|
463
462
|
|
464
|
-
@hawk_keys[key.to_sym] = {bind_to: [hawk_to], optional: optional}
|
463
|
+
@hawk_keys[key.to_sym] = { bind_to: [hawk_to], optional: optional }
|
465
464
|
use_shorthand = !options["hawk"].include?("{")
|
466
465
|
|
467
466
|
if use_shorthand # only include the hawk scope if using the shorthand
|
@@ -474,7 +473,6 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
474
473
|
end
|
475
474
|
end
|
476
475
|
|
477
|
-
|
478
476
|
def setup_attachments
|
479
477
|
@attachments = {}
|
480
478
|
|
@@ -539,7 +537,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
539
537
|
|
540
538
|
direct_upload = nil
|
541
539
|
field_for_original_filename = nil
|
542
|
-
dropzone
|
540
|
+
dropzone = nil
|
543
541
|
end
|
544
542
|
|
545
543
|
if thumbnail && !eval("#{singular_class}.reflect_on_attachment(:#{key}).variants.include?(:#{thumbnail})")
|
@@ -550,11 +548,10 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
550
548
|
"
|
551
549
|
end
|
552
550
|
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
dropzone: dropzone}
|
551
|
+
@attachments[key.to_sym] = { thumbnail: thumbnail,
|
552
|
+
field_for_original_filename: field_for_original_filename,
|
553
|
+
direct_upload: direct_upload,
|
554
|
+
dropzone: dropzone }
|
558
555
|
end
|
559
556
|
|
560
557
|
puts "ATTACHMENTS: #{@attachments}"
|
@@ -562,15 +559,15 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
562
559
|
end
|
563
560
|
|
564
561
|
def identify_object_owner
|
565
|
-
auth_assoc = @auth && @auth.gsub("current_","")
|
562
|
+
auth_assoc = @auth && @auth.gsub("current_", "")
|
566
563
|
|
567
|
-
if @object_owner_sym &&
|
564
|
+
if @object_owner_sym && !@self_auth
|
568
565
|
auth_assoc_field = auth_assoc + "_id" unless @god
|
569
566
|
assoc = eval("#{singular_class}.reflect_on_association(:#{@object_owner_sym})")
|
570
567
|
|
571
568
|
if assoc
|
572
569
|
@ownership_field = assoc.name.to_s + "_id"
|
573
|
-
elsif
|
570
|
+
elsif !@nested_set.any?
|
574
571
|
exit_message = "*** Oops: It looks like is no association `#{@object_owner_sym}` from the object #{@singular_class}. 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."
|
575
572
|
raise(HotGlue::Error, exit_message)
|
576
573
|
|
@@ -583,7 +580,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
583
580
|
|
584
581
|
raise(HotGlue::Error, exit_message)
|
585
582
|
end
|
586
|
-
elsif
|
583
|
+
elsif @object_owner_sym && !@object_owner_eval.include?(".")
|
587
584
|
@ownership_field = @object_owner_name + "_id"
|
588
585
|
end
|
589
586
|
end
|
@@ -596,18 +593,16 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
596
593
|
:confirmation_token, :confirmed_at,
|
597
594
|
:confirmation_sent_at, :unconfirmed_email
|
598
595
|
|
599
|
-
@exclude_fields.push(
|
600
|
-
|
601
|
-
|
602
|
-
@columns = @the_object.columns.map(&:name).map(&:to_sym).reject{|field| @exclude_fields.include?(field) }
|
596
|
+
@exclude_fields.push(@ownership_field.to_sym) if !@ownership_field.nil?
|
603
597
|
|
598
|
+
@columns = @the_object.columns.map(&:name).map(&:to_sym).reject { |field| @exclude_fields.include?(field) }
|
604
599
|
|
605
600
|
else
|
606
|
-
@columns = @the_object.columns.map(&:name).map(&:to_sym).reject{|field| !@include_fields.include?(field) }
|
601
|
+
@columns = @the_object.columns.map(&:name).map(&:to_sym).reject { |field| !@include_fields.include?(field) }
|
607
602
|
end
|
608
603
|
|
609
604
|
if @attachments.any?
|
610
|
-
puts "
|
605
|
+
puts "Adding attachments-as-columns: #{@attachments}"
|
611
606
|
@attachments.keys.each do |attachment|
|
612
607
|
@columns << attachment if !@columns.include?(attachment)
|
613
608
|
end
|
@@ -616,21 +611,16 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
616
611
|
end
|
617
612
|
end
|
618
613
|
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
614
|
def check_if_sample_file_is_present
|
625
615
|
if sample_file_path.nil?
|
626
616
|
puts "you have no sample file path set in config/hot_glue.yml"
|
627
617
|
settings = File.read("config/hot_glue.yml")
|
628
618
|
@sample_file_path = "spec/files/computer_code.jpg"
|
629
619
|
added_setting = ":sample_file_path: #{sample_file_path}"
|
630
|
-
File.open("config/hot_glue.yml", "w") { |f| f.write settings + "\n" +
|
620
|
+
File.open("config/hot_glue.yml", "w") { |f| f.write settings + "\n" + added_setting }
|
631
621
|
|
632
622
|
puts "adding `#{added_setting}` to config/hot_glue.yml"
|
633
|
-
elsif !
|
623
|
+
elsif !File.exist?(sample_file_path)
|
634
624
|
puts "NO SAMPLE FILE FOUND: adding sample file at #{sample_file_path}"
|
635
625
|
template "computer_code.jpg", File.join("#{filepath_prefix}spec/files/", "computer_code.jpg")
|
636
626
|
end
|
@@ -639,11 +629,11 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
639
629
|
end
|
640
630
|
|
641
631
|
def fields_filtered_for_email_lookups
|
642
|
-
@columns.reject{|c| @alt_lookups.keys.include?(c) } + @alt_lookups.values.map{|v| ("__lookup_#{v[:lookup_as]}").to_sym}
|
632
|
+
@columns.reject { |c| @alt_lookups.keys.include?(c) } + @alt_lookups.values.map { |v| ("__lookup_#{v[:lookup_as]}").to_sym }
|
643
633
|
end
|
644
634
|
|
645
635
|
def creation_syntax
|
646
|
-
merge_with = @alt_lookups.collect{ |key, data|
|
636
|
+
merge_with = @alt_lookups.collect { |key, data|
|
647
637
|
"#{data[:assoc].downcase}: #{data[:assoc].downcase}_factory.#{data[:assoc].downcase}"
|
648
638
|
}.join(", ")
|
649
639
|
|
@@ -668,7 +658,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
668
658
|
end
|
669
659
|
|
670
660
|
def filepath_prefix
|
671
|
-
'spec/dummy/' if
|
661
|
+
'spec/dummy/' if $INTERNAL_SPECS
|
672
662
|
end
|
673
663
|
|
674
664
|
def copy_controller_and_spec_files
|
@@ -687,14 +677,14 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
687
677
|
unless @no_specs
|
688
678
|
dest_file = File.join("#{filepath_prefix}spec/features#{namespace_with_dash}", "#{plural}_behavior_spec.rb")
|
689
679
|
|
690
|
-
if
|
680
|
+
if File.exist?(dest_file)
|
691
681
|
existing_file = File.open(dest_file)
|
692
682
|
existing_content = existing_file.read
|
693
683
|
if existing_content =~ /\#HOTGLUE-SAVESTART/
|
694
|
-
if
|
684
|
+
if existing_content !~ /\#HOTGLUE-END/
|
695
685
|
raise "Your file at #{dest_file} contains a #HOTGLUE-SAVESTART marker without #HOTGLUE-END"
|
696
686
|
end
|
697
|
-
@existing_content =
|
687
|
+
@existing_content = existing_content[(existing_content =~ /\#HOTGLUE-SAVESTART/)..(existing_content =~ /\#HOTGLUE-END/) - 1]
|
698
688
|
@existing_content << "#HOTGLUE-END"
|
699
689
|
|
700
690
|
end
|
@@ -703,7 +693,6 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
703
693
|
@existing_content = " #HOTGLUE-SAVESTART\n #HOTGLUE-END"
|
704
694
|
end
|
705
695
|
|
706
|
-
|
707
696
|
template "system_spec.rb.erb", dest_file
|
708
697
|
end
|
709
698
|
|
@@ -717,7 +706,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
717
706
|
end
|
718
707
|
|
719
708
|
def testing_name
|
720
|
-
singular_class.gsub("::","_").underscore
|
709
|
+
singular_class.gsub("::", "_").underscore
|
721
710
|
end
|
722
711
|
|
723
712
|
def spec_related_column_lets
|
@@ -736,7 +725,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
736
725
|
end
|
737
726
|
|
738
727
|
def columns_spec_with_sample_data
|
739
|
-
@columns_map.map
|
728
|
+
@columns_map.map { |col, col_object|
|
740
729
|
unless col_object.is_a?(AssociationField)
|
741
730
|
random_data = col_object.spec_random_data
|
742
731
|
col.to_s + ": '" + random_data.to_s + "'"
|
@@ -745,14 +734,14 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
745
734
|
end
|
746
735
|
|
747
736
|
def regenerate_me_code
|
748
|
-
"rails generate hot_glue:scaffold #{ @meta_args[0][0] } #{@meta_args[1].collect{|x| x.gsub(/\s*=\s*([\S\s]+)/, '=\'\1\'')}.join(" ")}"
|
737
|
+
"rails generate hot_glue:scaffold #{ @meta_args[0][0] } #{@meta_args[1].collect { |x| x.gsub(/\s*=\s*([\S\s]+)/, '=\'\1\'') }.join(" ")}"
|
749
738
|
end
|
750
739
|
|
751
740
|
def object_parent_mapping_as_argument_for_specs
|
752
741
|
|
753
742
|
if @self_auth
|
754
743
|
""
|
755
|
-
elsif @nested_set.any? &&
|
744
|
+
elsif @nested_set.any? && !@nested_set.last[:optional]
|
756
745
|
", " + @nested_set.last[:singular] + ": " + @nested_set.last[:singular]
|
757
746
|
elsif @auth && !@god
|
758
747
|
", #{@auth_identifier}: #{@auth}"
|
@@ -773,7 +762,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
773
762
|
end
|
774
763
|
|
775
764
|
def objest_nest_params_by_id_for_specs
|
776
|
-
@nested_set.map{|arg|
|
765
|
+
@nested_set.map { |arg|
|
777
766
|
"#{arg[:singular]}_id: #{arg[:singular]}.id"
|
778
767
|
}.join(",\n ")
|
779
768
|
end
|
@@ -791,8 +780,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
791
780
|
end
|
792
781
|
|
793
782
|
def capybara_make_updates(which_partial = :create)
|
794
|
-
@columns_map.map { |
|
795
|
-
show_only_list = which_partial == :create ? @show_only : (@update_show_only
|
783
|
+
@columns_map.map { |col, col_obj|
|
784
|
+
show_only_list = which_partial == :create ? @show_only : (@update_show_only + @show_only)
|
796
785
|
|
797
786
|
if show_only_list.include?(col)
|
798
787
|
" page.should have_no_selector(:css, \"[name='#{testing_name}[#{ col.to_s }]'\")"
|
@@ -804,7 +793,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
804
793
|
|
805
794
|
def path_helper_args
|
806
795
|
if @nested_set.any? && @nested
|
807
|
-
[(@nested_set).collect{|a| "#{a[:singular]}"}
|
796
|
+
[(@nested_set).collect { |a| "#{a[:singular]}" }, singular].join(",")
|
808
797
|
else
|
809
798
|
singular
|
810
799
|
end
|
@@ -812,9 +801,9 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
812
801
|
|
813
802
|
def path_helper_singular
|
814
803
|
if @nested
|
815
|
-
"#{@namespace+"_" if @namespace}#{(@nested_set.collect{|x| x[:singular]}.join("_") + "_" if @nested_set.any?)}#{@controller_build_folder_singular}_path"
|
804
|
+
"#{@namespace + "_" if @namespace}#{(@nested_set.collect { |x| x[:singular] }.join("_") + "_" if @nested_set.any?)}#{@controller_build_folder_singular}_path"
|
816
805
|
else
|
817
|
-
"#{@namespace+"_" if @namespace}#{@controller_build_folder_singular}_path"
|
806
|
+
"#{@namespace + "_" if @namespace}#{@controller_build_folder_singular}_path"
|
818
807
|
end
|
819
808
|
end
|
820
809
|
|
@@ -841,7 +830,6 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
841
830
|
top_level: true)
|
842
831
|
end
|
843
832
|
|
844
|
-
|
845
833
|
def delete_path_helper
|
846
834
|
HotGlue.optionalized_ternary(namespace: @namespace,
|
847
835
|
target: @singular,
|
@@ -868,15 +856,15 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
868
856
|
end
|
869
857
|
|
870
858
|
def line_path_partial
|
871
|
-
"#{@namespace+"/" if @namespace}#{@controller_build_folder}/line"
|
859
|
+
"#{@namespace + "/" if @namespace}#{@controller_build_folder}/line"
|
872
860
|
end
|
873
861
|
|
874
862
|
def show_path_partial
|
875
|
-
"#{@namespace+"/" if @namespace}#{@controller_build_folder}/show"
|
863
|
+
"#{@namespace + "/" if @namespace}#{@controller_build_folder}/show"
|
876
864
|
end
|
877
865
|
|
878
866
|
def list_path_partial
|
879
|
-
"#{@namespace+"/" if @namespace}#{@controller_build_folder}/list"
|
867
|
+
"#{@namespace + "/" if @namespace}#{@controller_build_folder}/list"
|
880
868
|
end
|
881
869
|
|
882
870
|
def new_path_name
|
@@ -889,11 +877,11 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
889
877
|
|
890
878
|
def nested_assignments
|
891
879
|
return "" if @nested_set.none?
|
892
|
-
@nested_set.map{|a| "#{a}: #{a}"}.join(", ") #metaprgramming into Ruby hash
|
880
|
+
@nested_set.map { |a| "#{a}: #{a}" }.join(", ") # metaprgramming into Ruby hash
|
893
881
|
end
|
894
882
|
|
895
883
|
def nested_assignments_top_level # this is by accessing the instance variable-- only use at top level
|
896
|
-
@nested_set.map{|a| "#{a[:singular]}"}.join(", ") #metaprgramming into Ruby hash
|
884
|
+
@nested_set.map { |a| "#{a[:singular]}" }.join(", ") # metaprgramming into Ruby hash
|
897
885
|
end
|
898
886
|
|
899
887
|
def nest_assignments_operator(top_level = false, leading_comma = false)
|
@@ -909,11 +897,11 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
909
897
|
end
|
910
898
|
|
911
899
|
def nested_objects_arity
|
912
|
-
@nested_set.map{|a| "@#{a[:singular]}"}.join(", ")
|
900
|
+
@nested_set.map { |a| "@#{a[:singular]}" }.join(", ")
|
913
901
|
end
|
914
902
|
|
915
903
|
def nested_arity_for_path
|
916
|
-
[@nested_set[0..-1].collect{|a| "@#{a[:singular]}"}].join(", ") #metaprgramming into arity for the Rails path helper
|
904
|
+
[@nested_set[0..-1].collect { |a| "@#{a[:singular]}" }].join(", ") # metaprgramming into arity for the Rails path helper
|
917
905
|
end
|
918
906
|
|
919
907
|
def object_scope
|
@@ -959,7 +947,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
959
947
|
end
|
960
948
|
|
961
949
|
def no_devise_installed
|
962
|
-
!Gem::Specification.sort_by{ |g| [g.name.downcase, g.version] }.group_by{ |g| g.name }['devise']
|
950
|
+
!Gem::Specification.sort_by { |g| [g.name.downcase, g.version] }.group_by { |g| g.name }['devise']
|
963
951
|
end
|
964
952
|
|
965
953
|
def magic_button_output
|
@@ -990,27 +978,24 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
990
978
|
source_filename = cc_filename_with_extensions("#{@markup}/#{view}", "#{@markup}")
|
991
979
|
dest_filename = cc_filename_with_extensions("#{view}", "#{@markup}")
|
992
980
|
|
993
|
-
|
994
981
|
dest_filepath = File.join("#{filepath_prefix}app/views#{namespace_with_dash}",
|
995
982
|
@controller_build_folder, dest_filename)
|
996
983
|
|
997
|
-
|
998
984
|
template source_filename, dest_filepath
|
999
|
-
gsub_file dest_filepath,
|
985
|
+
gsub_file dest_filepath, '\%', '%'
|
1000
986
|
|
1001
987
|
end
|
1002
988
|
end
|
1003
989
|
|
1004
990
|
turbo_stream_views.each do |view|
|
1005
991
|
formats.each do |format|
|
1006
|
-
source_filename = cc_filename_with_extensions(
|
992
|
+
source_filename = cc_filename_with_extensions("#{@markup}/#{view}.turbo_stream.#{@markup}")
|
1007
993
|
dest_filename = cc_filename_with_extensions("#{view}", "turbo_stream.#{@markup}")
|
1008
994
|
dest_filepath = File.join("#{filepath_prefix}app/views#{namespace_with_dash}",
|
1009
995
|
@controller_build_folder, dest_filename)
|
1010
996
|
|
1011
|
-
|
1012
997
|
template source_filename, dest_filepath
|
1013
|
-
gsub_file dest_filepath,
|
998
|
+
gsub_file dest_filepath, '\%', '%'
|
1014
999
|
|
1015
1000
|
end
|
1016
1001
|
end
|
@@ -1023,7 +1008,6 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1023
1008
|
dest_filename = cc_filename_with_extensions("#{singular_class.underscore}", "rb")
|
1024
1009
|
dest_filepath = File.join("#{filepath_prefix}app/models", dest_filename)
|
1025
1010
|
|
1026
|
-
|
1027
1011
|
puts "appending turbo callbacks to #{dest_filepath}"
|
1028
1012
|
|
1029
1013
|
text = File.read(dest_filepath)
|
@@ -1035,7 +1019,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1035
1019
|
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"
|
1036
1020
|
|
1037
1021
|
replace = text.gsub(/class #{singular_class} < ApplicationRecord/, append_text)
|
1038
|
-
File.open(dest_filepath, "w") {|file| file.puts replace}
|
1022
|
+
File.open(dest_filepath, "w") { |file| file.puts replace }
|
1039
1023
|
end
|
1040
1024
|
end
|
1041
1025
|
|
@@ -1052,7 +1036,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1052
1036
|
end
|
1053
1037
|
|
1054
1038
|
def all_views
|
1055
|
-
res =
|
1039
|
+
res = %w(index _line _list _show)
|
1056
1040
|
|
1057
1041
|
unless @no_create
|
1058
1042
|
res += %w(new _new_form _new_button)
|
@@ -1062,7 +1046,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1062
1046
|
res += %w{edit _edit}
|
1063
1047
|
end
|
1064
1048
|
|
1065
|
-
if !(
|
1049
|
+
if !(@no_edit && @no_create)
|
1066
1050
|
res << '_form'
|
1067
1051
|
end
|
1068
1052
|
res
|
@@ -1114,7 +1098,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1114
1098
|
def all_line_fields
|
1115
1099
|
@template_builder.all_line_fields(
|
1116
1100
|
col_identifier: @layout_strategy.column_classes_for_line_fields,
|
1117
|
-
perc_width: @layout_strategy.each_col,
|
1101
|
+
perc_width: @layout_strategy.each_col, # undefined method `each_col'
|
1118
1102
|
layout_strategy: @layout_strategy,
|
1119
1103
|
layout_object: @layout_object
|
1120
1104
|
)
|
@@ -1173,7 +1157,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1173
1157
|
end
|
1174
1158
|
|
1175
1159
|
def controller_magic_button_update_actions
|
1176
|
-
@magic_buttons.collect{ |magic_button|
|
1160
|
+
@magic_buttons.collect { |magic_button|
|
1177
1161
|
" if #{singular}_params[:#{magic_button}]
|
1178
1162
|
begin
|
1179
1163
|
res = @#{singular}.#{magic_button}!
|
@@ -1188,15 +1172,14 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1188
1172
|
}.join("\n") + "\n"
|
1189
1173
|
end
|
1190
1174
|
|
1191
|
-
|
1192
1175
|
def controller_update_params_tap_away_magic_buttons
|
1193
|
-
@magic_buttons.collect{ |magic_button|
|
1176
|
+
@magic_buttons.collect { |magic_button|
|
1194
1177
|
".tap{ |ary| ary.delete('__#{magic_button}') }"
|
1195
1178
|
}.join("")
|
1196
1179
|
end
|
1197
1180
|
|
1198
1181
|
def controller_update_params_tap_away_alt_lookups
|
1199
|
-
@alt_lookups.collect{ |key, data|
|
1182
|
+
@alt_lookups.collect { |key, data|
|
1200
1183
|
".tap{ |ary| ary.delete('__lookup_#{data[:lookup_as]}') }"
|
1201
1184
|
}.join("")
|
1202
1185
|
end
|
@@ -1211,7 +1194,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1211
1194
|
|
1212
1195
|
def n_plus_one_includes
|
1213
1196
|
if @associations.any? || @attachments.any?
|
1214
|
-
".includes(" + (@associations.map{|x| x} + @attachments.collect{|k,v| "#{k}_attachment"}).map{|x| ":#{x.to_s}"}.join(", ") + ")"
|
1197
|
+
".includes(" + (@associations.map { |x| x } + @attachments.collect { |k, v| "#{k}_attachment" }).map { |x| ":#{x.to_s}" }.join(", ") + ")"
|
1215
1198
|
else
|
1216
1199
|
""
|
1217
1200
|
end
|
@@ -1223,7 +1206,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1223
1206
|
if @nested_set.none?
|
1224
1207
|
"\"\""
|
1225
1208
|
else
|
1226
|
-
@nested_set.collect{|arg|
|
1209
|
+
@nested_set.collect { |arg|
|
1227
1210
|
"(((\"__#{arg[:singular]}-\#{" + "@" + arg[:singular] + ".id}\") if @" + arg[:singular] + ") || \"\")"
|
1228
1211
|
}.join(" + ")
|
1229
1212
|
end
|
@@ -1235,7 +1218,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1235
1218
|
if @nested_set.none?
|
1236
1219
|
""
|
1237
1220
|
else
|
1238
|
-
", \n nested_for: \"" + @nested_set.collect{|a| "#{a[:singular]}-" + '#{' + instance_symbol + a[:singular] + ".id}"}.join("__") + "\""
|
1221
|
+
", \n nested_for: \"" + @nested_set.collect { |a| "#{a[:singular]}-" + '#{' + instance_symbol + a[:singular] + ".id}" }.join("__") + "\""
|
1239
1222
|
end
|
1240
1223
|
end
|
1241
1224
|
|
@@ -1246,32 +1229,31 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
|
1246
1229
|
end
|
1247
1230
|
|
1248
1231
|
def hawk_to_ruby
|
1249
|
-
res = @hawk_keys.collect{ |k,v|
|
1232
|
+
res = @hawk_keys.collect { |k, v|
|
1250
1233
|
"#{k.to_s}: [#{v[:bind_to].join(".")}]"
|
1251
1234
|
}.join(", ")
|
1252
1235
|
res
|
1253
1236
|
end
|
1254
1237
|
|
1255
1238
|
def controller_attachment_orig_filename_pickup_syntax
|
1256
|
-
@attachments.collect{ |key, attachment|
|
1239
|
+
@attachments.collect { |key, attachment| "\n" + " modified_params[:#{ attachment[:field_for_original_filename] }] = #{singular}_params['#{ key }'].original_filename" if attachment[:field_for_original_filename] }.compact.join("\n")
|
1257
1240
|
end
|
1258
1241
|
|
1259
1242
|
def any_datetime_fields?
|
1260
|
-
(@columns - @attachments.keys.collect(&:to_sym)).collect{|col| eval("#{singular_class}.columns_hash['#{col}']").type}.include?(:datetime)
|
1243
|
+
(@columns - @attachments.keys.collect(&:to_sym)).collect { |col| eval("#{singular_class}.columns_hash['#{col}']").type }.include?(:datetime)
|
1261
1244
|
end
|
1262
1245
|
|
1263
1246
|
def post_action_parental_updates
|
1264
1247
|
if @nested_set.any?
|
1265
|
-
"\n" + @nested_set.collect{ |data|
|
1248
|
+
"\n" + @nested_set.collect { |data|
|
1266
1249
|
parent = data[:singular]
|
1267
1250
|
"@#{singular}.#{parent}.reload"
|
1268
1251
|
}.join("\n")
|
1269
1252
|
end
|
1270
1253
|
end
|
1271
1254
|
|
1272
|
-
|
1273
1255
|
def turbo_parental_updates
|
1274
|
-
@nested_set.collect{|
|
1256
|
+
@nested_set.collect { |data|
|
1275
1257
|
"<%= turbo_stream.replace \"#{@namespace + '__' if @namespace}\#{dom_id(@#{data[:singular]})}\" do %>
|
1276
1258
|
<%= render partial: \"#{@namespace}/#{data[:plural]}/edit\", locals: {#{data[:singular]}: @#{singular}.#{data[:singular]}.reload} %>
|
1277
1259
|
<% end %>"
|