hot-glue 0.5.21 → 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: 34d4899a5495270c4364848ad5e61527141d1f2b869e3e55c24efb6c63865ac9
4
- data.tar.gz: 1a97496b55af910b3c14ead50c92205e0e8ed7c6d75330050041a8e9c6aa4df7
3
+ metadata.gz: e2d92541aa687117c64a4a52b034f9103f06f95ae7996bcbd1cf7f71f986ec34
4
+ data.tar.gz: 751619956a66052dc837b4f13ab85cbe3fe655b60c8ad820150b7e21f3737696
5
5
  SHA512:
6
- metadata.gz: 9aea82f09683d50f8e4175777fff16ef07da0682055cbe3ee29f3da3360a2b8763cfc079afe15c69f3e05f3b4dd33d063b63aa483c5e32ad60c2ac20da305f65
7
- data.tar.gz: e3ec284bdb6d2d7d1030502fc45858c55afaf82e97fda92fd0bcb7359a7f54315a360aacd9bfd7e23da56dff08541ed0f120f2bc071faab950990688b40fb2ea
6
+ metadata.gz: f5c4dfb35d0a673cc6f8b8a4b3833feafa7fca86a0e07d616b825c11c3c132af98fde4ec4a73ef9538f9f74a0982f38c2fceb562c1ca43f72764ad7d604bb864
7
+ data.tar.gz: f520ab73bebb9597e5cc4cc3651e4ef45641641157f99353c79abf7004cf9340b59d8222e2a1462d51b269bfef62e3c725732c962d21185bfc0f62f87dcc5a51
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.5.20)
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
@@ -1404,6 +1404,13 @@ end
1404
1404
 
1405
1405
  # VERSION HISTORY
1406
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
1407
1414
 
1408
1415
  #### 2023-09-18 - v0.5.21
1409
1416
  - Removes `@` symbols using instance variables in `_edit` partials and in the enum syntax
@@ -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
@@ -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,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.5.21'
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.21
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-18 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