hot-glue 0.5.7 → 0.5.9.1
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 -1
- data/.gitignore +2 -1
- data/Gemfile +1 -1
- data/LICENSE +12 -5
- data/README.md +323 -143
- data/app/helpers/hot_glue/controller_helper.rb +9 -6
- data/lib/generators/hot_glue/direct_upload_install_generator.rb +47 -0
- data/lib/generators/hot_glue/dropzone_install_generator.rb +39 -0
- data/lib/generators/hot_glue/layout/builder.rb +15 -7
- data/lib/generators/hot_glue/layout_strategy/base.rb +2 -0
- data/lib/generators/hot_glue/layout_strategy/bootstrap.rb +16 -3
- data/lib/generators/hot_glue/markup_templates/erb.rb +186 -127
- data/lib/generators/hot_glue/scaffold_generator.rb +269 -142
- data/lib/generators/hot_glue/templates/controller.rb.erb +19 -11
- data/lib/generators/hot_glue/templates/erb/_list.erb +19 -6
- data/lib/generators/hot_glue/templates/erb/_show.erb +6 -4
- data/lib/generators/hot_glue/templates/javascript/dropzone_controller.js +191 -0
- data/lib/generators/hot_glue/templates/system_spec.rb.erb +31 -13
- data/lib/hotglue/version.rb +1 -1
- data/script/clean_generated_code +1 -1
- metadata +7 -4
@@ -41,20 +41,25 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
41
41
|
<% else %>
|
42
42
|
@<%= @nested_set[0][:singular] %> ||= <%= root_object %>.find(params[:<%= @nested_set[0][:singular] %>_id])<%= " if params.include?(:#{@nested_set[0][:singular]}_id)" if @nested_set[0][:optional] %> <% end %>
|
43
43
|
end
|
44
|
-
<% end %><% if any_nested? %><% nest_chain = [@nested_set[0][:singular]];
|
45
|
-
<%
|
44
|
+
<% end %><% if any_nested? %><% nest_chain = [@nested_set[0][:singular]]; %>
|
45
|
+
<% for index in 1..(@nested_set.count - 1) do
|
46
46
|
arg = @nested_set[index]
|
47
|
+
|
47
48
|
last_arg = (index == 0 ? nil : @nested_set[index-1])
|
48
49
|
|
49
50
|
this_scope = "#{nest_chain.last}.#{arg[:plural]}"
|
50
|
-
nest_chain << arg %>
|
51
|
-
<% unless @nested_set[0][:singular] == arg[:singular] %>
|
51
|
+
nest_chain << arg[:singular] %>
|
52
52
|
def <%= arg[:singular] %>
|
53
|
-
@<%=
|
53
|
+
@<%= arg[:singular] %> ||= (<%= this_scope; %>.find(params[:<%= arg[:singular] %>_id]) <%= " if params.include?(:#{last_arg[:singular]}_id)" if last_arg && @god && last_arg[:optional] %>)
|
54
54
|
<% if @god && last_arg && (last_arg[:optional] ) %>@<%= arg[:singular] %> ||= (<%= collect_objects[index-1] %>.find(params[:<%= arg[:singular] %>_id]) if params.include?(:<%= arg[:singular] %>_id) ) <% end %>
|
55
|
-
end<% end %><% end
|
55
|
+
end<% end %><% end %>
|
56
|
+
<% if !@self_auth %>
|
56
57
|
def load_<%= singular_name %>
|
57
|
-
|
58
|
+
<% if @nested_set[0] && @nested_set[0][:optional] %>if params.include?(:<%= @nested_set.last[:singular] %>_id)
|
59
|
+
@<%= singular_name %> = <%= object_scope.gsub("@",'') %>.find(params[:id])
|
60
|
+
else
|
61
|
+
<% end %>@<%= singular_name %> = <%= object_scope %>.find(params[:id])<% if @nested_set[0] && @nested_set[0][:optional] %>
|
62
|
+
end<% end %>
|
58
63
|
end
|
59
64
|
<% else %>
|
60
65
|
def load_<%= singular_name %>
|
@@ -83,8 +88,9 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
83
88
|
" #{data[:assoc].downcase} = #{data[:assoc]}.#{data[:with_create] ? "find_or_create_by" : "find_by"}(#{data[:lookup_as]}: #{ singular_name }_params[:__lookup_#{data[:lookup_as]}])\n"
|
84
89
|
}.join("/n") %><% end %> <% merge_lookups = @alt_lookups.collect{|key, data| "#{key.gsub("_id", "")}: #{key.gsub("_id", "")}" }.join(",") %>
|
85
90
|
modified_params = modify_date_inputs_on_params(<%= singular_name %>_params.dup<%= controller_update_params_tap_away_alt_lookups %><% if @object_owner_sym && eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>.merge!(<% if @object_owner_optional && any_nested? %><%= @object_owner_name %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}<% else %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)<% end %>)<%= ".merge(#{merge_lookups})" if !merge_lookups.empty? %><% if @hawk_keys.any? %>
|
86
|
-
modified_params = hawk_params({<%= hawk_to_ruby %>}, modified_params)<% end %>
|
91
|
+
modified_params = hawk_params({<%= hawk_to_ruby %>}, modified_params)<% end %><%= controller_attachment_orig_filename_pickup_syntax %>
|
87
92
|
<%= creation_syntax %>
|
93
|
+
|
88
94
|
if @<%= singular_name %>.save
|
89
95
|
flash[:notice] = "Successfully created #{@<%= singular %>.<%= display_class %>}"
|
90
96
|
load_all_<%= plural %>
|
@@ -104,7 +110,9 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
104
110
|
<% if @alt_lookups.filter{|key,d| ! @update_show_only.include?(key.to_sym) }.any? %><%= @alt_lookups.filter{|key,d| ! @update_show_only.include?(key.to_sym) }.collect{|key, data|
|
105
111
|
" #{data[:assoc].downcase} = #{data[:assoc]}.#{data[:with_create] ? "find_or_create_by" : "find_by"}(#{data[:lookup_as]}: #{ singular_name }_params[:__lookup_#{data[:lookup_as]}])\n"
|
106
112
|
}.join("\n") %><% end %> <% merge_lookups = @alt_lookups.filter{|key,d| ! @update_show_only.include?(key.to_sym) }.collect{|key, data| "#{key.gsub("_id", "")}: #{key.gsub("_id", "")}" }.join(",") %>
|
107
|
-
|
113
|
+
<% @magic_buttons.each { |button| %>@<%= singular_name %>.<%= button %>! if <%= singular_name %>_params[:__<%= button %>]
|
114
|
+
<% } %>
|
115
|
+
modified_params = modify_date_inputs_on_params(<%= singular_name %>_params.dup<% if @object_owner_sym && eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>.merge!(<% if @object_owner_optional && any_nested? %><%= @object_owner_name %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}<% else %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)<% end %>)<%= controller_update_params_tap_away_alt_lookups %><%= controller_update_params_tap_away_magic_buttons %><%= ".merge(#{merge_lookups})" if !merge_lookups.empty? %>
|
108
116
|
|
109
117
|
<% if @hawk_keys.any? %> modified_params = hawk_params({<%= hawk_to_ruby %>}, modified_params)<% end %>
|
110
118
|
<% if @alt_lookups.any? %><%= @alt_lookups.collect{|key, data|
|
@@ -114,7 +122,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
114
122
|
}.join("/n") %><% end %><% if (@update_alt_lookups).any? %>
|
115
123
|
<%= @update_alt_lookups.collect{|key, data|
|
116
124
|
" @#{ singular_name }.#{key.gsub("_id", "")} = #{key.gsub("_id", "")}"
|
117
|
-
}.join("/n") %><% end %>
|
125
|
+
}.join("/n") %><% end %><%= controller_attachment_orig_filename_pickup_syntax %>
|
118
126
|
if @<%= singular_name %>.update(modified_params)
|
119
127
|
<% if @display_list_after_update %> load_all_<%= plural %><% end %>
|
120
128
|
flash[:notice] = (flash[:notice] || "") << "Saved #{@<%= singular %>.<%= display_class %>}"
|
@@ -136,7 +144,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
136
144
|
end<% end %>
|
137
145
|
|
138
146
|
def <%=singular_name%>_params
|
139
|
-
params.require(:<%= testing_name %>).permit(<%= (fields_filtered_for_email_lookups - @show_only) + @magic_buttons.collect
|
147
|
+
params.require(:<%= testing_name %>).permit(<%= (fields_filtered_for_email_lookups - @show_only) + @magic_buttons.collect{|x| "__#{x}".to_sym }%>)
|
140
148
|
end
|
141
149
|
|
142
150
|
def namespace
|
@@ -12,15 +12,28 @@
|
|
12
12
|
<% unless @no_list_heading %>
|
13
13
|
<div class="<%= @layout_strategy.row_classes %> <%= @layout_strategy.row_heading_classes %>">
|
14
14
|
<%= list_column_headings %>
|
15
|
+
|
15
16
|
<% if @downnest_object.any? %>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
<
|
20
|
-
|
21
|
-
|
17
|
+
<% if !@stacked_downnesting %>
|
18
|
+
<%= @layout_strategy.downnest_column_style %>
|
19
|
+
<% @downnest_object.each do |downnest,i| %>
|
20
|
+
<div class=" scaffold-col-heading <%= @layout_strategy.downnest_portal_column_width(downnest) %> <%= @layout_strategy.downnest_column_style %>">
|
21
|
+
<strong>
|
22
|
+
<%= downnest.titleize %>
|
23
|
+
</strong>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
<% else %>
|
27
|
+
<div class=" scaffold-col-heading <%= @layout_strategy.downnest_portal_stacked_column_width %> <%= @layout_strategy.downnest_column_style %>">
|
28
|
+
<%= @layout_strategy.downnest_column_style %>
|
29
|
+
<% @downnest_object.each do |downnest,i| %>
|
30
|
+
<strong>
|
31
|
+
<%= downnest.titleize %>
|
32
|
+
</strong>
|
33
|
+
<% end %>
|
22
34
|
</div>
|
23
35
|
<% end %>
|
36
|
+
|
24
37
|
<% end %>
|
25
38
|
|
26
39
|
<div class=' scaffold-col-heading scaffold-col-heading-buttons <%= @layout_strategy.column_classes_for_column_headings %>' <%= @layout_strategy.button_column_style %>>
|
@@ -1,16 +1,17 @@
|
|
1
1
|
<%= all_line_fields %>
|
2
2
|
|
3
|
+
|
4
|
+
|
3
5
|
<% if @downnest_children.any? %>
|
4
6
|
<% each_downnest_width = @downnest_children.count == 1 ? 33 : (53/@downnest_children.count).floor %>
|
5
|
-
|
7
|
+
<% if @stacked_downnesting %><div class="<%= @layout_strategy.downnest_portal_stacked_column_width %> scaffold-downnest" ><% end %>
|
6
8
|
<% @downnest_object.each do |downnest, size| %>
|
7
|
-
|
8
9
|
<% downnest_object = eval("#{singular_class}.reflect_on_association(:#{downnest})") %>
|
9
10
|
<% if downnest_object.nil?; raise "no relationship for downnested portal `#{downnest}` found on `#{singular_class}`; please check relationship for has_many :#{downnest}"; end; %>
|
10
11
|
<% downnest_class = downnest_object.class_name %>
|
11
12
|
<% downnest_object_name = eval("#{downnest_class}.table_name") %>
|
12
13
|
<% downnest_style = @layout_strategy.downnest_style %>
|
13
|
-
|
14
|
+
<% if !@stacked_downnesting %><div class="<%= @layout_strategy.downnest_portal_column_width(downnest) %> scaffold-downnest" <%= downnest_style %> ><% end %>
|
14
15
|
<\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest_object_name %>/list", locals: {
|
15
16
|
<%= @singular %>: <%= @singular %>,
|
16
17
|
<%= downnest_object_name %>: <%= @singular %>.<%= downnest %>
|
@@ -18,8 +19,9 @@
|
|
18
19
|
.merge({nested_for: "<% if @nested_set.any? %>#{nested_for + "__" if defined?(nested_for)}<% end %><%= @singular %>-#{<%= @singular %>.id}"})
|
19
20
|
<%= @nested_set.collect{|arg| ".merge(defined?(#{arg[:singular]}) ? {#{arg[:singular]}: #{arg[:singular]}} : {} )"}.join("\n") %>
|
20
21
|
\%>
|
21
|
-
|
22
|
+
<% if !@stacked_downnesting %></div><% end %>
|
22
23
|
<% end %>
|
24
|
+
<% if @stacked_downnesting %></div><% end %>
|
23
25
|
<% end %>
|
24
26
|
|
25
27
|
<%= @layout_strategy.button_style %>
|
@@ -0,0 +1,191 @@
|
|
1
|
+
import Dropzone from "dropzone";
|
2
|
+
import { Controller } from "@hotwired/stimulus"
|
3
|
+
import { DirectUpload } from "@rails/activestorage";
|
4
|
+
|
5
|
+
export default class extends Controller {
|
6
|
+
static targets = ["input"];
|
7
|
+
|
8
|
+
connect() {
|
9
|
+
this.dropZone = this.createDropZone(this);
|
10
|
+
this.hideFileInput();
|
11
|
+
this.bindEvents();
|
12
|
+
Dropzone.autoDiscover = false; // necessary quirk for Dropzone error in console
|
13
|
+
}
|
14
|
+
|
15
|
+
// helpers
|
16
|
+
getMetaValue(name) {
|
17
|
+
const element = this.findElement(document.head, `meta[name="${name}"]`);
|
18
|
+
if (element) {
|
19
|
+
return element.getAttribute("content");
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
findElement(root, selector) {
|
24
|
+
if (typeof root == "string") {
|
25
|
+
selector = root;
|
26
|
+
root = document;
|
27
|
+
}
|
28
|
+
return root.querySelector(selector);
|
29
|
+
}
|
30
|
+
|
31
|
+
toArray(value) {
|
32
|
+
if (Array.isArray(value)) {
|
33
|
+
return value;
|
34
|
+
} else if (Array.from) {
|
35
|
+
return Array.from(value);
|
36
|
+
} else {
|
37
|
+
return [].slice.call(value);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
hideFileInput() {
|
43
|
+
this.inputTarget.disabled = true;
|
44
|
+
this.inputTarget.style.display = "none";
|
45
|
+
}
|
46
|
+
|
47
|
+
bindEvents() {
|
48
|
+
this.dropZone.on("addedfile", file => {
|
49
|
+
setTimeout(() => {
|
50
|
+
if (file.accepted) {
|
51
|
+
const duc = new DirectUploadProcessor(this, this.url(), file)
|
52
|
+
duc.start();
|
53
|
+
}
|
54
|
+
}, 500);
|
55
|
+
});
|
56
|
+
|
57
|
+
this.dropZone.on("removedfile", file => {
|
58
|
+
if(file.controller) {
|
59
|
+
file.controller.hiddenInput.parentNode.removeChild(file.controller.hiddenInput);
|
60
|
+
}
|
61
|
+
});
|
62
|
+
|
63
|
+
this.dropZone.on("canceled", file => {
|
64
|
+
file.controller && file.controller.xhr.abort();
|
65
|
+
});
|
66
|
+
}
|
67
|
+
|
68
|
+
url() {
|
69
|
+
return this.inputTarget.getAttribute("data-direct-upload-url");
|
70
|
+
}
|
71
|
+
|
72
|
+
createDropZone() {
|
73
|
+
|
74
|
+
return new Dropzone(this.element, {
|
75
|
+
url: this.url(),
|
76
|
+
headers: this.headers,
|
77
|
+
maxFiles: this.maxFiles,
|
78
|
+
maxFilesize: this.maxFileSize,
|
79
|
+
acceptedFiles: this.acceptedFiles,
|
80
|
+
addRemoveLinks: this.addRemoveLinks,
|
81
|
+
autoQueue: false
|
82
|
+
});
|
83
|
+
}
|
84
|
+
|
85
|
+
get headers() {
|
86
|
+
return { "X-CSRF-Token": this.getMetaValue("csrf-token") };
|
87
|
+
}
|
88
|
+
|
89
|
+
get maxFiles() {
|
90
|
+
return this.data.get("maxFiles") || 1;
|
91
|
+
}
|
92
|
+
|
93
|
+
get maxFileSize() {
|
94
|
+
return this.data.get("maxFileSize") || 256;
|
95
|
+
}
|
96
|
+
|
97
|
+
get acceptedFiles() {
|
98
|
+
return this.data.get("acceptedFiles");
|
99
|
+
}
|
100
|
+
|
101
|
+
get addRemoveLinks() {
|
102
|
+
return this.data.get("addRemoveLinks") || true;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
class DirectUploadProcessor {
|
107
|
+
constructor(source, url, file) {
|
108
|
+
this.directUpload = createDirectUpload(file, url, this);
|
109
|
+
this.source = source;
|
110
|
+
this.file = file;
|
111
|
+
this.url = url;
|
112
|
+
}
|
113
|
+
|
114
|
+
insertAfter(el, referenceNode) {
|
115
|
+
return referenceNode.parentNode.insertBefore(el, referenceNode.nextSibling);
|
116
|
+
}
|
117
|
+
|
118
|
+
start() {
|
119
|
+
this.file.controller = this;
|
120
|
+
this.hiddenInput = this.createHiddenInput();
|
121
|
+
this.directUpload.create((error, attributes) => {
|
122
|
+
if (error) {
|
123
|
+
|
124
|
+
this.hiddenInput.remove();
|
125
|
+
this.emitDropzoneError(error);
|
126
|
+
} else {
|
127
|
+
this.hiddenInput.value = attributes.signed_id;
|
128
|
+
this.emitDropzoneSuccess();
|
129
|
+
}
|
130
|
+
});
|
131
|
+
}
|
132
|
+
|
133
|
+
createHiddenInput() {
|
134
|
+
const input = document.createElement("input");
|
135
|
+
input.type = "hidden";
|
136
|
+
input.name = this.source.inputTarget.name;
|
137
|
+
this.insertAfter(input, this.source.inputTarget);
|
138
|
+
return input;
|
139
|
+
}
|
140
|
+
|
141
|
+
directUploadWillStoreFileWithXHR(xhr) {
|
142
|
+
this.bindProgressEvent(xhr);
|
143
|
+
this.emitDropzoneUploading();
|
144
|
+
}
|
145
|
+
|
146
|
+
bindProgressEvent(xhr) {
|
147
|
+
this.xhr = xhr;
|
148
|
+
this.xhr.upload.addEventListener("progress", event =>
|
149
|
+
this.uploadRequestDidProgress(event)
|
150
|
+
);
|
151
|
+
}
|
152
|
+
|
153
|
+
findElement(root, selector) {
|
154
|
+
if (typeof root == "string") {
|
155
|
+
selector = root;
|
156
|
+
root = document;
|
157
|
+
}
|
158
|
+
return root.querySelector(selector);
|
159
|
+
}
|
160
|
+
|
161
|
+
uploadRequestDidProgress(event) {
|
162
|
+
const element = this.source.element;
|
163
|
+
const progress = (event.loaded / event.total) * 100;
|
164
|
+
this.findElement(
|
165
|
+
this.file.previewTemplate,
|
166
|
+
".dz-upload"
|
167
|
+
).style.width = `${progress}%`;
|
168
|
+
}
|
169
|
+
|
170
|
+
emitDropzoneUploading() {
|
171
|
+
this.file.status = Dropzone.UPLOADING;
|
172
|
+
this.source.dropZone.emit("processing", this.file);
|
173
|
+
}
|
174
|
+
|
175
|
+
emitDropzoneError(error) {
|
176
|
+
this.file.status = Dropzone.ERROR;
|
177
|
+
this.source.dropZone.emit("error", this.file, error);
|
178
|
+
this.source.dropZone.emit("complete", this.file);
|
179
|
+
}
|
180
|
+
|
181
|
+
emitDropzoneSuccess() {
|
182
|
+
this.file.status = Dropzone.SUCCESS;
|
183
|
+
this.source.dropZone.emit("success", this.file);
|
184
|
+
this.source.dropZone.emit("complete", this.file);
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
function createDirectUpload(file, url, controller) {
|
189
|
+
return new DirectUpload(file, url, controller);
|
190
|
+
}
|
191
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
describe 'interaction for <%= controller_class_name %>'
|
3
|
+
describe 'interaction for <%= controller_class_name %>' do
|
4
4
|
include HotGlue::ControllerHelper
|
5
5
|
include ActionView::RecordIdentifier
|
6
6
|
|
@@ -12,7 +12,7 @@ describe 'interaction for <%= controller_class_name %>', type: :feature do
|
|
12
12
|
item1_addOns << "#{display_class}: FFaker::Name.name"
|
13
13
|
end
|
14
14
|
|
15
|
-
item1_addOns << ", " + @columns.map { |col|
|
15
|
+
item1_addOns << ", " + (@columns - @attachments.keys.collect(&:to_sym)).map { |col|
|
16
16
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
17
17
|
case type
|
18
18
|
when :string
|
@@ -53,13 +53,15 @@ describe 'interaction for <%= controller_class_name %>', type: :feature do
|
|
53
53
|
<%= objest_nest_factory_setup %> <% unless @god || @existing_content.include?("login_as")%>
|
54
54
|
before do
|
55
55
|
login_as(<%= @auth %>)
|
56
|
-
end <% end %>
|
57
|
-
|
56
|
+
end <% end %> <% if any_datetime_fields? %>
|
57
|
+
let(:current_timezone) {
|
58
|
+
<%= @auth_identifier %>.try(:timezone) || Time.now.strftime("%z").to_i/100
|
59
|
+
}<% end %>
|
58
60
|
describe "index" do
|
59
61
|
it "should show me the list" do
|
60
62
|
visit <%= path_helper_plural %>
|
61
63
|
<%=
|
62
|
-
@columns.map { |col|
|
64
|
+
(@columns - @attachments.keys.collect(&:to_sym)).map { |col|
|
63
65
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
64
66
|
|
65
67
|
case type
|
@@ -72,14 +74,18 @@ describe 'interaction for <%= controller_class_name %>', type: :feature do
|
|
72
74
|
when :uuid
|
73
75
|
assoc_name = col.to_s.gsub('_id','')
|
74
76
|
association = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
|
75
|
-
|
76
|
-
|
77
77
|
" " + ["expect(page).to have_content(#{singular}#{1}.#{assoc_name}.#{HotGlue.derrive_reference_name(association.class_name)})"].join("\n ")
|
78
|
+
when :enum
|
79
|
+
if(eval("#{singular_class}.respond_to?(:#{col}_labels)"))
|
80
|
+
" " + "expect(page).to have_content(#{singular_class}.#{col}_labels[#{singular}#{1}.#{col}])"
|
81
|
+
else
|
82
|
+
" " + "expect(page).to have_content(#{singular}1.#{col})"
|
83
|
+
end
|
78
84
|
|
79
85
|
when :boolean
|
80
86
|
" " + ["expect(page).to have_content(#{singular}#{1}.#{col} ? 'YES' : 'NO')"].join("\n ")
|
81
87
|
else
|
82
|
-
|
88
|
+
" " + ["expect(page).to have_content(#{singular}#{1}.#{col})"].join("\n ")
|
83
89
|
end
|
84
90
|
|
85
91
|
}.join("\n")
|
@@ -97,7 +103,7 @@ describe 'interaction for <%= controller_class_name %>', type: :feature do
|
|
97
103
|
expect(page).to have_content("Successfully created")
|
98
104
|
<%=" " +
|
99
105
|
|
100
|
-
(@columns - @show_only).map { |col|
|
106
|
+
((@columns - @attachments.keys.collect(&:to_sym)) - @show_only).map { |col|
|
101
107
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
102
108
|
|
103
109
|
case type
|
@@ -115,7 +121,12 @@ describe 'interaction for <%= controller_class_name %>', type: :feature do
|
|
115
121
|
|
116
122
|
when :boolean
|
117
123
|
["expect(page).to have_content(#{singular}#{1}.#{col} ? 'YES' : 'NO')"].join("\n ")
|
118
|
-
|
124
|
+
when :enum
|
125
|
+
if(eval("#{singular_class}.respond_to?(:#{col}_labels)"))
|
126
|
+
"expect(page).to have_content(#{singular_class}.#{col}_labels[new_#{col}])"
|
127
|
+
else
|
128
|
+
"expect(page).to have_content(new_#{col})"
|
129
|
+
end
|
119
130
|
else
|
120
131
|
"expect(page).to have_content(new_#{col})"
|
121
132
|
end
|
@@ -135,7 +146,7 @@ describe 'interaction for <%= controller_class_name %>', type: :feature do
|
|
135
146
|
<%= test_capybara_block(:update) %>
|
136
147
|
click_button "Save"
|
137
148
|
within("turbo-frame#<%= @namespace %>__#{dom_id(<%= singular %>1)} ") do
|
138
|
-
<%= (@columns - @show_only).map { |col|
|
149
|
+
<%= ((@columns - @attachments.keys.collect(&:to_sym)) - @show_only).map { |col|
|
139
150
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
140
151
|
|
141
152
|
if type == :uuid || (type == :integer && col.to_s.ends_with?("_id"))
|
@@ -146,9 +157,16 @@ describe 'interaction for <%= controller_class_name %>', type: :feature do
|
|
146
157
|
elsif type == :boolean
|
147
158
|
' expect(page).to have_content(new_' + col.to_s + ' ? "YES" : "NO")'
|
148
159
|
|
160
|
+
elsif type == :enum && eval("#{singular_class}.respond_to?(:#{col}_labels)")
|
161
|
+
" expect(page).to have_content(#{singular_class}.#{col}_labels[new_#{col}])"
|
162
|
+
elsif type == :string && eval("#{singular_class}.respond_to?(:devise_modules)") &&
|
163
|
+
#devise confirmable makes email updates go into unconfirmed_email
|
164
|
+
eval("#{singular_class}.devise_modules.include?(:confirmable)") && col.to_s == "email"
|
165
|
+
" expect(page).to have_content(#{ singular }1.#{col.to_s})"
|
166
|
+
elsif type == :datetime
|
167
|
+
" expect(page).to have_content(new_#{col.to_s}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ') + timezonize(current_timezone))"
|
149
168
|
else
|
150
|
-
|
151
|
-
|
169
|
+
" expect(page).to have_content(new_#{col.to_s})"
|
152
170
|
end
|
153
171
|
}.compact.join("\n")
|
154
172
|
%>
|
data/lib/hotglue/version.rb
CHANGED
data/script/clean_generated_code
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.5.
|
4
|
+
version: 0.5.9.1
|
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: 2023-
|
11
|
+
date: 2023-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -75,6 +75,8 @@ files:
|
|
75
75
|
- config/database.yml
|
76
76
|
- config/hot_glue.yml
|
77
77
|
- db/schema.rb
|
78
|
+
- lib/generators/hot_glue/direct_upload_install_generator.rb
|
79
|
+
- lib/generators/hot_glue/dropzone_install_generator.rb
|
78
80
|
- lib/generators/hot_glue/install_generator.rb
|
79
81
|
- lib/generators/hot_glue/layout/builder.rb
|
80
82
|
- lib/generators/hot_glue/layout_strategy/base.rb
|
@@ -117,6 +119,7 @@ files:
|
|
117
119
|
- lib/generators/hot_glue/templates/haml/index.haml
|
118
120
|
- lib/generators/hot_glue/templates/haml/new.haml
|
119
121
|
- lib/generators/hot_glue/templates/haml/update.turbo_stream.haml
|
122
|
+
- lib/generators/hot_glue/templates/javascript/dropzone_controller.js
|
120
123
|
- lib/generators/hot_glue/templates/system_spec.rb.erb
|
121
124
|
- lib/generators/hot_glue/templates/themes/hotglue_scaffold_dark_knight.scss
|
122
125
|
- lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_bootstrap.scss
|
@@ -131,9 +134,9 @@ homepage: https://heliosdev.shop/p/hot-glue?utm_source=rubygems.org&utm_campaign
|
|
131
134
|
licenses:
|
132
135
|
- Nonstandard
|
133
136
|
metadata:
|
134
|
-
source_code_uri: https://github.com/
|
137
|
+
source_code_uri: https://github.com/hot-glue-for-rails/hot-glue
|
135
138
|
homepage: https://heliosdev.shop/hot-glue
|
136
|
-
funding: https://
|
139
|
+
funding: https://school.jasonfleetwoodboldt.com/8188
|
137
140
|
post_install_message: |
|
138
141
|
---------------------------------------------
|
139
142
|
Welcome to Hot Glue - A Scaffold Building Companion for Hotwire + Turbo-Rails
|