effective_resources 2.9.0 → 2.9.1

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: 10642ec990cb0ad6b2426415a997aead2f5d53bcdb8a932b3f276af5e9485af9
4
- data.tar.gz: a971535ad4974d3931be497db3595f91e1baac7483f718e3197778e84674e525
3
+ metadata.gz: e271cc3c7cc6656818fa8584765872c44add6e05f45aebf71b21a2463d27975e
4
+ data.tar.gz: b96b045469f418016cbef1d000eec3ee3b82b260122eff4a6f160e689f55f0b1
5
5
  SHA512:
6
- metadata.gz: c8ee4692a6b49d21cfe3d591233f9991355cb1d4d3697d5317fceb7186eb9011db71edef3dc8b6ddedc8ba97d3d28b7c7cf80bf753c18a31b344c8cbc7393db1
7
- data.tar.gz: 7cfa99b30169c1bb0bc316dafdc29bad35996b678affea7f21e9ab6fe469bdf4dd6a3fe013d028b8e8fb4cd4281aa809640477db683e3cb0d987bc40d62375b5
6
+ metadata.gz: b065909664f6d3dfd6cdb6589023dcd743b77feeccf2d98e74ef940780c5a48492681915437975aa7bd988251d768367d50b00f8198de841642af7728425eec7
7
+ data.tar.gz: 44e79e8885d98c26b5179955f60cc7b775efac0d7804712e4d5556b20df09fc00d6efad0f9db8e40a0e61c959fc355ec5cf7b7314dcec80aceb0f476932fd9a3
@@ -185,8 +185,10 @@ module Effective
185
185
  respond_to do |format|
186
186
  format.html { }
187
187
  format.js do
188
+ html_template = action if template_present?(action, format: :html)
188
189
  template = template_present?(action) ? action : 'member_action'
189
- render(template, formats: :js, locals: { action: action })
190
+
191
+ render(template, formats: :js, locals: { action: action, html_template: html_template })
190
192
  end
191
193
  end
192
194
 
@@ -103,9 +103,10 @@ module Effective
103
103
  flash[:danger] ||= danger
104
104
  end
105
105
 
106
- def template_present?(action)
106
+ def template_present?(action, format: nil)
107
+ format = Array(format).presence
107
108
  formats = [(request.format.symbol.to_s.sub('json', 'js').presence || 'html').to_sym]
108
- lookup_context.template_exists?(action, _prefixes, formats: formats)
109
+ lookup_context.template_exists?(action, _prefixes, formats: (format || formats))
109
110
  end
110
111
 
111
112
  end
@@ -189,13 +189,15 @@ module EffectiveResourcesHelper
189
189
  safe = atts.delete(:safe)
190
190
  atts = { :namespace => (effective_resource.namespace.to_sym if effective_resource.namespace), effective_resource.name.to_sym => resource }.compact.merge(atts)
191
191
 
192
- if lookup_context.template_exists?(effective_resource.name, controller._prefixes, :partial)
193
- return render(effective_resource.name, atts)
192
+ partial = (action.present? ? action.to_s : effective_resource.name)
193
+
194
+ if lookup_context.template_exists?(partial, controller._prefixes, :partial)
195
+ return render(partial, atts)
194
196
  end
195
197
 
196
198
  effective_resource.view_paths.each do |view_path|
197
- if lookup_context.template_exists?(effective_resource.name, [view_path], :partial)
198
- return render(view_path + '/' + effective_resource.name, atts)
199
+ if lookup_context.template_exists?(partial, [view_path], :partial)
200
+ return render(view_path + '/' + partial, atts)
199
201
  end
200
202
  end
201
203
 
@@ -146,10 +146,16 @@ module ActsAsWizard
146
146
  has_completed_step?(required_steps.last)
147
147
  end
148
148
 
149
- def reset_wizard_steps!
149
+ def reset_all_wizard_steps!
150
150
  update!(wizard_steps: {})
151
151
  end
152
152
 
153
+ def complete_all_wizard_steps!
154
+ now = Time.zone.now
155
+ required_steps.each { |step| wizard_steps[step] ||= now }
156
+ save!
157
+ end
158
+
153
159
  def without_current_step(&block)
154
160
  existing = current_step
155
161
 
@@ -1,7 +1,12 @@
1
1
  <% resource = (@_effective_resource || Effective::Resource.new(controller_path)) %>
2
2
  <% @resource = instance_variable_get('@' + resource.name) if resource.name %>
3
3
 
4
- EffectiveForm.remote_form_payload = "<%= j render_resource_form(@resource, action: action, safe: true) %>";
4
+ <% if html_template.present? %>
5
+ EffectiveForm.remote_form_payload = "<%= j(render_resource_partial(@resource, action: action)) %>";
6
+ <% else %>
7
+ EffectiveForm.remote_form_payload = "<%= j(render_resource_form(@resource, action: action, safe: true).presence || render_resource_partial(@resource)) %>";
8
+ <% end %>
9
+
5
10
  EffectiveForm.remote_form_commit = "<%= params[:commit] %>";
6
11
  EffectiveForm.remote_form_flash = <%= raw flash.to_json %>;
7
12
 
@@ -46,10 +46,8 @@ module EffectiveResources
46
46
  app.config.to_prepare do
47
47
  if defined?(CanCan::Ability)
48
48
  CanCan::Ability.module_eval do
49
- CRUD_ACTIONS = [:index, :new, :create, :edit, :update, :show, :destroy]
50
-
51
49
  def crud
52
- CRUD_ACTIONS
50
+ [:index, :new, :create, :edit, :update, :show, :destroy]
53
51
  end
54
52
  end
55
53
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.9.0'.freeze
2
+ VERSION = '2.9.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-16 00:00:00.000000000 Z
11
+ date: 2023-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails