hot-glue 0.4.9.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +14 -0
- data/app/helpers/hot_glue/controller_helper.rb +5 -23
- data/lib/generators/hot_glue/install_generator.rb +0 -5
- data/lib/generators/hot_glue/markup_templates/erb.rb +124 -84
- data/lib/generators/hot_glue/scaffold_generator.rb +27 -7
- data/lib/hotglue/version.rb +1 -1
- metadata +3 -4
- data/lib/generators/hot_glue/templates/confirmable.js +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ce580959416e9968343b55064541fe777cef3c213f6124add34aba96f13a194b
|
|
4
|
+
data.tar.gz: 902147016f8d3ef1b20a1ce713b84d68b9ff2b5700d2643369d1037d0658bbc2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4625645ea4bd58ee8614965ff26083ef86ca6d07398408bcf01cb72e3aceda62d60480a86fbe4a999e12f726bc74c427f35a3d889cba9e6d0ef7e54c42f1f79
|
|
7
|
+
data.tar.gz: 7dd4e7fc8d7a605c54818c60bfdaa38148727f65a13e8e1135002bcc23c6f63649be909787b76b207fd81b3f6a139e0598a526b59c872dc71e512f2983432fe4
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -472,6 +472,13 @@ Please note that this example would produce non-functional code, so you would ne
|
|
|
472
472
|
You don't need this if the pluralized version is just + "s" of the singular version. Only use for non-standard plurlizations, and be sure to pass it as TitleCase (as if you pluralized the model name which is non-standard for Rails)
|
|
473
473
|
|
|
474
474
|
|
|
475
|
+
### `--form-labels-position` (default: `after`; options are **before**, **after**, and **omit**)
|
|
476
|
+
By default form labels appear after the form inputs. To make them appear before or omit them, use this flag.
|
|
477
|
+
|
|
478
|
+
See also `--form-placeholder-labels` to use placeolder labels.
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
475
482
|
### `--exclude=`
|
|
476
483
|
(separate field names by COMMA)
|
|
477
484
|
|
|
@@ -680,6 +687,13 @@ Omits list LABEL itself above the list. (Do not confuse with the field labels.)
|
|
|
680
687
|
|
|
681
688
|
Note that list labels may be automatically omitted on downnested scaffolds.
|
|
682
689
|
|
|
690
|
+
### `--form-placeholder-labels` (default: false)
|
|
691
|
+
|
|
692
|
+
When set to true, fields, numbers, and text areas will have placeholder labels.
|
|
693
|
+
Will not apply to dates, times, datetimes, dropdowns (enums + foreign keys), or booleans.
|
|
694
|
+
|
|
695
|
+
See also setting `--form-labels-position` to control position or omit normal labels.
|
|
696
|
+
|
|
683
697
|
### `--no-list-heading`
|
|
684
698
|
|
|
685
699
|
Omits the heading of column names that appears above the 1st row of data.
|
|
@@ -8,43 +8,25 @@ module HotGlue
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def datetime_field_localized(form_object, field_name, value, label, timezone = nil )
|
|
11
|
-
|
|
12
|
-
field_name,
|
|
13
|
-
class: 'small form-text text-muted')
|
|
14
|
-
|
|
15
|
-
res << form_object.text_field(field_name, class: 'form-control',
|
|
11
|
+
form_object.text_field(field_name, class: 'form-control',
|
|
16
12
|
type: 'datetime-local',
|
|
17
13
|
value: date_to_current_timezone(value, timezone))
|
|
18
|
-
|
|
19
|
-
res << timezonize(timezone)
|
|
20
|
-
res
|
|
14
|
+
+ timezonize(timezone)
|
|
21
15
|
end
|
|
22
16
|
|
|
23
17
|
|
|
24
18
|
def date_field_localized(form_object, field_name, value, label, timezone = nil )
|
|
25
|
-
|
|
26
|
-
res = form_object.label(label,
|
|
27
|
-
field_name,
|
|
28
|
-
class: 'small form-text text-muted')
|
|
29
|
-
|
|
30
|
-
res << form_object.text_field(field_name, class: 'form-control',
|
|
19
|
+
form_object.text_field(field_name, class: 'form-control',
|
|
31
20
|
type: 'date',
|
|
32
21
|
value: value )
|
|
33
|
-
|
|
34
|
-
res
|
|
35
22
|
end
|
|
36
23
|
|
|
37
24
|
def time_field_localized(form_object, field_name, value, label, timezone = nil )
|
|
38
|
-
|
|
39
|
-
field_name,
|
|
40
|
-
class: 'small form-text text-muted')
|
|
41
|
-
|
|
42
|
-
res << form_object.text_field(field_name, class: 'form-control',
|
|
25
|
+
form_object.text_field(field_name, class: 'form-control',
|
|
43
26
|
type: 'time',
|
|
44
27
|
value: date_to_current_timezone(value, timezone))
|
|
28
|
+
+ timezonize(timezone)
|
|
45
29
|
|
|
46
|
-
res << timezonize(timezone)
|
|
47
|
-
res
|
|
48
30
|
end
|
|
49
31
|
|
|
50
32
|
def current_timezone
|
|
@@ -87,11 +87,6 @@ module HotGlue
|
|
|
87
87
|
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
if Rails.version.split(".")[0].to_i >= 7
|
|
91
|
-
copy_file "confirmable.js", "#{'spec/dummy/' if Rails.env.test?}app/javascript/controllers/confirmable.js"
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
|
|
95
90
|
begin
|
|
96
91
|
if Rails.version.split(".")[0].to_i == 6
|
|
97
92
|
app_js_contents = File.read("app/javascript/packs/application.js")
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
module HotGlue
|
|
2
2
|
class ErbTemplate < TemplateBase
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
attr_accessor :path, :singular, :singular_class,
|
|
5
|
+
:magic_buttons, :small_buttons,
|
|
6
|
+
:show_only, :column_width, :layout, :perc_width,
|
|
7
|
+
:ownership_field, :form_labels_position,
|
|
8
|
+
:inline_list_labels,
|
|
9
|
+
:columns, :column_width, :col_identifier, :singular,
|
|
10
|
+
:form_placeholder_labels
|
|
5
11
|
|
|
6
12
|
def add_spaces_each_line(text, num_spaces)
|
|
7
13
|
add_spaces = " " * num_spaces
|
|
8
14
|
text.lines.collect{|line| add_spaces + line}.join("")
|
|
9
15
|
end
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
# include GeneratorHelper
|
|
13
|
-
attr_accessor :singular
|
|
14
|
-
|
|
15
|
-
def field_output(col, type = nil, width, col_identifier )
|
|
16
|
-
" <%= f.text_field :#{col}, value: @#{@singular}.#{col}, autocomplete: 'off', size: #{width}, class: 'form-control', type: '#{type}' %>\n "+
|
|
17
|
-
"\n"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
|
|
21
17
|
def magic_button_output(*args)
|
|
22
18
|
path = args[0][:path]
|
|
23
19
|
# path_helper_singular = args[0][:path_helper_singular]
|
|
@@ -34,20 +30,13 @@ module HotGlue
|
|
|
34
30
|
}.join("\n")
|
|
35
31
|
end
|
|
36
32
|
|
|
37
|
-
def text_area_output(col, field_length, col_identifier )
|
|
38
|
-
lines = field_length % 40
|
|
39
|
-
if lines > 5
|
|
40
|
-
lines = 5
|
|
41
|
-
end
|
|
42
33
|
|
|
43
|
-
"<%= f.text_area :#{col}, class: 'form-control', autocomplete: 'off', cols: 40, rows: '#{lines}' %>"
|
|
44
|
-
end
|
|
45
34
|
|
|
46
35
|
def list_column_headings(*args)
|
|
47
|
-
|
|
48
|
-
column_width = args[0][:column_width]
|
|
49
|
-
col_identifier = args[0][:col_identifier]
|
|
50
|
-
layout = args[0][:layout]
|
|
36
|
+
@columns = args[0][:columns]
|
|
37
|
+
@column_width = args[0][:column_width]
|
|
38
|
+
@col_identifier = args[0][:col_identifier]
|
|
39
|
+
@layout = args[0][:layout]
|
|
51
40
|
|
|
52
41
|
if layout == "hotglue"
|
|
53
42
|
col_style = " style='flex-basis: #{column_width}%'"
|
|
@@ -55,23 +44,29 @@ module HotGlue
|
|
|
55
44
|
col_style = ""
|
|
56
45
|
end
|
|
57
46
|
|
|
58
|
-
result =
|
|
47
|
+
result = columns.map{ |column|
|
|
59
48
|
"<div class='#{col_identifier}'" + col_style + ">" + column.map(&:to_s).map{|col_name| "#{col_name.humanize}"}.join("<br />") + "</div>"
|
|
60
49
|
}.join("\n")
|
|
61
50
|
return result
|
|
62
51
|
end
|
|
63
52
|
|
|
64
53
|
|
|
54
|
+
################################################################
|
|
55
|
+
|
|
56
|
+
# THE FORM
|
|
57
|
+
|
|
65
58
|
def all_form_fields(*args)
|
|
66
|
-
|
|
67
|
-
show_only = args[0][:show_only]
|
|
68
|
-
singular_class = args[0][:singular_class]
|
|
69
|
-
col_identifier = args[0][:col_identifier]
|
|
70
|
-
ownership_field = args[0][:ownership_field]
|
|
59
|
+
@columns = args[0][:columns]
|
|
60
|
+
@show_only = args[0][:show_only]
|
|
61
|
+
@singular_class = args[0][:singular_class]
|
|
62
|
+
@col_identifier = args[0][:col_identifier]
|
|
63
|
+
@ownership_field = args[0][:ownership_field]
|
|
64
|
+
@form_labels_position = args[0][:form_labels_position]
|
|
65
|
+
@form_placeholder_labels = args[0][:form_placeholder_labels]
|
|
71
66
|
|
|
72
67
|
@singular = args[0][:singular]
|
|
73
68
|
singular = @singular
|
|
74
|
-
result =
|
|
69
|
+
result = columns.map{ |column|
|
|
75
70
|
" <div class='#{col_identifier}' >" +
|
|
76
71
|
column.map { |col|
|
|
77
72
|
field_result =
|
|
@@ -84,41 +79,11 @@ module HotGlue
|
|
|
84
79
|
|
|
85
80
|
case type
|
|
86
81
|
when :integer
|
|
87
|
-
|
|
88
|
-
if col.to_s.ends_with?("_id")
|
|
89
|
-
assoc_name = col.to_s.gsub("_id","")
|
|
90
|
-
assoc = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
|
|
91
|
-
if assoc.nil?
|
|
92
|
-
exit_message = "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
|
93
|
-
exit
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
is_owner = col == ownership_field
|
|
97
|
-
assoc_class_name = assoc.active_record.name
|
|
98
|
-
display_column = HotGlue.derrive_reference_name(assoc_class_name)
|
|
99
|
-
|
|
100
|
-
(is_owner ? "<% unless @#{assoc_name} %>\n" : "") +
|
|
101
|
-
" <%= f.collection_select(:#{col}, #{assoc.class_name}.all, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{col} }, class: 'form-control') %>\n" +
|
|
102
|
-
(is_owner ? "<% else %>\n <%= @#{assoc_name}.#{display_column} %>" : "") +
|
|
103
|
-
(is_owner ? "\n<% end %>" : "")
|
|
104
|
-
|
|
105
|
-
else
|
|
106
|
-
"<%= f.text_field :#{col}, value: #{singular}.#{col}, class: 'form-control', size: 4, type: 'number' %>"
|
|
107
|
-
|
|
108
|
-
end
|
|
82
|
+
integer_result(col)
|
|
109
83
|
when :string
|
|
110
|
-
|
|
111
|
-
field_output(col, nil, limit || 40, col_identifier)
|
|
112
|
-
else
|
|
113
|
-
text_area_output(col, 65536, col_identifier)
|
|
114
|
-
end
|
|
115
|
-
|
|
84
|
+
string_result(col, sql_type, limit)
|
|
116
85
|
when :text
|
|
117
|
-
|
|
118
|
-
field_output(col, nil, limit, col_identifier)
|
|
119
|
-
else
|
|
120
|
-
text_area_output(col, 65536, col_identifier)
|
|
121
|
-
end
|
|
86
|
+
text_result(col, sql_type, limit)
|
|
122
87
|
when :float
|
|
123
88
|
field_output(col, nil, 5, col_identifier)
|
|
124
89
|
when :datetime
|
|
@@ -128,18 +93,10 @@ module HotGlue
|
|
|
128
93
|
when :time
|
|
129
94
|
"<%= time_field_localized(f, :#{col}, #{singular}.#{col}, '#{ col.to_s.humanize }', #{@auth ? @auth+'.timezone' : 'nil'}) %>"
|
|
130
95
|
when :boolean
|
|
131
|
-
|
|
132
|
-
" <span>#{col.to_s.humanize}</span>" +
|
|
133
|
-
" <%= f.radio_button(:#{col}, '0', checked: #{singular}.#{col} ? '' : 'checked') %>\n" +
|
|
134
|
-
" <%= f.label(:#{col}, value: 'No', for: '#{singular}_#{col}_0') %>\n" +
|
|
135
|
-
" <%= f.radio_button(:#{col}, '1', checked: #{singular}.#{col} ? 'checked' : '') %>\n" +
|
|
136
|
-
" <%= f.label(:#{col}, value: 'Yes', for: '#{singular}_#{col}_1') %>\n" +
|
|
137
|
-
""
|
|
96
|
+
boolean_result(col)
|
|
138
97
|
when :enum
|
|
139
|
-
|
|
140
|
-
"<%= f.collection_select(:#{col}, enum_to_collection_select( #{singular_class}.defined_enums['#{enum_type}']), :key, :value, {selected: @#{singular}.#{col} }, class: 'form-control') %>"
|
|
98
|
+
enum_result(col)
|
|
141
99
|
end
|
|
142
|
-
|
|
143
100
|
end
|
|
144
101
|
|
|
145
102
|
if (type == :integer) && col.to_s.ends_with?("_id")
|
|
@@ -148,16 +105,93 @@ module HotGlue
|
|
|
148
105
|
field_error_name = col
|
|
149
106
|
end
|
|
150
107
|
|
|
151
|
-
|
|
152
|
-
|
|
108
|
+
the_label = "\n<label class='small form-text text-muted'>#{col.to_s.humanize}</label>"
|
|
109
|
+
add_spaces_each_line( "\n <span class='<%= \"alert-danger\" if #{singular}.errors.details.keys.include?(:#{field_error_name}) %>' #{'style="display: inherit;"'} >\n" +
|
|
110
|
+
add_spaces_each_line( (@form_labels_position == 'before' ? the_label : "") +
|
|
111
|
+
field_result + (@form_labels_position == 'after' ? the_label : "") , 4) +
|
|
153
112
|
"\n </span>\n <br />", 2)
|
|
154
113
|
|
|
114
|
+
|
|
155
115
|
}.join("") + "\n </div>"
|
|
156
116
|
}.join("\n")
|
|
157
117
|
return result
|
|
158
118
|
end
|
|
159
119
|
|
|
160
120
|
|
|
121
|
+
def integer_result(col)
|
|
122
|
+
# look for a belongs_to on this object
|
|
123
|
+
if col.to_s.ends_with?("_id")
|
|
124
|
+
assoc_name = col.to_s.gsub("_id","")
|
|
125
|
+
assoc = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
|
|
126
|
+
if assoc.nil?
|
|
127
|
+
exit_message = "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
|
128
|
+
exit
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
is_owner = col == ownership_field
|
|
132
|
+
assoc_class_name = assoc.active_record.name
|
|
133
|
+
display_column = HotGlue.derrive_reference_name(assoc_class_name)
|
|
134
|
+
|
|
135
|
+
(is_owner ? "<% unless @#{assoc_name} %>\n" : "") +
|
|
136
|
+
" <%= f.collection_select(:#{col}, #{assoc.class_name}.all, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{col} }, class: 'form-control') %>\n" +
|
|
137
|
+
(is_owner ? "<% else %>\n <%= @#{assoc_name}.#{display_column} %>" : "") +
|
|
138
|
+
(is_owner ? "\n<% end %>" : "")
|
|
139
|
+
|
|
140
|
+
else
|
|
141
|
+
" <%= f.text_field :#{col}, value: #{@singular}.#{col}, autocomplete: 'off', size: 4, class: 'form-control', type: 'number'" + (@form_placeholder_labels ? ", placeholder: '#{col.to_s.humanize}'" : "") + " %>\n " + "\n"
|
|
142
|
+
|
|
143
|
+
# field_output(col, nil, 4, col_identifier)
|
|
144
|
+
#
|
|
145
|
+
# # "<%= f.text_field :#{col}, value: #{singular}.#{col}, class: 'form-control', size: 4, type: 'number' %>"
|
|
146
|
+
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def string_result(col, sql_type, limit)
|
|
151
|
+
if sql_type == "varchar" || sql_type == "character varying"
|
|
152
|
+
field_output(col, nil, limit || 40, col_identifier)
|
|
153
|
+
else
|
|
154
|
+
text_area_output(col, 65536, col_identifier)
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def text_result(col, sql_type, limit)
|
|
160
|
+
if sql_type == "varchar"
|
|
161
|
+
field_output(col, nil, limit, col_identifier)
|
|
162
|
+
else
|
|
163
|
+
text_area_output(col, 65536, col_identifier)
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def field_output(col, type = nil, width, col_identifier )
|
|
168
|
+
" <%= f.text_field :#{col}, value: #{@singular}.#{col}, autocomplete: 'off', size: #{width}, class: 'form-control', type: '#{type}'" + (@form_placeholder_labels ? ", placeholder: '#{col.to_s.humanize}'" : "") + " %>\n " + "\n"
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def text_area_output(col, field_length, col_identifier )
|
|
172
|
+
lines = field_length % 40
|
|
173
|
+
if lines > 5
|
|
174
|
+
lines = 5
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
"<%= f.text_area :#{col}, class: 'form-control', autocomplete: 'off', cols: 40, rows: '#{lines}'" + ( @form_placeholder_labels ? ", placeholder: '#{col.to_s.humanize}'" : "") + " %>"
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def boolean_result(col)
|
|
181
|
+
" <br />" +
|
|
182
|
+
" <%= f.radio_button(:#{col}, '0', checked: #{singular}.#{col} ? '' : 'checked') %>\n" +
|
|
183
|
+
" <%= f.label(:#{col}, value: 'No', for: '#{singular}_#{col}_0') %>\n" +
|
|
184
|
+
" <%= f.radio_button(:#{col}, '1', checked: #{singular}.#{col} ? 'checked' : '') %>\n" +
|
|
185
|
+
" <%= f.label(:#{col}, value: 'Yes', for: '#{singular}_#{col}_1') %>\n" +
|
|
186
|
+
""
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def enum_result(col)
|
|
190
|
+
enum_type = eval("#{singular_class}.columns.select{|x| x.name == '#{col}'}[0].sql_type")
|
|
191
|
+
"<%= f.collection_select(:#{col}, enum_to_collection_select( #{singular_class}.defined_enums['#{enum_type}']), :key, :value, {selected: @#{singular}.#{col} }, class: 'form-control') %>"
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
################################################################
|
|
161
195
|
|
|
162
196
|
def paginate(*args)
|
|
163
197
|
plural = args[0][:plural]
|
|
@@ -165,18 +199,24 @@ module HotGlue
|
|
|
165
199
|
"<% if #{plural}.respond_to?(:total_pages) %><%= paginate(#{plural}) %> <% end %>"
|
|
166
200
|
end
|
|
167
201
|
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
################################################################
|
|
206
|
+
|
|
207
|
+
|
|
168
208
|
def all_line_fields(*args)
|
|
169
|
-
|
|
170
|
-
show_only = args[0][:show_only]
|
|
171
|
-
singular_class = args[0][:singular_class]
|
|
172
|
-
singular = args[0][:singular]
|
|
173
|
-
perc_width = args[0][:perc_width]
|
|
174
|
-
layout = args[0][:layout]
|
|
175
|
-
col_identifier = args[0][:col_identifier] || (layout == "bootstrap" ? "col-md-2" : "scaffold-cell")
|
|
209
|
+
@columns = args[0][:columns]
|
|
210
|
+
@show_only = args[0][:show_only]
|
|
211
|
+
@singular_class = args[0][:singular_class]
|
|
212
|
+
@singular = args[0][:singular]
|
|
213
|
+
@perc_width = args[0][:perc_width]
|
|
214
|
+
@layout = args[0][:layout]
|
|
215
|
+
@col_identifier = args[0][:col_identifier] || (layout == "bootstrap" ? "col-md-2" : "scaffold-cell")
|
|
176
216
|
|
|
177
217
|
|
|
178
|
-
columns_count =
|
|
179
|
-
perc_width = (perc_width).floor
|
|
218
|
+
columns_count = columns.count + 1
|
|
219
|
+
perc_width = (@perc_width).floor
|
|
180
220
|
|
|
181
221
|
if layout == "bootstrap"
|
|
182
222
|
style_with_flex_basis = ""
|
|
@@ -184,7 +224,7 @@ module HotGlue
|
|
|
184
224
|
style_with_flex_basis = " style='flex-basis: #{perc_width}%'"
|
|
185
225
|
end
|
|
186
226
|
|
|
187
|
-
result =
|
|
227
|
+
result = columns.map{ |column|
|
|
188
228
|
"<div class='#{col_identifier}'#{style_with_flex_basis}>" +
|
|
189
229
|
|
|
190
230
|
|
|
@@ -97,7 +97,6 @@ module HotGlue
|
|
|
97
97
|
class_option :nest, type: :string, default: nil # DEPRECATED —— DO NOT USE
|
|
98
98
|
class_option :nested, type: :string, default: ""
|
|
99
99
|
|
|
100
|
-
|
|
101
100
|
class_option :namespace, type: :string, default: nil
|
|
102
101
|
class_option :auth, type: :string, default: nil
|
|
103
102
|
class_option :auth_identifier, type: :string, default: nil
|
|
@@ -105,6 +104,7 @@ module HotGlue
|
|
|
105
104
|
class_option :include, type: :string, default: ""
|
|
106
105
|
class_option :god, type: :boolean, default: false
|
|
107
106
|
class_option :gd, type: :boolean, default: false # alias for god
|
|
107
|
+
|
|
108
108
|
class_option :specs_only, type: :boolean, default: false
|
|
109
109
|
class_option :no_specs, type: :boolean, default: false
|
|
110
110
|
class_option :no_delete, type: :boolean, default: false
|
|
@@ -116,24 +116,31 @@ module HotGlue
|
|
|
116
116
|
class_option :show_only, type: :string, default: ""
|
|
117
117
|
|
|
118
118
|
class_option :ujs_syntax, type: :boolean, default: nil
|
|
119
|
-
|
|
120
119
|
class_option :downnest, type: :string, default: nil
|
|
121
120
|
class_option :magic_buttons, type: :string, default: nil
|
|
122
121
|
class_option :small_buttons, type: :boolean, default: nil
|
|
123
|
-
|
|
124
122
|
class_option :display_list_after_update, type: :boolean, default: false
|
|
125
123
|
class_option :smart_layout, type: :boolean, default: false
|
|
126
124
|
class_option :markup, type: :string, default: nil # deprecated -- use in app config instead
|
|
127
125
|
class_option :layout, type: :string, default: nil # if used here it will override what is in the config
|
|
126
|
+
|
|
128
127
|
class_option :no_list_label, type: :boolean, default: false
|
|
128
|
+
|
|
129
129
|
class_option :no_list_heading, type: :boolean, default: false
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
|
|
132
|
+
# determines if the labels show up BEFORE or AFTER on the NEW/EDIT (form)
|
|
133
|
+
class_option :form_labels_position, default: 'after' # choices are before, after, omit
|
|
134
|
+
class_option :form_placeholder_labels, default: false # puts the field names into the placeholder labels
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
# NOT YET IMPLEMENTED
|
|
138
|
+
# determines if labels appear within the rows of the VIEWABLE list (does NOT affect the list heading)
|
|
139
|
+
# class_option :inline_list_labels, default: 'omit' # choices are before, after, omit
|
|
132
140
|
|
|
133
141
|
def initialize(*meta_args)
|
|
134
142
|
super
|
|
135
143
|
|
|
136
|
-
|
|
137
144
|
begin
|
|
138
145
|
@the_object = eval(class_name)
|
|
139
146
|
rescue StandardError => e
|
|
@@ -165,7 +172,6 @@ module HotGlue
|
|
|
165
172
|
if !options['markup'].nil?
|
|
166
173
|
message = "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`"
|
|
167
174
|
raise(HotGlue::Error, message)
|
|
168
|
-
|
|
169
175
|
end
|
|
170
176
|
|
|
171
177
|
if !options['markup'].nil?
|
|
@@ -267,6 +273,18 @@ module HotGlue
|
|
|
267
273
|
@no_list_label = options['no_list_label'] || false
|
|
268
274
|
@no_list_heading = options['no_list_heading'] || false
|
|
269
275
|
|
|
276
|
+
@form_labels_position = options['form_labels_position']
|
|
277
|
+
if !['before','after','omit'].include?(@form_labels_position)
|
|
278
|
+
raise "You passed '#{@form_labels_position}' as the setting for --form-labels-position but the only allowed options are before, after (default), and omit"
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
@form_placeholder_labels = options['form_placeholder_labels'] # true or false
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
# if !['before','after','omit'].include?(@form_placeholder_labels)
|
|
285
|
+
# raise "You passed '#{@form_placeholder_labels}' as the setting for --form-placeholder-labels but the only allowed options are before, after, and omit (default)"
|
|
286
|
+
# end
|
|
287
|
+
|
|
270
288
|
@display_list_after_update = options['display_list_after_update'] || false
|
|
271
289
|
@smart_layout = options['smart_layout']
|
|
272
290
|
|
|
@@ -915,7 +933,9 @@ module HotGlue
|
|
|
915
933
|
singular_class: singular_class,
|
|
916
934
|
singular: singular,
|
|
917
935
|
col_identifier: col_identifier,
|
|
918
|
-
ownership_field: @ownership_field
|
|
936
|
+
ownership_field: @ownership_field,
|
|
937
|
+
form_labels_position: @form_labels_position,
|
|
938
|
+
form_placeholder_labels: @form_placeholder_labels
|
|
919
939
|
)
|
|
920
940
|
end
|
|
921
941
|
|
data/lib/hotglue/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hot-glue
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jason Fleetwood-Boldt
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-03-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -85,7 +85,6 @@ files:
|
|
|
85
85
|
- lib/generators/hot_glue/scaffold_generator.rb
|
|
86
86
|
- lib/generators/hot_glue/templates/base_controller.rb.erb
|
|
87
87
|
- lib/generators/hot_glue/templates/capybara_login.rb
|
|
88
|
-
- lib/generators/hot_glue/templates/confirmable.js
|
|
89
88
|
- lib/generators/hot_glue/templates/controller.rb.erb
|
|
90
89
|
- lib/generators/hot_glue/templates/erb/_errors.erb
|
|
91
90
|
- lib/generators/hot_glue/templates/erb/_flash_notices.erb
|
|
@@ -149,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
149
148
|
- !ruby/object:Gem::Version
|
|
150
149
|
version: '0'
|
|
151
150
|
requirements: []
|
|
152
|
-
rubygems_version: 3.1.
|
|
151
|
+
rubygems_version: 3.1.6
|
|
153
152
|
signing_key:
|
|
154
153
|
specification_version: 4
|
|
155
154
|
summary: A gem to build Tubro Rails scaffolding.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Controller } from "@hotwired/stimulus"
|
|
2
|
-
|
|
3
|
-
console.log("defining Confirmable....")
|
|
4
|
-
export default class extends Controller {
|
|
5
|
-
static values = { message: String }
|
|
6
|
-
|
|
7
|
-
confirm(event) {
|
|
8
|
-
|
|
9
|
-
if(!window.confirm(this.message)) {
|
|
10
|
-
event.preventDefault();
|
|
11
|
-
event.stopPropagation()
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|