hot-glue 0.5.20 → 0.5.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48857d455006404276d88ee9481b21664a413e14403f8432a26cb13fc4351f4a
4
- data.tar.gz: d15f7a0d742a7164e0f58c4bd25a620198efed8106c7e36bfeea1a34251d4889
3
+ metadata.gz: e2d92541aa687117c64a4a52b034f9103f06f95ae7996bcbd1cf7f71f986ec34
4
+ data.tar.gz: 751619956a66052dc837b4f13ab85cbe3fe655b60c8ad820150b7e21f3737696
5
5
  SHA512:
6
- metadata.gz: 916d29b5b2f60c273bf9d0094511d95b39b54f8d57c3b41c251d17dc9b7f918914a6ca529f4eca000461fa7c2b4e2b36f954fb3ee59f0fda8a8ed53038c773e0
7
- data.tar.gz: cbddef65679e3dd42d18143d964f3a9ad9ccb25490bfc054d8fd73f23c24d0a74751a8e07c96fc5404792bb6fe553b2d70a6f6fc168ceaf4a39247d96a4d360e
6
+ metadata.gz: f5c4dfb35d0a673cc6f8b8a4b3833feafa7fca86a0e07d616b825c11c3c132af98fde4ec4a73ef9538f9f74a0982f38c2fceb562c1ca43f72764ad7d604bb864
7
+ data.tar.gz: f520ab73bebb9597e5cc4cc3651e4ef45641641157f99353c79abf7004cf9340b59d8222e2a1462d51b269bfef62e3c725732c962d21185bfc0f62f87dcc5a51
data/Gemfile CHANGED
@@ -24,7 +24,7 @@ gem "sprockets-rails"
24
24
  gem "importmap-rails"
25
25
  gem "stimulus-rails"
26
26
  gem "turbo-rails"
27
- gem "byebug"
27
+
28
28
 
29
29
  gem "puma", "~> 5.0"
30
30
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.5.19.2)
4
+ hot-glue (0.5.22)
5
5
  ffaker (~> 2.16)
6
6
  kaminari (~> 1.2)
7
7
  rails (> 5.1)
data/README.md CHANGED
@@ -909,6 +909,14 @@ Omits new & create actions.
909
909
 
910
910
  Omits delete button & destroy action.
911
911
 
912
+ ### `--no-controller`
913
+
914
+ Omits controller.
915
+
916
+ ### `--no-list`
917
+
918
+ Omits list views.
919
+
912
920
  ### `--big-edit`
913
921
 
914
922
  If you do not want inline editing of your list items but instead want to fall back to full page style behavior for your edit views, use `--big-edit`. Turbo still handles the page interactions, but the user is taken to a full-screen edit page instead of an edit-in-place interaction.
@@ -1396,6 +1404,21 @@ end
1396
1404
 
1397
1405
  # VERSION HISTORY
1398
1406
 
1407
+ #### 2023-09-20- v0.5.22
1408
+ - adds back magic button tap-away params in the controller
1409
+ - changes creation of flash[:notice] in update method
1410
+ - adds pundit authorization for edit action in the edit method itself
1411
+ - adds a crude show method that redirects to the edit (Hot Glue takes the opinionated stance that show routes should not really exist. This addition makes it so that when the user is on the show route and re-loads the browse window, they don't see a route error)
1412
+ - adds RuboCop detection; omits the regen code at the top of the controller from line length cop
1413
+ - fixes for specs
1414
+
1415
+ #### 2023-09-18 - v0.5.21
1416
+ - Removes `@` symbols using instance variables in `_edit` partials and in the enum syntax
1417
+ - fixes in system_spec.rb.erb
1418
+ - Adds flags --no-controller --no-list
1419
+ - adds regen code to a file in the views folder REGENERATE.md if you have set --no-controller
1420
+
1421
+
1399
1422
  #### 2023-09-08 - v0.5.20
1400
1423
  `--pundit` authorization
1401
1424
  • Will look for a `XyzPolicy` class and method on your class named `*_able?` matching the fields on your object. See Pundit section for details.
@@ -104,7 +104,7 @@ class AssociationField < Field
104
104
  end
105
105
 
106
106
  (is_owner ? "<% unless @#{assoc_name} %>\n" : "") +
107
- " <%= f.collection_select(:#{name}, #{hawked_association}, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{name} }, class: 'form-control') %>\n" +
107
+ " <%= f.collection_select(:#{name}, #{hawked_association}, :id, :#{display_column}, {prompt: true, selected: #{singular}.#{name} }, class: 'form-control') %>\n" +
108
108
  (is_owner ? "<% else %>\n <%= @#{assoc_name}.#{display_column} %>" : "") +
109
109
  (is_owner ? "\n<% end %>" : "")
110
110
  end
@@ -43,6 +43,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
43
43
  class_option :no_create, type: :boolean, default: false
44
44
  class_option :no_edit, type: :boolean, default: false
45
45
  class_option :no_list, type: :boolean, default: false
46
+ class_option :no_controller, type: :boolean, default: false
47
+ class_option :no_list, type: :boolean, default: false
46
48
  class_option :no_paginate, type: :boolean, default: false
47
49
  class_option :big_edit, type: :boolean, default: false
48
50
  class_option :show_only, type: :string, default: ""
@@ -289,6 +291,8 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
289
291
 
290
292
  @no_edit = options['no_edit'] || false
291
293
  @no_list = options['no_list'] || false
294
+ @no_controller = options['no_controller'] || false
295
+ @no_list = options['no_list'] || false
292
296
  @no_list_label = options['no_list_label'] || false
293
297
  @no_list_heading = options['no_list_heading'] || false
294
298
  @stacked_downnesting = options['stacked_downnesting']
@@ -688,7 +692,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
688
692
 
689
693
  def copy_controller_and_spec_files
690
694
  @default_colspan = @columns.size
691
- unless @specs_only
695
+ unless @specs_only || @no_controller
692
696
  template "controller.rb.erb", File.join("#{filepath_prefix}app/controllers#{namespace_with_dash}", "#{@controller_build_folder}_controller.rb")
693
697
  if @namespace
694
698
  begin
@@ -866,7 +870,7 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
866
870
  nested_set: @nested_set,
867
871
  with_params: true,
868
872
  put_form: true,
869
- top_level: true)
873
+ top_level: false)
870
874
  end
871
875
 
872
876
  def delete_path_helper
@@ -1021,6 +1025,11 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1021
1025
 
1022
1026
  def copy_view_files
1023
1027
  return if @specs_only
1028
+
1029
+ if @no_controller
1030
+ File.write("#{Rails.root}/app/views/#{namespace_with_trailing_dash}/#{plural}/REGENERATE.md", regenerate_me_code)
1031
+ end
1032
+
1024
1033
  all_views.each do |view|
1025
1034
  formats.each do |format|
1026
1035
  source_filename = cc_filename_with_extensions("#{@markup}/#{view}", "#{@markup}")
@@ -1120,6 +1129,11 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1120
1129
  if !(@no_edit && @no_create)
1121
1130
  res << '_form'
1122
1131
  end
1132
+
1133
+ if @no_list
1134
+ res -= %w{_list _line index}
1135
+ end
1136
+
1123
1137
  res
1124
1138
  end
1125
1139
 
@@ -1,6 +1,8 @@
1
1
  class <%= controller_class_name %> < <%= controller_descends_from %>
2
2
  # regenerate this controller with
3
- # <%= regenerate_me_code %>
3
+ <% if defined?(RuboCop) %># rubocop:disable Layout/LineLength
4
+ <% end %># <%= regenerate_me_code %><% if defined?(RuboCop) %>
5
+ # rubocop:enable Layout/LineLength <% end %>
4
6
 
5
7
  helper :hot_glue
6
8
  include HotGlue::ControllerHelper
@@ -70,7 +72,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
70
72
  authorize @<%= plural_name %>.all<% else %> <% if !@self_auth %>
71
73
  @<%= plural_name %> = <%= object_scope.gsub("@",'') %>.page(params[:page])<%= n_plus_one_includes %><%= " if params.include?(:#{ @nested_set.last[:singular]}_id)" if @nested_set.any? && @nested_set[0] && @nested_set[0][:optional] %><% if @nested_set[0] && @nested_set[0][:optional] %>
72
74
  @<%= plural_name %> = <%= class_name %>.all<% end %><% else %>
73
- @<%= plural_name %> = <%= class_name %>.where(id: <%= auth_object.gsub("@",'') %>.id)<%= n_plus_one_includes %> # returns iterable even though this <%= singular_name %> is only allowed access to themselves<% end %>
75
+ @<%= plural_name %> = <%= class_name %>.where(id: <%= auth_object.gsub("@",'') %>.id)<%= n_plus_one_includes %><% end %>
74
76
  <% end %>
75
77
  end
76
78
 
@@ -121,7 +123,18 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
121
123
  end
122
124
 
123
125
  <% end %>
124
- <% unless @no_edit %> def edit
126
+ <% unless @no_edit %>
127
+ def show
128
+ redirect_to <%= HotGlue.optionalized_ternary(namespace: @namespace,
129
+ target: @singular,
130
+ nested_set: @nested_set,
131
+ modifier: "edit_",
132
+ with_params: true,
133
+ put_form: true).gsub("(#{singular}", "(@#{singular}") %>
134
+ end
135
+
136
+ def edit<% if @pundit %>
137
+ authorize @<%= singular_name %><% end %>
125
138
  render :edit<% if @pundit %>
126
139
  rescue Pundit::NotAuthorizedError
127
140
  flash[:alert] = "Editing #{@<%= singular %>.<%= display_class %>} not authorized."
@@ -129,12 +142,18 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
129
142
  end
130
143
 
131
144
  <% end %><% if @build_update_action %> def update
145
+ flash[:notice] = ""
146
+ flash[:alert] = nil
132
147
  <% 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|
133
148
  " #{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"
134
149
  }.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(",") %>
135
- <% @magic_buttons.each { |button| %>@<%= singular_name %>.<%= button %>! if <%= singular_name %>_params[:__<%= button %>]
136
- <% } %>
137
- modified_params = modify_date_inputs_on_params(<% if @update_show_only %>update_<% end %><%= singular_name %>_params.dup<%= controller_update_params_tap_away_alt_lookups %>, <%= current_user_object %>, <%= datetime_fields_list %>) <% if @object_owner_sym && eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>
150
+ <% @magic_buttons.each do |button| %>
151
+ if <%= singular_name %>_params[:__<%= button %>]
152
+ @<%= singular_name %>.<%= button %>!
153
+ flash[:notice] << "<% singular %> <%= button.titlecase %>."
154
+ end
155
+ <% end %>
156
+ modified_params = modify_date_inputs_on_params(<% if @update_show_only %>update_<% end %><%= singular_name %>_params.dup<%= controller_update_params_tap_away_alt_lookups %><%= controller_update_params_tap_away_magic_buttons %>, <%= current_user_object %>, <%= datetime_fields_list %>) <% if @object_owner_sym && eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>
138
157
  modified_params = modified_params.merge(<%= @object_owner_sym %>: <%= @object_owner_eval %>) <% elsif @object_owner_optional && any_nested? %>
139
158
  modified_params = modified_params.merge(<%= @object_owner_name %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}) <% elsif !@object_owner_eval.empty? %>
140
159
  modified_params = modified_params.merge(<%= @object_owner_eval %>) <% end %><% if !merge_lookups.empty? %>
@@ -158,11 +177,11 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
158
177
  if @<%= singular_name %>.update(modified_params)
159
178
  <% end %>
160
179
  <% if @display_list_after_update %> load_all_<%= plural %><% end %>
161
- flash[:notice] = "#{flash[:notice]} Saved #{@<%= singular %>.<%= display_class %>}"
180
+ flash[:notice] << "Saved #{@<%= singular %>.<%= display_class %>}"
162
181
  flash[:alert] = @hawk_alarm if @hawk_alarm
163
182
  render :update
164
183
  else
165
- flash[:alert] = "#{flash[:notice]} <%= singular_name.titlecase %> could not be saved. #{@hawk_alarm}"
184
+ flash[:alert] = "<%= singular_name.titlecase %> could not be saved. #{@hawk_alarm}"
166
185
  render :update, status: :unprocessable_entity
167
186
  end<% if @pundit %>
168
187
  rescue Pundit::NotAuthorizedError
@@ -1,12 +1,11 @@
1
- <\%= turbo_frame_tag "<%= @namespace %>__#{dom_id(@<%= singular %>)}" do %>
1
+ <\%= turbo_frame_tag "<%= @namespace %>__#{dom_id(<%= singular %>)}" do %>
2
2
  <div class="cell editable" style="position: relative;">
3
- <\% if @<%= singular %>.errors.any? %>
4
- <\%= render(partial: "<%= namespace_with_trailing_dash %>errors", locals: {resource: @<%= singular %> }) %>
3
+ <\% if <%= singular %>.errors.any? %>
4
+ <\%= render(partial: "<%= namespace_with_trailing_dash %>errors", locals: {resource: <%= singular %> }) %>
5
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: "<%= namespace_with_trailing_dash + @controller_build_folder + "/" %>form", locals: {:<%= singular %> => <%= "@" + singular%>, f: f}<%= @nested_set.collect{|arg| ".merge(@#{arg[:singular]} ? {#{arg[:singular]}: @#{arg[:singular]}} : {})" }.join %> \%>
6
+ <h2>Editing <\%= <%= singular %>.<%= display_class %> %></h2>
7
+ <\%= form_with model: <%= singular %>, url: <%= form_path_edit_helper %> do |f| %>
8
+ <\%= render partial: "<%= namespace_with_trailing_dash + @controller_build_folder + "/" %>form", locals: {:<%= singular %> => <%= singular %>, f: f}<%= @nested_set.collect{|arg| ".merge(#{arg[:singular]} ? {#{arg[:singular]}: #{arg[:singular]}} : {})" }.join %> \%>
10
9
  <\% end %>
11
10
  </div>
12
11
  <\% end %>
@@ -15,7 +15,7 @@ describe 'interaction for <%= controller_class_name %>' do
15
15
  <% unless @god %>let(:<%= @auth %>) {create(:<%= @auth.gsub('current_', '') %>)}<% end %>
16
16
  <%= spec_related_column_lets %>
17
17
  let!(:<%= singular %>1) {create(:<%= singular %><%= object_parent_mapping_as_argument_for_specs %> <%= item1_addOns %> )}
18
- <%= objest_nest_factory_setup %> <% unless @god || @existing_content.include?("login_as")%>
18
+ <%= objest_nest_factory_setup %> <% unless @god || (@existing_content && @existing_content.include?("login_as")) %>
19
19
  before do
20
20
  login_as(<%= @auth %>)
21
21
  end <% end %> <% if any_datetime_fields? %>
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.5.20'
3
+ CURRENT = '0.5.22'
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.20
4
+ version: 0.5.22
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-09-08 00:00:00.000000000 Z
11
+ date: 2023-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails