effective_resources 1.8.27 → 1.8.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49b0e10cdea6482347d89604f85458147fe74f06ecbf0085a3ed9b8a2b68ecdd
4
- data.tar.gz: dcfc9bd5423907bf6a5cd9b4a1a1ac191ea49bd774033a51d209064de38db017
3
+ metadata.gz: 2cac8ab4956bad6e580c5edfe77d2040d13430b327acff13874f0d447e2cb154
4
+ data.tar.gz: 9d2aeb097b2a71715aec44af86b49628549c0083ecd757f742047ae17842207b
5
5
  SHA512:
6
- metadata.gz: b5795d6c0d9565e2df3777b51ca4a074cbb1aa9eeef0f68f7a16914319dcf4860456c576548be7496af848272d3f4c579fe03057a5c126db2b89f0a621670f03
7
- data.tar.gz: fb53b1dc820211022a2ba9c4730613c94ae40aa5c7dfdcdf216e5a92930001a7ae032fc77ae3b81e39f718f995f8cdadc72f7a4a31b9da380ceaa2aaf64a42b6
6
+ metadata.gz: c04ecb8170f56016f354a93dd1be925ac08cef0f9dc77b93027457fa30b3382907943083877f47daa6dc000e700be9594a69e52a69fe63a0846a1d988413876c
7
+ data.tar.gz: 73e362b25cc6acbc6c9abf0c8e8c87ad1a9b19d4a2d4c4e5f0a21cdc9f4071e8084ec15685fcb29a8d96bd1d9241c36f4d2569c79244247c3df8cd77eca2c333
data/README.md CHANGED
@@ -352,6 +352,8 @@ Here's `views/things/start.html.haml`:
352
352
 
353
353
  You can also call `render_wizard_sidebar(resource)` without the block syntax.
354
354
 
355
+ If you add `f.hidden_field(:skip_to_step, value: 'stepc')` you can control the next step.
356
+
355
357
  ## Testing
356
358
 
357
359
  Run tests by:
@@ -5,10 +5,13 @@ module Effective
5
5
  def new
6
6
  Rails.logger.info 'Processed by Effective::WizardController#new'
7
7
 
8
- self.resource ||= resource_scope.new
8
+ self.resource ||= (find_wizard_resource || resource_scope.new)
9
9
  EffectiveResources.authorize!(self, :new, resource)
10
10
 
11
- redirect_to resource_wizard_path(:new, resource.first_uncompleted_step || resource_wizard_steps.first)
11
+ redirect_to resource_wizard_path(
12
+ (resource.to_param || :new),
13
+ (resource.first_uncompleted_step || resource_wizard_steps.first)
14
+ )
12
15
  end
13
16
 
14
17
  def show
@@ -9,7 +9,7 @@ module Effective
9
9
  if save_resource(resource, action)
10
10
  flash[:success] ||= options.delete(:success) || resource_flash(:success, resource, action)
11
11
 
12
- @skip_to ||= resource.required_steps.find { |s| s == next_step } || resource.first_uncompleted_step
12
+ @skip_to ||= skip_to_step(resource)
13
13
  @redirect_to ||= resource_wizard_path(resource, @skip_to) if was_new_record
14
14
 
15
15
  redirect_to(@redirect_to || wizard_path(@skip_to))
@@ -19,6 +19,14 @@ module Effective
19
19
  end
20
20
  end
21
21
 
22
+ private
23
+
24
+ def skip_to_step(resource)
25
+ resource.skip_to_step ||
26
+ resource.required_steps.find { |s| s == next_step } ||
27
+ resource.first_uncompleted_step
28
+ end
29
+
22
30
  end
23
31
  end
24
32
  end
@@ -59,6 +59,8 @@ module EffectiveResourcesHelper
59
59
  # locals: {} render locals
60
60
  # you can also pass all action names and true/false such as edit: true, show: false
61
61
  def render_resource_actions(resource, atts = {}, &block)
62
+ return ''.html_safe if resource.blank?
63
+
62
64
  unless resource.kind_of?(ActiveRecord::Base) || resource.kind_of?(Class) || resource.kind_of?(Array) || resource.class.ancestors.include?(ActiveModel::Model)
63
65
  raise 'expected first argument to be an ActiveRecord::Base object or Array of objects'
64
66
  end
@@ -25,6 +25,8 @@ module ActsAsWizard
25
25
  acts_as_wizard_options = @acts_as_wizard_options
26
26
 
27
27
  attr_accessor :current_step
28
+ attr_accessor :skip_to_step
29
+
28
30
  attr_accessor :current_user
29
31
 
30
32
  if Rails.env.test? # So our tests can override the required_steps method
@@ -39,9 +39,9 @@ module HasManyRichTexts
39
39
  end
40
40
 
41
41
  def method_missing(method, *args, &block)
42
- method = method.to_s
43
- super unless method.start_with?('rich_text_')
42
+ return super unless method.to_s.start_with?('rich_text_')
44
43
 
44
+ method = method.to_s
45
45
  name = method.chomp('=').sub('rich_text_', '')
46
46
 
47
47
  if method.end_with?('=')
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.8.27'.freeze
2
+ VERSION = '1.8.31'.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: 1.8.27
4
+ version: 1.8.31
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: 2021-06-21 00:00:00.000000000 Z
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails