hot-glue 0.2.9E → 0.3.5
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 +60 -1
- data/lib/generators/hot_glue/markup_templates/erb.rb +31 -21
- data/lib/generators/hot_glue/markup_templates/haml.rb +3 -1
- data/lib/generators/hot_glue/scaffold_generator.rb +147 -32
- data/lib/generators/hot_glue/templates/controller.rb.erb +31 -18
- 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 +22 -14
- data/lib/generators/hot_glue/templates/erb/_show.erb +13 -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
@@ -61,7 +61,8 @@ module HotGlue
|
|
61
61
|
# elsif self.class.ancestors.include?(ApplicationController)
|
62
62
|
# self.try(:current_timezone)
|
63
63
|
else
|
64
|
-
|
64
|
+
puts "no method current_user is available; please implement/override the method current_timezone IN YOUR CONTROLLER"
|
65
|
+
exit
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
@@ -5,12 +5,41 @@ module HotGlue
|
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
6
6
|
hook_for :form_builder, :as => :scaffold
|
7
7
|
class_option :markup, type: :string, default: "erb"
|
8
|
+
class_option :theme, type: :string, default: nil
|
9
|
+
class_option :layout, type: :string, default: "hotglue"
|
8
10
|
|
9
11
|
source_root File.expand_path('templates', __dir__)
|
10
12
|
|
11
|
-
|
12
13
|
def initialize(*args) #:nodoc:
|
13
14
|
super
|
15
|
+
@layout = options['layout'] || "hotglue"
|
16
|
+
@theme = options['theme']
|
17
|
+
|
18
|
+
if @layout == "hotglue" && options['theme'].nil?
|
19
|
+
puts "You have selected to install Hot Glue without a theme. You can either use the --layout=bootstrap to install NO HOT GLUE THEME, or to use a Hot Glue theme please choose: like_boostrap, like_menlo_park, like_cupertino, like_mountain_view, dark_knight"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
if @layout == 'boostrap'
|
24
|
+
puts "IMPORTANT: You have selected to install Hot Glue with Bootstrap layout (legacy). Be sure to always use ``--layout=bootstrap` when building your scaffold. No Hot Glue theme will be installed at this time.` "
|
25
|
+
end
|
26
|
+
|
27
|
+
### INTERACTIVE LICENSING
|
28
|
+
#
|
29
|
+
|
30
|
+
|
31
|
+
print "(To purchase a license, please see https://heliosdev.shop/hot-glue-license) \n Please enter your license key: "
|
32
|
+
license_activation_key = STDIN.gets
|
33
|
+
|
34
|
+
print "Please enter the EMAIL you used to purchase this license: "
|
35
|
+
license_email = STDIN.gets
|
36
|
+
app_name = Rails.application.class.module_parent_name
|
37
|
+
license_should_be = Digest::SHA1.hexdigest("HotGlueLicense--#{app_name}--#{license_email}")
|
38
|
+
if (license_should_be != license_activation_key)
|
39
|
+
puts "Ooops... it seems that Hot Glue license is not valid. Please check 1) the email address you used for this license, 2) The app name you used to purchase this license, and 3) the activation key itself."
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
|
14
43
|
@markup = options['markup']
|
15
44
|
if @markup == "haml"
|
16
45
|
copy_file "haml/_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
|
@@ -70,6 +99,36 @@ module HotGlue
|
|
70
99
|
end
|
71
100
|
|
72
101
|
|
102
|
+
if @layout == "hotglue"
|
103
|
+
theme_location = "themes/hotglue_scaffold_#{@theme}.scss"
|
104
|
+
theme_file = "hotglue_scaffold_#{@theme}.scss"
|
105
|
+
|
106
|
+
copy_file theme_location, "#{'spec/dummy/' if Rails.env.test?}app/assets/stylesheets/#{theme_file}"
|
107
|
+
|
108
|
+
application_scss = File.read("app/assets/stylesheets/application.scss")
|
109
|
+
|
110
|
+
if !application_scss.include?("@import '#{theme_file}';")
|
111
|
+
application_scss << ( "\n @import '#{theme_file}'; ")
|
112
|
+
File.write("app/assets/stylesheets/application.scss", application_scss)
|
113
|
+
puts " HOTGLUE --> added to app/assets/stylesheets/application.scss: @import '#{theme_file}' "
|
114
|
+
else
|
115
|
+
puts " HOTGLUE --> already found theme in app/assets/stylesheets/application.scss: @import '#{theme_file}' "
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
if !File.exists?("config/hot_glue.yml")
|
122
|
+
|
123
|
+
yaml = {layout: @layout,
|
124
|
+
markup: @markup,
|
125
|
+
license_activation_key: license_activation_key,
|
126
|
+
license_email: license_email}.to_yaml
|
127
|
+
File.write("#{'spec/dummy/' if Rails.env.test?}config/hot_glue.yml", yaml)
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
|
73
132
|
if !File.exists?("spec/support/capybara_login.rb")
|
74
133
|
copy_file "capybara_login.rb", "#{'spec/dummy/' if Rails.env.test?}spec/support/capybara_login.rb"
|
75
134
|
end
|
@@ -5,8 +5,8 @@ module HotGlue
|
|
5
5
|
attr_accessor :singular
|
6
6
|
|
7
7
|
def field_output(col, type = nil, width, col_identifier )
|
8
|
-
"<div class='
|
9
|
-
" <%= f.text_field :#{col.to_s}, value: @#{@singular}.#{col.to_s}, size: #{width}, class: 'form-control', type: '#{type}' %>\n "+
|
8
|
+
"<div class='#{col_identifier} form-group <%='alert-danger' if @#{singular}.errors.details.keys.include?(:#{col.to_s})%>' > \n" +
|
9
|
+
" <%= f.text_field :#{col.to_s}, value: @#{@singular}.#{col.to_s}, autocomplete: 'off', size: #{width}, class: 'form-control', type: '#{type}' %>\n "+
|
10
10
|
" <label class='form-text' >#{col.to_s.humanize}</label>\n" +
|
11
11
|
"</div>"
|
12
12
|
end
|
@@ -33,7 +33,7 @@ module HotGlue
|
|
33
33
|
end
|
34
34
|
|
35
35
|
"<div class=\"#{col_identifier} form-group \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\">" +
|
36
|
-
"<%= f.text_area :#{col.to_s}, class: 'form-control', cols: 40, rows: '#{lines}' %>" +
|
36
|
+
"<%= f.text_area :#{col.to_s}, class: 'form-control', autocomplete: 'off', cols: 40, rows: '#{lines}' %>" +
|
37
37
|
"<label class='form-text'>#{col.to_s.humanize}</label>"+
|
38
38
|
"</div>"
|
39
39
|
|
@@ -41,8 +41,10 @@ module HotGlue
|
|
41
41
|
|
42
42
|
def list_column_headings(*args)
|
43
43
|
columns = args[0][:columns]
|
44
|
+
column_width = args[0][:column_width]
|
45
|
+
col_identifier = args[0][:col_identifier]
|
44
46
|
|
45
|
-
columns.map(&:to_s).map{|col_name| "<div class='
|
47
|
+
columns.map(&:to_s).map{|col_name| "<div class='#{col_identifier}' style='flex-basis: #{column_width}%'>#{col_name.humanize}</div>"}.join("\n")
|
46
48
|
end
|
47
49
|
|
48
50
|
|
@@ -50,13 +52,15 @@ module HotGlue
|
|
50
52
|
columns = args[0][:columns]
|
51
53
|
show_only = args[0][:show_only]
|
52
54
|
singular_class = args[0][:singular_class]
|
55
|
+
col_identifier = args[0][:col_identifier]
|
56
|
+
|
53
57
|
|
54
58
|
# TODO: CLEAN ME
|
55
59
|
@singular = args[0][:singular]
|
56
60
|
singular = @singular
|
57
61
|
|
58
62
|
|
59
|
-
|
63
|
+
|
60
64
|
col_spaces_prepend = " "
|
61
65
|
|
62
66
|
res = columns.map { |col|
|
@@ -111,10 +115,7 @@ module HotGlue
|
|
111
115
|
text_area_output(col, 65536, col_identifier)
|
112
116
|
end
|
113
117
|
when :float
|
114
|
-
|
115
|
-
field_output(col, nil, limit, col_identifier)
|
116
|
-
|
117
|
-
|
118
|
+
field_output(col, nil, 5, col_identifier)
|
118
119
|
when :datetime
|
119
120
|
|
120
121
|
|
@@ -166,11 +167,18 @@ module HotGlue
|
|
166
167
|
show_only = args[0][:show_only]
|
167
168
|
singular_class = args[0][:singular_class]
|
168
169
|
singular = args[0][:singular]
|
170
|
+
perc_width = args[0][:perc_width]
|
169
171
|
|
170
172
|
columns_count = columns.count + 1
|
171
|
-
perc_width = (
|
173
|
+
perc_width = (perc_width).floor
|
172
174
|
|
173
|
-
|
175
|
+
if @layout == "boostrap"
|
176
|
+
col_identifer = "col"
|
177
|
+
|
178
|
+
else
|
179
|
+
col_identifer = "scaffold-cell"
|
180
|
+
|
181
|
+
end
|
174
182
|
columns.map { |col|
|
175
183
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
176
184
|
limit = eval("#{singular_class}.columns_hash['#{col}']").limit
|
@@ -188,35 +196,37 @@ module HotGlue
|
|
188
196
|
|
189
197
|
if assoc.nil?
|
190
198
|
exit_message = "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
191
|
-
|
199
|
+
puts exit_message
|
200
|
+
exit
|
201
|
+
# raise(HotGlue::Error,exit_message)
|
192
202
|
end
|
193
203
|
|
194
204
|
display_column = HotGlue.derrive_reference_name(assoc.class_name)
|
195
205
|
|
196
|
-
"<div class='#{col_identifer}'>
|
206
|
+
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
|
197
207
|
<%= #{singular}.#{assoc.name.to_s}.try(:#{display_column}) || '<span class=\"content alert-danger\">MISSING</span>'.html_safe %>
|
198
208
|
</div>"
|
199
209
|
|
200
210
|
else
|
201
|
-
"<div class='#{col_identifer}'>
|
211
|
+
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
|
202
212
|
<%= #{singular}.#{col}%></div>"
|
203
213
|
end
|
204
214
|
when :float
|
205
215
|
width = (limit && limit < 40) ? limit : (40)
|
206
|
-
"<div class='#{col_identifer}'>
|
216
|
+
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
|
207
217
|
<%= #{singular}.#{col}%></div>"
|
208
218
|
when :string
|
209
219
|
width = (limit && limit < 40) ? limit : (40)
|
210
|
-
"<div class='#{col_identifer}'>
|
220
|
+
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
|
211
221
|
<%= #{singular}.#{col} %>
|
212
222
|
</div>"
|
213
223
|
when :text
|
214
|
-
"<div class='#{col_identifer}'>
|
224
|
+
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
|
215
225
|
<%= #{singular}.#{col} %>
|
216
226
|
</div>"
|
217
227
|
when :datetime
|
218
228
|
|
219
|
-
"<div class='#{col_identifer}'>
|
229
|
+
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
|
220
230
|
<% unless #{singular}.#{col}.nil? %>
|
221
231
|
<%= #{singular}.#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ') + timezonize(current_timezone) %>
|
222
232
|
<% else %>
|
@@ -224,7 +234,7 @@ module HotGlue
|
|
224
234
|
<% end %>
|
225
235
|
</div>"
|
226
236
|
when :date
|
227
|
-
"<div class='#{col_identifer}'>
|
237
|
+
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
|
228
238
|
<% unless #{singular}.#{col}.nil? %>
|
229
239
|
<%= #{singular}.#{col} %>
|
230
240
|
<% else %>
|
@@ -232,7 +242,7 @@ module HotGlue
|
|
232
242
|
<% end %>
|
233
243
|
</div>"
|
234
244
|
when :time
|
235
|
-
"<div class='#{col_identifer}'>
|
245
|
+
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
|
236
246
|
<% unless #{singular}.#{col}.nil? %>
|
237
247
|
<%= #{singular}.#{col}.in_time_zone(current_timezone).strftime('%l:%M %p ') + timezonize(current_timezone) %>
|
238
248
|
<% else %>
|
@@ -241,7 +251,7 @@ module HotGlue
|
|
241
251
|
</div>
|
242
252
|
"
|
243
253
|
when :boolean
|
244
|
-
"<div class='#{col_identifer}'>
|
254
|
+
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
|
245
255
|
<% if #{singular}.#{col}.nil? %>
|
246
256
|
<span class='alert-danger'>MISSING</span>
|
247
257
|
<% elsif #{singular}.#{col} %>
|
@@ -159,7 +159,9 @@ module HotGlue
|
|
159
159
|
|
160
160
|
if assoc.nil?
|
161
161
|
exit_message = "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
162
|
-
|
162
|
+
puts exit_message
|
163
|
+
exit
|
164
|
+
# raise(HotGlue::Error,exit_message)
|
163
165
|
end
|
164
166
|
|
165
167
|
display_column = HotGlue.derrive_reference_name(assoc.class_name)
|
@@ -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,16 +684,43 @@ 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,
|
@@ -720,6 +805,36 @@ module HotGlue
|
|
720
805
|
}.join("")
|
721
806
|
end
|
722
807
|
|
808
|
+
|
809
|
+
def nested_for_turbo_id_list_constructor
|
810
|
+
if @nested_args.none?
|
811
|
+
""
|
812
|
+
else
|
813
|
+
"+ ('__' + nested_for)"
|
814
|
+
end
|
815
|
+
end
|
816
|
+
|
817
|
+
def nested_for_turbo_nested_constructor(top_level = true)
|
818
|
+
instance_symbol = "@" if top_level
|
819
|
+
instance_symbol = "" if !top_level
|
820
|
+
if @nested_args.none?
|
821
|
+
""
|
822
|
+
else
|
823
|
+
"__" + @nested_args.collect{|a| "#{a}-" + '#{' + instance_symbol + a + '.id}'}.join("__")
|
824
|
+
end
|
825
|
+
end
|
826
|
+
|
827
|
+
def nested_for_assignments_constructor(top_level = true)
|
828
|
+
instance_symbol = "@" if top_level
|
829
|
+
instance_symbol = "" if !top_level
|
830
|
+
if @nested_args.none?
|
831
|
+
""
|
832
|
+
else
|
833
|
+
", \n nested_for: \"" + @nested_args.collect{|a| "#{a}-" + '#{' + instance_symbol + a + ".id}"}.join("__") + "\""
|
834
|
+
end
|
835
|
+
end
|
836
|
+
|
837
|
+
|
723
838
|
private # thor does something fancy like sending the class all of its own methods during some strange run sequence
|
724
839
|
# does not like public methods
|
725
840
|
def cc_filename_with_extensions(name, file_format = format)
|