hot-glue 0.5.11 → 0.5.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +17 -2
- data/README.md +13 -6
- data/lib/generators/hot_glue/default_config_loader.rb +12 -0
- data/lib/generators/hot_glue/field_factory.rb +2 -0
- data/lib/generators/hot_glue/fields/association_field.rb +1 -1
- data/lib/generators/hot_glue/fields/attachment_field.rb +27 -0
- data/lib/generators/hot_glue/fields/field.rb +1 -1
- data/lib/generators/hot_glue/hot_glue.rb +5 -0
- data/lib/generators/hot_glue/layout/builder.rb +38 -55
- data/lib/generators/hot_glue/markup_templates/erb.rb +9 -15
- data/lib/generators/hot_glue/scaffold_generator.rb +953 -1010
- data/lib/generators/hot_glue/templates/erb/_list.erb +1 -2
- data/lib/generators/hot_glue/templates/erb/_show.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/edit.erb +35 -6
- data/lib/hot-glue.rb +78 -0
- data/lib/hotglue/version.rb +1 -1
- data/script/test +2 -4
- metadata +4 -2
@@ -13,7 +13,7 @@
|
|
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
|
+
<% if @downnest_object.any? && !@big_edit %>
|
17
17
|
<% if !@stacked_downnesting %>
|
18
18
|
<%= @layout_strategy.downnest_column_style %>
|
19
19
|
<% @downnest_object.each do |downnest,i| %>
|
@@ -33,7 +33,6 @@
|
|
33
33
|
<% end %>
|
34
34
|
</div>
|
35
35
|
<% end %>
|
36
|
-
|
37
36
|
<% end %>
|
38
37
|
|
39
38
|
<div class=' scaffold-col-heading scaffold-col-heading-buttons <%= @layout_strategy.column_classes_for_column_headings %>' <%= @layout_strategy.button_column_style %>>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
<% if @downnest_children.any? %>
|
5
|
+
<% if @downnest_children.any? && ! @big_edit %>
|
6
6
|
<% each_downnest_width = @downnest_children.count == 1 ? 33 : (53/@downnest_children.count).floor %>
|
7
7
|
<% if @stacked_downnesting %><div class="<%= @layout_strategy.downnest_portal_stacked_column_width %> scaffold-downnest" ><% end %>
|
8
8
|
<% @downnest_object.each do |downnest, size| %>
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% if @big_edit %>
|
2
|
+
<div class="container">
|
3
|
+
<div class="row">
|
4
|
+
<div class="col-md-12">
|
5
|
+
<\%= link_to "<% if @button_icons == 'font-awesome' %><i class='fa fa-arrow-circle-left 2x'></i><% end %> Back to list".html_safe, <%= path_helper_plural %> %>
|
6
|
+
<% end %>
|
3
7
|
<\%= turbo_frame_tag "<%= @namespace %>__#{dom_id(@<%= singular %>)}" do %>
|
4
|
-
|
5
8
|
<div class="cell editable" style="position: relative;">
|
6
|
-
|
7
9
|
<\% if @<%= singular %>.errors.any? %>
|
8
10
|
<\%= render(partial: "<%= namespace_with_trailing_dash %>errors", locals: {resource: @<%= singular %> }) %>
|
9
11
|
<\% end %>
|
@@ -12,9 +14,36 @@
|
|
12
14
|
<\%= form_with model: <%= "@" + singular %>, url: <%= form_path_edit_helper %> do |f| %>
|
13
15
|
<\%= render partial: "form", locals: {:<%= singular %> => <%= "@" + singular%>, f: f}<%= @nested_set.collect{|arg| ".merge(@#{arg[:singular]} ? {#{arg[:singular]}: @#{arg[:singular]}} : {})" }.join %> \%>
|
14
16
|
<\% end %>
|
15
|
-
|
16
17
|
</div>
|
17
|
-
|
18
18
|
<\% end %>
|
19
|
+
<% if @big_edit %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
|
19
23
|
|
24
|
+
<% if @downnest_children.any? && @big_edit %>
|
25
|
+
<% each_downnest_width = @downnest_children.count == 1 ? 33 : (53/@downnest_children.count).floor %>
|
26
|
+
<% @downnest_object.each do |downnest, size| %>
|
27
|
+
<div class="row">
|
28
|
+
<div class="col-md-6">
|
29
|
+
<% downnest_object = eval("#{singular_class}.reflect_on_association(:#{downnest})") %>
|
30
|
+
<% if downnest_object.nil?; raise "no relationship for downnested portal `#{downnest}` found on `#{singular_class}`; please check relationship for has_many :#{downnest}"; end; %>
|
31
|
+
<% downnest_class = downnest_object.class_name %>
|
32
|
+
<% downnest_object_name = eval("#{downnest_class}.table_name") %>
|
33
|
+
<% downnest_style = @layout_strategy.downnest_style %>
|
34
|
+
|
35
|
+
<\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest_object_name %>/list", locals: {
|
36
|
+
<%= @singular %>: @<%= @singular %>,
|
37
|
+
<%= downnest_object_name %>: @<%= @singular %>.<%= downnest %>
|
38
|
+
}
|
39
|
+
.merge({nested_for: "<% if @nested_set.any? %>#{nested_for + "__" if defined?(nested_for)}<% end %><%= @singular %>-#{@<%= @singular %>.id}"})
|
40
|
+
<%= @nested_set.collect{|arg| ".merge(defined?(#{arg[:singular]}) ? {#{arg[:singular]}: #{arg[:singular]}} : {} )"}.join("\n") %>
|
41
|
+
\%>
|
42
|
+
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
<% end %>
|
46
|
+
<% end %>
|
47
|
+
</div>
|
48
|
+
<% end %>
|
20
49
|
|
data/lib/hot-glue.rb
CHANGED
@@ -5,5 +5,83 @@ module HotGlue
|
|
5
5
|
module TemplateBuilders
|
6
6
|
|
7
7
|
end
|
8
|
+
|
9
|
+
|
10
|
+
class Error < StandardError
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.construct_downnest_object(input)
|
14
|
+
res = input.split(",").map { |child|
|
15
|
+
child_name = child.gsub("+","")
|
16
|
+
extra_size = child.count("+")
|
17
|
+
{child_name => 4+extra_size}
|
18
|
+
}
|
19
|
+
Hash[*res.collect{|hash| hash.collect{|key,value| [key,value].flatten}.flatten}.flatten]
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.optionalized_ternary(namespace: nil,
|
23
|
+
target:,
|
24
|
+
nested_set:,
|
25
|
+
modifier: "",
|
26
|
+
with_params: false,
|
27
|
+
top_level: false,
|
28
|
+
put_form: false)
|
29
|
+
instance_sym = top_level ? "@" : ""
|
30
|
+
if nested_set.nil? || nested_set.empty?
|
31
|
+
return modifier + "#{(namespace + '_') if namespace}#{target}_path" + (("(#{instance_sym}#{target})" if put_form) || "")
|
32
|
+
elsif nested_set[0][:optional] == false
|
33
|
+
return modifier + ((namespace + "_" if namespace) || "") + nested_set.collect{|x|
|
34
|
+
x[:singular] + "_"
|
35
|
+
}.join() + target + "_path" + (("(#{nested_set.collect{
|
36
|
+
|x| instance_sym + x[:singular] }.join(",")
|
37
|
+
}#{ put_form ? ',' + instance_sym + target : '' })" if with_params) || "")
|
38
|
+
|
39
|
+
else
|
40
|
+
# copy the first item, make a ternery in this cycle, and recursively move to both the
|
41
|
+
# is present path and the is optional path
|
42
|
+
|
43
|
+
nonoptional = nested_set[0].dup
|
44
|
+
nonoptional[:optional] = false
|
45
|
+
rest_of_nest = nested_set[1..-1]
|
46
|
+
|
47
|
+
is_present_path = HotGlue.optionalized_ternary(
|
48
|
+
namespace: namespace,
|
49
|
+
target: target,
|
50
|
+
modifier: modifier,
|
51
|
+
top_level: top_level,
|
52
|
+
with_params: with_params,
|
53
|
+
put_form: put_form,
|
54
|
+
nested_set: [nonoptional, *rest_of_nest])
|
55
|
+
|
56
|
+
is_missing_path = HotGlue.optionalized_ternary(
|
57
|
+
namespace: namespace,
|
58
|
+
target: target,
|
59
|
+
modifier: modifier,
|
60
|
+
top_level: top_level,
|
61
|
+
with_params: with_params,
|
62
|
+
put_form: put_form,
|
63
|
+
nested_set: rest_of_nest )
|
64
|
+
return "defined?(#{instance_sym + nested_set[0][:singular]}2) ? #{is_present_path} : #{is_missing_path}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.derrive_reference_name(thing_as_string)
|
69
|
+
assoc_class = eval(thing_as_string)
|
70
|
+
|
71
|
+
if assoc_class.new.respond_to?("name")
|
72
|
+
display_column = "name"
|
73
|
+
elsif assoc_class.new.respond_to?("to_label")
|
74
|
+
display_column = "to_label"
|
75
|
+
elsif assoc_class.new.respond_to?("full_name")
|
76
|
+
display_column = "full_name"
|
77
|
+
elsif assoc_class.new.respond_to?("display_name")
|
78
|
+
display_column = "display_name"
|
79
|
+
elsif assoc_class.new.respond_to?("email")
|
80
|
+
display_column = "email"
|
81
|
+
end
|
82
|
+
display_column
|
83
|
+
end
|
84
|
+
|
85
|
+
|
8
86
|
end
|
9
87
|
|
data/lib/hotglue/version.rb
CHANGED
data/script/test
CHANGED
@@ -4,9 +4,7 @@ clean_generated_code() {
|
|
4
4
|
./clean_generated_code
|
5
5
|
}
|
6
6
|
|
7
|
-
|
8
|
-
# the internal specs test only Hot Glue's command line usage
|
9
|
-
rspec spec
|
7
|
+
|
10
8
|
|
11
9
|
script/clean_generated_code
|
12
10
|
|
@@ -47,7 +45,7 @@ rails generate hot_glue:scaffold Human --gd
|
|
47
45
|
|
48
46
|
|
49
47
|
|
50
|
-
rspec
|
48
|
+
rspec || exit
|
51
49
|
|
52
50
|
cd ../
|
53
51
|
|
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.12
|
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-04-
|
11
|
+
date: 2023-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- config/database.yml
|
76
76
|
- config/hot_glue.yml
|
77
77
|
- db/schema.rb
|
78
|
+
- lib/generators/hot_glue/default_config_loader.rb
|
78
79
|
- lib/generators/hot_glue/direct_upload_install_generator.rb
|
79
80
|
- lib/generators/hot_glue/dropzone_install_generator.rb
|
80
81
|
- lib/generators/hot_glue/field_factory.rb
|
@@ -91,6 +92,7 @@ files:
|
|
91
92
|
- lib/generators/hot_glue/fields/text_field.rb
|
92
93
|
- lib/generators/hot_glue/fields/time_field.rb
|
93
94
|
- lib/generators/hot_glue/fields/uuid_field.rb
|
95
|
+
- lib/generators/hot_glue/hot_glue.rb
|
94
96
|
- lib/generators/hot_glue/install_generator.rb
|
95
97
|
- lib/generators/hot_glue/layout/builder.rb
|
96
98
|
- lib/generators/hot_glue/layout_strategy/base.rb
|