hot-glue 0.5.12 → 0.5.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +65 -1
  3. data/lib/generators/hot_glue/fields/date_time_field.rb +3 -2
  4. data/lib/generators/hot_glue/fields/enum_field.rb +2 -2
  5. data/lib/generators/hot_glue/fields/field.rb +1 -1
  6. data/lib/generators/hot_glue/fields/integer_field.rb +1 -1
  7. data/lib/generators/hot_glue/fields/uuid_field.rb +1 -2
  8. data/lib/generators/hot_glue/flash_notices_install_generator.rb +20 -0
  9. data/lib/generators/hot_glue/install_generator.rb +2 -7
  10. data/lib/generators/hot_glue/scaffold_generator.rb +25 -5
  11. data/lib/generators/hot_glue/templates/controller.rb.erb +5 -4
  12. data/lib/generators/hot_glue/templates/erb/_edit.erb +12 -0
  13. data/lib/generators/hot_glue/templates/erb/_flash_notices.erb +12 -8
  14. data/lib/generators/hot_glue/templates/erb/_show.erb +1 -1
  15. data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +3 -4
  16. data/lib/generators/hot_glue/templates/erb/destroy.turbo_stream.erb +7 -1
  17. data/lib/generators/hot_glue/templates/erb/edit.erb +1 -12
  18. data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +3 -6
  19. data/lib/generators/hot_glue/templates/system_spec.rb.erb +1 -1
  20. data/lib/hot-glue.rb +4 -1
  21. data/lib/hotglue/version.rb +1 -1
  22. metadata +4 -18
  23. data/lib/generators/hot_glue/templates/erb/_errors.erb +0 -11
  24. data/lib/generators/hot_glue/templates/haml/_errors.haml +0 -6
  25. data/lib/generators/hot_glue/templates/haml/_flash_notices.haml +0 -8
  26. data/lib/generators/hot_glue/templates/haml/_form.haml +0 -5
  27. data/lib/generators/hot_glue/templates/haml/_line.haml +0 -6
  28. data/lib/generators/hot_glue/templates/haml/_list.haml +0 -15
  29. data/lib/generators/hot_glue/templates/haml/_new_button.haml +0 -2
  30. data/lib/generators/hot_glue/templates/haml/_new_form.haml +0 -7
  31. data/lib/generators/hot_glue/templates/haml/_show.haml +0 -7
  32. data/lib/generators/hot_glue/templates/haml/create.turbo_stream.haml +0 -14
  33. data/lib/generators/hot_glue/templates/haml/destroy.turbo_stream.haml +0 -2
  34. data/lib/generators/hot_glue/templates/haml/edit.haml +0 -19
  35. data/lib/generators/hot_glue/templates/haml/edit.turbo_stream.haml +0 -4
  36. data/lib/generators/hot_glue/templates/haml/index.haml +0 -8
  37. data/lib/generators/hot_glue/templates/haml/new.haml +0 -1
  38. data/lib/generators/hot_glue/templates/haml/update.turbo_stream.haml +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78d37c6eaf1dbce758ad70869c5a8b18f799b5ebabfebf242fa7e5641c672cd2
4
- data.tar.gz: 38b18ddbe9505ec0123c403a944d563c9b91720d9a03deb7e89c8202ae406574
3
+ metadata.gz: c93b089a5dfd19941c88d9b330f0305dee83315bf7b8a6af436321dad842ac0b
4
+ data.tar.gz: cf17d5a487fdf1ae4230647923b42d344465bf1e81a06eb6eef0caa75282eb2c
5
5
  SHA512:
6
- metadata.gz: c8562d221489ae715a8848cec74b28259bbf51d06d90df8968cfeb1a7a36d2c20968fc596f8e89ad49bbce4533bcc0bab425d84ec43fdaf511fd785e22b590b3
7
- data.tar.gz: fd79db54f85333e4652b9e5444b720eb5525275fd7e071eb27bce4105bd6ca0f475bf921fb216f4389e1f4522bc148d7c9306efdfd707f466a4d826477c5a146
6
+ metadata.gz: f9c6f8fdd02d3cd09e7c9e6a46a5a82c7125475b18f11fafa1cc3c609c4e7376c7c2cfcbc3a18483bd2027a69adfff859b62fa5d2405dabf371f4086247b240d
7
+ data.tar.gz: 51b3736cb2715e6387a13a98a4fe12bf450eee827679d80a6079d3b62546d31db234c4a818e03e801f07881ebd45da289b34b7c61dd5821d25db8084c8de6a61
data/README.md CHANGED
@@ -1124,9 +1124,29 @@ Thus, your factory object must have a method of the same name as the factory bei
1124
1124
  For example, assuming the example from above, we are going to do the lookup ourselves inside of our own `AgentFactory` object.)
1125
1125
 
1126
1126
  ```
1127
- agent_factory = AgentFactory.new(find_or_create_by_email: agent_company_params[:__lookup_email])
1127
+ factory = AgentFactory.new(find_or_create_by_email: agent_company_params[:__lookup_email],
1128
+ params: modified_params)
1128
1129
  ```
1129
1130
 
1131
+ Here the new AgentFactory will recieve any variables by keyword argument, and since you're specifying the calling code here, Hot Glue does not dictate your factory's setup.
1132
+ However, two special variables are in scope which you can use in your calling code.
1133
+
1134
+ `*_params` (where * is the name of the thing you are building)
1135
+ `modified_params` a variable that has been transmogrified for the timezone aware input
1136
+
1137
+ Either one must be recieved by your factory for your factory to create data based off the inputted data.
1138
+
1139
+ Rememebr, `*_params` has the input params passed only the through the sanitizer, and modified_params has it passed through the timezone aware mechanism and other Hot Glue-specific defaults.
1140
+
1141
+ Always:
1142
+ • In your factory calling code, assign the variable `factory = ` (do not use a different variable name),
1143
+ • Write a factory object with a `new` method that received the paramters you are specifying in your calling code,
1144
+ • Be sure your factory has an _instance method_ a method with the **same name** of the built object, which hot glue will call next:
1145
+
1146
+ `@agent = factory.agent`
1147
+
1148
+ Don't include this last line in your factory code.
1149
+
1130
1150
 
1131
1151
 
1132
1152
  ## Automatic Base Controller
@@ -1209,8 +1229,52 @@ def self.status_labels
1209
1229
 
1210
1230
  Now, your labels will show up on the front-end as defined in the `_labels` ("Is currently pending", etc) instead of the database-values.
1211
1231
 
1232
+ ### Validation Magic
1233
+
1234
+ Use ActiveRecord validations or hooks to validate your data. Hot Glue will automatically display the errors in the UI.
1235
+
1236
+ TO prevent a record from being destroyed, use a syntax like this:
1237
+
1238
+ ```
1239
+ before_destroy :check_if_allowed_to_destroy
1240
+
1241
+ def check_if_allowed_to_destroy
1242
+ if (some_condition)
1243
+ self.errors.add(:base, "Cannot delete")
1244
+ raise ActiveRecord::RecordNotDestroyed("Cannot delete because of some condition")
1245
+ end
1246
+ end
1247
+
1248
+ ```
1249
+
1250
+
1251
+
1252
+
1212
1253
 
1213
1254
  # VERSION HISTORY
1255
+
1256
+ #### TBR
1257
+ - When using big edit, updating a child will now re-render the parent EDIT record automatically.
1258
+
1259
+ For example
1260
+ `rails generate hot_glue:scafold LineItem --nested=invioce`
1261
+
1262
+ Whenever the line item is created, updated, or destroyed, the parent invoice record gets (edit action) re-rendered automatically. This happens for the big edit screen of the invoice.
1263
+
1264
+ #### 2023-05-14 - v0.5.14 Delete message flash notice and new flash notice partial
1265
+
1266
+ - This changes to how flash_notices work.
1267
+ - After you upgrade to 0.5.14 from a prior version, please re-install the global flash notice
1268
+ - template with:
1269
+
1270
+ `rails generate hot_glue:flash_notices_install`
1271
+
1272
+ The newer template will work with old Hot Glue scaffold (generated prior to 0.5.14) and new scaffold moving forward.
1273
+
1274
+ If you miss this step, your old Hot Glue flash notices template will not show the model error messages (but will continue to show the global alert & notice messages)
1275
+
1276
+ - The destroy action on controllers now produces an "alert" message for successful deletion.
1277
+
1214
1278
  #### 2023-04-24 - v0.5.12
1215
1279
  - adds new option for `bootstrap_column_width` (default is 2) to specify the number of bootstrap columns a visual column should take up
1216
1280
  - You can specify this as a builder option (`--bootstrap-column-width`)
@@ -10,7 +10,8 @@ class DateTimeField < Field
10
10
  end
11
11
 
12
12
  def spec_make_assertion
13
- super
13
+
14
+ "expect(page).to have_content(new_#{name}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ') + timezonize(current_timezone))"
14
15
  end
15
16
 
16
17
  def spec_setup_let_arg
@@ -18,6 +19,6 @@ class DateTimeField < Field
18
19
  end
19
20
 
20
21
  def spec_list_view_assertion
21
- " " + ["expect(page).to have_content(#{singular}#{1}.#{name}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ').gsub(' ', ' ') + timezonize(current_timezone) )"].join("\n ")
22
+ "expect(page).to have_content(#{singular}#{1}.#{name}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ').gsub(' ', ' ') + timezonize(current_timezone) )"
22
23
  end
23
24
  end
@@ -19,9 +19,9 @@ class EnumField < Field
19
19
 
20
20
  def spec_list_view_assertion
21
21
  if(eval("#{singular_class}.respond_to?(:#{name}_labels)"))
22
- " " + "expect(page).to have_content(#{singular_class}.#{name}_labels[#{singular}#{1}.#{name}])"
22
+ "expect(page).to have_content(#{singular_class}.#{name}_labels[#{singular}#{1}.#{name}])"
23
23
  else
24
- " " + "expect(page).to have_content(#{singular}1.#{name})"
24
+ "expect(page).to have_content(#{singular}1.#{name})"
25
25
  end
26
26
  end
27
27
  end
@@ -42,7 +42,7 @@ class Field
42
42
  end
43
43
 
44
44
  def spec_list_view_assertion
45
- " " + ["expect(page).to have_content(#{singular}#{1}.#{name})"].join("\n ")
45
+ "expect(page).to have_content(#{singular}#{1}.#{name})"
46
46
  end
47
47
 
48
48
  def spec_related_column_lets
@@ -21,6 +21,6 @@ class IntegerField < Field
21
21
  end
22
22
 
23
23
  def spec_list_view_assertion
24
- " " + ["expect(page).to have_content(#{singular}#{1}.#{name})"].join("\n ")
24
+ "expect(page).to have_content(#{singular}#{1}.#{name})"
25
25
  end
26
26
  end
@@ -6,7 +6,6 @@ class UUIDField < Field
6
6
  def spec_list_view_assertion
7
7
  assoc_name = name.to_s.gsub('_id','')
8
8
  association = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
9
- " " + ["expect(page).to have_content(#{singular}#{1}.#{assoc_name}.#{HotGlue.derrive_reference_name(association.class_name)})"].join("\n ")
10
-
9
+ "expect(page).to have_content(#{singular}#{1}.#{assoc_name}.#{HotGlue.derrive_reference_name(association.class_name)})"
11
10
  end
12
11
  end
@@ -0,0 +1,20 @@
1
+ module HotGlue
2
+ class FlashNoticesInstallGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('templates', __dir__)
4
+
5
+ def filepath_prefix
6
+ # todo: inject the context
7
+ 'spec/dummy/' if Rails.env.test?
8
+ end
9
+
10
+
11
+ def initialize(*args) #:nodoc:
12
+ super
13
+ copy_file "erb/_flash_notices.erb", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.erb"
14
+
15
+ end
16
+ end
17
+ end
18
+
19
+
20
+
@@ -27,13 +27,8 @@ module HotGlue
27
27
  end
28
28
 
29
29
 
30
- @markup = options['markup']
31
- if @markup == "haml"
32
- copy_file "haml/_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
33
- elsif @markup == "erb"
34
- copy_file "erb/_flash_notices.erb", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.erb"
35
-
36
- end
30
+ @markup = options['markup'] || "erb"
31
+ copy_file "erb/_flash_notices.erb", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.erb"
37
32
 
38
33
  begin
39
34
  if Rails.version.split(".")[0].to_i == 6
@@ -648,10 +648,10 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
648
648
  }.join(", ")
649
649
 
650
650
  if @factory_creation == ''
651
- "@#{singular } = #{ class_name }.create(modified_params)"
651
+ "@#{singular } = #{ class_name }.create(modified_params#{'.merge(' + merge_with + ')' if !merge_with.empty?})"
652
652
  else
653
653
  "#{@factory_creation}\n" +
654
- " @#{singular } = #{ class_name }.create(modified_params#{'.merge(' + merge_with + ')' if !merge_with.empty?})"
654
+ " @#{singular } = factory.#{singular}"
655
655
  end
656
656
  end
657
657
 
@@ -707,7 +707,9 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
707
707
  template "system_spec.rb.erb", dest_file
708
708
  end
709
709
 
710
- template "#{@markup}/_errors.#{@markup}", File.join("#{filepath_prefix}app/views#{namespace_with_dash}", "_errors.#{@markup}")
710
+ if File.exist?("#{filepath_prefix}app/views#{namespace_with_dash}/_errors.#{@markup}")
711
+ File.delete("#{filepath_prefix}app/views#{namespace_with_dash}/_errors.#{@markup}")
712
+ end
711
713
  end
712
714
 
713
715
  def spec_foreign_association_merge_hash
@@ -1050,14 +1052,14 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1050
1052
  end
1051
1053
 
1052
1054
  def all_views
1053
- res = %w(index _line _list _show _errors)
1055
+ res = %w(index _line _list _show)
1054
1056
 
1055
1057
  unless @no_create
1056
1058
  res += %w(new _new_form _new_button)
1057
1059
  end
1058
1060
 
1059
1061
  unless @no_edit
1060
- res << 'edit'
1062
+ res += %w{edit _edit}
1061
1063
  end
1062
1064
 
1063
1065
  if !( @no_edit && @no_create)
@@ -1257,4 +1259,22 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1257
1259
  def any_datetime_fields?
1258
1260
  (@columns - @attachments.keys.collect(&:to_sym)).collect{|col| eval("#{singular_class}.columns_hash['#{col}']").type}.include?(:datetime)
1259
1261
  end
1262
+
1263
+ def post_action_parental_updates
1264
+ if @nested_set.any?
1265
+ "\n" + @nested_set.collect{ |data|
1266
+ parent = data[:singular]
1267
+ "@#{singular}.#{parent}.reload"
1268
+ }.join("\n")
1269
+ end
1270
+ end
1271
+
1272
+
1273
+ def turbo_parental_updates
1274
+ @nested_set.collect{| data|
1275
+ "<%= turbo_stream.replace \"#{@namespace + '__' if @namespace}\#{dom_id(@#{data[:singular]})}\" do %>
1276
+ <%= render partial: \"#{@namespace}/#{data[:plural]}/edit\", locals: {#{data[:singular]}: @#{singular}.#{data[:singular]}.reload} %>
1277
+ <% end %>"
1278
+ }.join("\n")
1279
+ end
1260
1280
  end
@@ -57,8 +57,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
57
57
  def load_<%= singular_name %>
58
58
  <% if @nested_set[0] && @nested_set[0][:optional] %>if params.include?(:<%= @nested_set.last[:singular] %>_id)
59
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] %>
60
+ else <% end %>@<%= singular_name %> = <%= object_scope %>.find(params[:id])<% if @nested_set[0] && @nested_set[0][:optional] %>
62
61
  end<% end %>
63
62
  end
64
63
  <% else %>
@@ -93,6 +92,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
93
92
 
94
93
  if @<%= singular_name %>.save
95
94
  flash[:notice] = "Successfully created #{@<%= singular %>.<%= display_class %>}"
95
+ <%= post_action_parental_updates %>
96
96
  load_all_<%= plural %>
97
97
  render :create
98
98
  else
@@ -137,9 +137,10 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
137
137
  <% end %><% if destroy_action %> def destroy
138
138
  begin
139
139
  @<%=singular_name%>.destroy
140
+ flash[:notice] = '<%= singular_name.titlecase %> successfully deleted'
140
141
  rescue StandardError => e
141
- flash[:alert] = '<%= singular_name.titlecase %> could not be deleted.'
142
- end
142
+ flash[:alert] = '<%= singular_name.titlecase %> could not be deleted'
143
+ end <%= post_action_parental_updates %>
143
144
  load_all_<%= plural %>
144
145
  end<% end %>
145
146
 
@@ -0,0 +1,12 @@
1
+ <\%= turbo_frame_tag "<%= @namespace %>__#{dom_id(@<%= singular %>)}" do %>
2
+ <div class="cell editable" style="position: relative;">
3
+ <\% if @<%= singular %>.errors.any? %>
4
+ <\%= render(partial: "<%= namespace_with_trailing_dash %>errors", locals: {resource: @<%= singular %> }) %>
5
+ <\% end %>
6
+
7
+ <h2>Editing <\%= @<%= @singular %>.<%= display_class %> %></h2>
8
+ <\%= form_with model: <%= "@" + singular %>, url: <%= form_path_edit_helper %> do |f| %>
9
+ <\%= render partial: "form", locals: {:<%= singular %> => <%= "@" + singular%>, f: f}<%= @nested_set.collect{|arg| ".merge(@#{arg[:singular]} ? {#{arg[:singular]}: @#{arg[:singular]}} : {})" }.join %> \%>
10
+ <\% end %>
11
+ </div>
12
+ <\% end %>
@@ -1,12 +1,16 @@
1
1
  <%= turbo_frame_tag "flash_notices" do %>
2
- <% unless notice.nil? %>
3
- <div class="alert alert-notice alert-dismissible">
4
- <%= notice %>
5
- </div>
6
- <% end %>
7
- <% unless alert.nil? %>
8
- <div class="alert alert-danger alert-dismissible">
9
- <%= alert %>
2
+ <% unless notice.nil? && alert.nil? %>
3
+ <div class="alert alert-<%= alert ? 'danger' : 'primary' %> alert-dismissible">
4
+ <div><%= notice %></div>
5
+ <div><%= alert %></div>
6
+ <% if defined?(resource) && resource %>
7
+ <ul>
8
+ <% resource.errors.full_messages.each do |message| %>
9
+ <li><%= message %></li>
10
+ <% end %>
11
+ </ul>
12
+ <% end %>
13
+
10
14
  </div>
11
15
  <% end %>
12
16
  <% end %>
@@ -35,6 +35,6 @@
35
35
  <% end %>
36
36
 
37
37
  <% unless @no_edit %>
38
- <\%= link_to "Edit <i class='fa fa-1x fa-list-alt'></i>".html_safe, <%= edit_path_helper %>, <% if @big_edit %>'data-turbo' => 'false', <% end %>disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary btn-sm" %>
38
+ <\%= link_to "Edit <% if @button_icons == 'font-awesome' %><i class='fa fa-1x fa-list-alt'></i><% end %>".html_safe, <%= edit_path_helper %>, <% if @big_edit %>'data-turbo' => 'false', <% end %>disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary btn-sm" %>
39
39
  <% end %>
40
40
  </div>
@@ -3,6 +3,7 @@
3
3
  <\%= render partial: "list", locals: {<%= plural %>: @<%= plural %>}<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {nested_for: \"" + arg[:singular] + "-\#{@" + arg[:singular] + ".id}\"" + ", " + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> \%>
4
4
  <\% end %>
5
5
  <\% end %>
6
+ <%= turbo_parental_updates %>
6
7
  <\%= turbo_stream.replace "<%= @namespace %>__<%= singular %>__<%= singular %>-new" do %>
7
8
  <\% if @<%= singular %>.errors.none? %>
8
9
  <\%= render partial: "new_button", locals: {}<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {" + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> %>
@@ -11,8 +12,6 @@
11
12
  <\% end %>
12
13
  <\% end %>
13
14
  <\%= turbo_stream.replace "flash_notices" do %>
14
- <\%= render partial: "layouts/flash_notices" %>
15
- <\% if @<%= singular %>.errors.any? %>
16
- <\%= render partial: "errors", locals: {resource: @<%= singular %>} %>
17
- <\% end %>
15
+ <\%= render partial: "layouts/flash_notices", locals: {resource: @<%= singular %>} %>
16
+
18
17
  <\% end %>
@@ -1,3 +1,9 @@
1
- <\%= turbo_stream.replace "<%= @namespace %>__<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
1
+ <%= turbo_parental_updates %>
2
+
3
+ <\%= turbo_stream.update "<%= @namespace %>__<%= plural %>-list" + <%= nested_for_turbo_nested_constructor %> do %>
2
4
  <\%= render partial: "list", locals: {<%=plural%>: @<%=plural%> }<%= @nested_set.collect{|arg| ".merge(@" + arg[:singular] + " ? {nested_for: \"" + arg[:singular] + "-\#{@" + arg[:singular] + ".id}\"" + ", " + arg[:singular] + ": @" + arg[:singular] + "} : {})"}.join() %> \%>
3
5
  <\% end %>
6
+
7
+ <\%= turbo_stream.update "flash_notices" do %>
8
+ <\%= render partial: "layouts/flash_notices", locals: {resource: @<%= singular %>} %>
9
+ <\% end %>
@@ -4,18 +4,7 @@
4
4
  <div class="col-md-12">
5
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
6
  <% end %>
7
- <\%= turbo_frame_tag "<%= @namespace %>__#{dom_id(@<%= singular %>)}" do %>
8
- <div class="cell editable" style="position: relative;">
9
- <\% if @<%= singular %>.errors.any? %>
10
- <\%= render(partial: "<%= namespace_with_trailing_dash %>errors", locals: {resource: @<%= singular %> }) %>
11
- <\% end %>
12
-
13
- <h2>Editing <\%= @<%= @singular %>.<%= display_class %> %></h2>
14
- <\%= form_with model: <%= "@" + singular %>, url: <%= form_path_edit_helper %> do |f| %>
15
- <\%= render partial: "form", locals: {:<%= singular %> => <%= "@" + singular%>, f: f}<%= @nested_set.collect{|arg| ".merge(@#{arg[:singular]} ? {#{arg[:singular]}: @#{arg[:singular]}} : {})" }.join %> \%>
16
- <\% end %>
17
- </div>
18
- <\% end %>
7
+ <\%= render partial: "edit", locals: {<%= singular %>: @<%= singular %>} %>
19
8
  <% if @big_edit %>
20
9
  </div>
21
10
  </div>
@@ -4,10 +4,7 @@
4
4
  <\%= render partial: '<%= list_path_partial %>', locals: {<%= plural %>: @<%= plural %>}<%= @nested_set.collect{|arg| ".merge(@#{arg[:singular]} ? {#{arg[:singular]}: @#{arg[:singular]}} : {})" }.join %> \%>
5
5
  <\% end %>
6
6
  <% end %>
7
-
8
- <\%= turbo_stream.replace "flash_notices" do %>
9
- <\%= render partial: "layouts/flash_notices" %>
10
- <\% if @<%= singular %>.errors.any? %>
11
- <\%= render partial: "errors", locals: {resource: @<%= singular %>} %>
12
- <\% end %>
7
+ <%= turbo_parental_updates %>
8
+ <\%= turbo_stream.update "flash_notices" do %>
9
+ <\%= render partial: "layouts/flash_notices", locals: {resource: @<%= singular %>} %>
13
10
  <\% end %>
@@ -25,7 +25,7 @@ describe 'interaction for <%= controller_class_name %>' do
25
25
  describe "index" do
26
26
  it "should show me the list" do
27
27
  visit <%= path_helper_plural %>
28
- <%= @columns_map.collect{|col, col_object| col_object.spec_list_view_assertion } %>
28
+ <%= @columns_map.collect{|col, col_object| col_object.spec_list_view_assertion }.join("\n ") %>
29
29
  end
30
30
  end
31
31
 
data/lib/hot-glue.rb CHANGED
@@ -27,14 +27,17 @@ module HotGlue
27
27
  top_level: false,
28
28
  put_form: false)
29
29
  instance_sym = top_level ? "@" : ""
30
+
30
31
  if nested_set.nil? || nested_set.empty?
31
32
  return modifier + "#{(namespace + '_') if namespace}#{target}_path" + (("(#{instance_sym}#{target})" if put_form) || "")
32
33
  elsif nested_set[0][:optional] == false
34
+
33
35
  return modifier + ((namespace + "_" if namespace) || "") + nested_set.collect{|x|
34
36
  x[:singular] + "_"
35
37
  }.join() + target + "_path" + (("(#{nested_set.collect{
36
38
  |x| instance_sym + x[:singular] }.join(",")
37
- }#{ put_form ? ',' + instance_sym + target : '' })" if with_params) || "")
39
+ }#{ put_form ? ',' + instance_sym + target : '' })") || "")
40
+
38
41
 
39
42
  else
40
43
  # copy the first item, make a ternery in this cycle, and recursively move to both the
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.5.12'
3
+ CURRENT = '0.5.14'
4
4
  end
5
5
  end
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.12
4
+ version: 0.5.14
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-24 00:00:00.000000000 Z
11
+ date: 2023-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -92,6 +92,7 @@ files:
92
92
  - lib/generators/hot_glue/fields/text_field.rb
93
93
  - lib/generators/hot_glue/fields/time_field.rb
94
94
  - lib/generators/hot_glue/fields/uuid_field.rb
95
+ - lib/generators/hot_glue/flash_notices_install_generator.rb
95
96
  - lib/generators/hot_glue/hot_glue.rb
96
97
  - lib/generators/hot_glue/install_generator.rb
97
98
  - lib/generators/hot_glue/layout/builder.rb
@@ -106,7 +107,7 @@ files:
106
107
  - lib/generators/hot_glue/templates/capybara_login.rb
107
108
  - lib/generators/hot_glue/templates/computer_code.jpg
108
109
  - lib/generators/hot_glue/templates/controller.rb.erb
109
- - lib/generators/hot_glue/templates/erb/_errors.erb
110
+ - lib/generators/hot_glue/templates/erb/_edit.erb
110
111
  - lib/generators/hot_glue/templates/erb/_flash_notices.erb
111
112
  - lib/generators/hot_glue/templates/erb/_form.erb
112
113
  - lib/generators/hot_glue/templates/erb/_line.erb
@@ -121,21 +122,6 @@ files:
121
122
  - lib/generators/hot_glue/templates/erb/index.erb
122
123
  - lib/generators/hot_glue/templates/erb/new.erb
123
124
  - lib/generators/hot_glue/templates/erb/update.turbo_stream.erb
124
- - lib/generators/hot_glue/templates/haml/_errors.haml
125
- - lib/generators/hot_glue/templates/haml/_flash_notices.haml
126
- - lib/generators/hot_glue/templates/haml/_form.haml
127
- - lib/generators/hot_glue/templates/haml/_line.haml
128
- - lib/generators/hot_glue/templates/haml/_list.haml
129
- - lib/generators/hot_glue/templates/haml/_new_button.haml
130
- - lib/generators/hot_glue/templates/haml/_new_form.haml
131
- - lib/generators/hot_glue/templates/haml/_show.haml
132
- - lib/generators/hot_glue/templates/haml/create.turbo_stream.haml
133
- - lib/generators/hot_glue/templates/haml/destroy.turbo_stream.haml
134
- - lib/generators/hot_glue/templates/haml/edit.haml
135
- - lib/generators/hot_glue/templates/haml/edit.turbo_stream.haml
136
- - lib/generators/hot_glue/templates/haml/index.haml
137
- - lib/generators/hot_glue/templates/haml/new.haml
138
- - lib/generators/hot_glue/templates/haml/update.turbo_stream.haml
139
125
  - lib/generators/hot_glue/templates/javascript/dropzone_controller.js
140
126
  - lib/generators/hot_glue/templates/system_spec.rb.erb
141
127
  - lib/generators/hot_glue/templates/themes/hotglue_scaffold_dark_knight.scss
@@ -1,11 +0,0 @@
1
- <\%= turbo_frame_tag "errors" do %>
2
- <\% if resource.errors.any? %>
3
- <div id="error_explanation">
4
- <\% resource.errors.full_messages.each do |message| %>
5
- <div class="alert alert-danger">
6
- <\%= message %>
7
- </div>
8
- <\% end %>
9
- </div>
10
- <\% end %>
11
- <\% end %>
@@ -1,6 +0,0 @@
1
- = turbo_frame_tag "errors" do
2
- - if resource.errors.any?
3
- #error_explanation
4
- - resource.errors.full_messages.each do |message|
5
- %div.alert.alert-danger
6
- = message
@@ -1,8 +0,0 @@
1
- = turbo_frame_tag "flash_notices" do
2
- - unless notice.nil?
3
- %div.alert.alert-notice.alert-dismissible
4
- = notice
5
-
6
- - unless alert.nil?
7
- %div.alert.alert-danger.alert-dismissible
8
- = alert
@@ -1,5 +0,0 @@
1
- .row
2
- <%= form_fields_html %>
3
- .col
4
- = link_to "Cancel", <%= path_helper_plural %>, {class: "btn btn-secondary"}
5
- = f.submit "Save", class: "btn btn-primary pull-right"
@@ -1,6 +0,0 @@
1
- = turbo_frame_tag "<%= singular %>__#{<%= singular %>.id}" do
2
- .row{'data-id': <%= singular %>.id, 'data-edit': 'false'}
3
- = render partial: "<%= show_path_partial %>", locals: {<%= singular %>: <%= singular %> <%= nest_assignments_operator(false, true) %>}
4
-
5
-
6
-
@@ -1,15 +0,0 @@
1
- = turbo_frame_tag "<%= plural %>-list" do
2
- %div{class: "<%= @container_name %> <%= singular %>-table"}
3
- .row
4
- .col-md-12
5
- <%= '= render partial: "' + (@namespace+"/" if @namespace) + plural + '/new_button", locals: {' + nested_assignments + '}' unless @no_create %>
6
-
7
- .row
8
- <%= list_column_headings %>
9
- .col
10
- %div
11
- - if <%= plural %>.empty?
12
- None
13
- - <%= plural %>.each do |<%= singular %>|
14
- = render partial: '<%= line_path_partial %>', locals: {<%= singular %>: <%= singular %><%= nested_assignments_with_leading_comma if @nest %> }
15
- <%= @no_paginate ? "" : paginate %>
@@ -1,2 +0,0 @@
1
- = turbo_frame_tag "<%= singular %>-new" do
2
- = link_to "New <%= singular.titlecase %>", <%= new_path_name %>, disable_with: "Loading...", class: "new-<%= singular %>-button btn btn-primary pull-right"
@@ -1,7 +0,0 @@
1
- = turbo_frame_tag "<%= singular %>-new" do
2
- %h3
3
- New <%= singular.titlecase %>
4
-
5
- = form_with model: <%= singular %>, url: <%= path_helper_plural %>(<%= nested_objects_arity %>), method: "post" do |f|
6
- = render partial: "<%=namespace_with_slash%><%= @plural %>/form", locals: {<%= singular %>: <%= singular %>, f: f}
7
-
@@ -1,7 +0,0 @@
1
- <%= all_line_fields %>
2
- .col
3
- <% if destroy_action %>
4
- = link_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe, <%= path_helper_singular %>(<%= path_helper_args %>), method: :delete, data: {confirm: 'Are you sure?'}, disable_with: "Loading...", class: "delete-<%= singular %>-button btn btn-primary "
5
- <% end %>
6
- &nbsp;
7
- = link_to "Edit <i class='fa fa-1x fa-list-alt'></i>".html_safe, edit_<%= path_helper_singular %>(<%= path_helper_args %>), <% if @big_edit %>'data-turbo' => 'false', <% end %>disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary "
@@ -1,14 +0,0 @@
1
- - if @<%= singular %>.errors.none?
2
- = turbo_stream.replace "<%= plural %>-list" do
3
- = render partial: "list", locals: {<%= plural %>: @<%= plural %> <%= nest_assignments_operator(true, true) %>}
4
-
5
- = turbo_stream.replace "<%= singular %>-new" do
6
- - if @<%= singular %>.errors.none?
7
- = render partial: "new_button", locals: {<%= nest_assignments_operator(true, false) %> }
8
- - else
9
- = render partial: "new_form", locals: {<%= singular %>: @<%= singular %> <%= nest_assignments_operator(true, true) %>}
10
-
11
- = turbo_stream.replace "flash_notices" do
12
- = render partial: "layouts/flash_notices"
13
- - if @<%= singular %>.errors.any?
14
- = render partial: "errors", locals: {resource: @<%= singular %>}
@@ -1,2 +0,0 @@
1
- = turbo_stream.replace "<%=plural%>-list" do
2
- = render partial: "list", locals: {<%=plural%>: @<%=plural%> <%= nest_assignments_operator(true, true) %>}
@@ -1,19 +0,0 @@
1
- = link_to "<i class='fa fa-arrow-circle-left 2x'></i> Back to list".html_safe, <%= path_helper_plural %>
2
-
3
- = turbo_frame_tag "<%= singular %>__#{<%= "@" + singular %>.id}" do
4
- .cell.editable{style: "position: relative;"}
5
- - if <%="@" + singular%>.errors.any?
6
- = render(partial: "#{controller.namespace}errors", locals: {resource: <%="@" + singular%>})
7
-
8
-
9
- Editing
10
- - if <%="@" + singular%>.try(:to_label)
11
- = <%="@" + singular%>.to_label
12
- - elsif <%="@" + singular%>.try(:name)
13
- = <%="@" + singular%>.name
14
- - else
15
- (no name)
16
-
17
- = form_with model: <%= "@" + singular%>, url: <%= path_helper_singular %>(<%= path_arity %>) do |f|
18
- = render partial: "form", locals: {:<%= singular %> => <%= "@" + singular%>, f: f}
19
-
@@ -1,4 +0,0 @@
1
-
2
- = turbo_stream.replace "<%= singular%>__#{@<%= singular %>.id}" do
3
- = render 'edit'
4
-
@@ -1,8 +0,0 @@
1
- %div{class: "#{@container_name }"}
2
- .row
3
- .col-md-12
4
- .clearfix
5
- = render partial: "<%= list_path_partial %>", locals: {<%= plural %>: @<%= plural %> <%= nest_assignments_operator(true, true) %>}
6
-
7
-
8
-
@@ -1 +0,0 @@
1
- = render partial: "new_form", locals: {<%=singular%>: @<%=singular%>}
@@ -1,9 +0,0 @@
1
-
2
- = turbo_stream.replace "<%= singular%>__#{@<%= singular %>.id}" do
3
- = render partial: 'line', locals: {<%= singular %>: @<%= singular %> <%= nested_assignments_with_leading_comma %> }
4
-
5
-
6
- = turbo_stream.replace "flash_notices" do
7
- = render partial: "layouts/flash_notices"
8
- - if @<%= singular %>.errors.any?
9
- = render partial: "errors", locals: {resource: @<%= singular %>}