effective_resources 1.8.29 → 1.8.33

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: 01eb0c185b86003c4c06095cab5e141ab7e279479af13a8660409319f3e3bfc5
4
- data.tar.gz: 2095122951bc3d297f385fb26f833847f91317bfc2106bb727ceacf7b78149da
3
+ metadata.gz: 60cb47028d5031c44e6a833fd1750d6e9435ace75de88ffec3756378079ba13c
4
+ data.tar.gz: 9ceb601f1fdf5ab0784abe83b6f7d8071f66e079d7c5a3c7352dee0dda9b1abb
5
5
  SHA512:
6
- metadata.gz: 1cfa1f47ff8341bdeddbdca8cdb2ca6e7d977c726f363d3ad0f292e06eb43d17dbbd242629958ea7c5dd58347fbf66bc75ac48572b51e4ae7fd320a34542dacf
7
- data.tar.gz: 0cdafa9339dfdefdcff7a8142b5e98ad6e9d48987b3508ee44076aa34ecd434f0f4388d5ac73b7a45609928dd0e94ac2b20e89063df32d08b278827170392f3e
6
+ metadata.gz: 9fe4309ff79c01a66217aee696f3bfa45d11d429d7a3dad84977351be8e0f9efd1091b6bc8398fcc46d131cc69a57d2251a2b365ddbd7fd4f0a4576c51ba6a5f
7
+ data.tar.gz: a88750936ed0d46ee4a8faa8a591fbd04dd9eef2eeedaa7f36c01a80bbeaff72690eed324974cdbaf12ed68b2f156ea91058c5250d5b415e80040f4edf0d9060
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
@@ -62,5 +62,19 @@ module Effective
62
62
  wizard_path(step, resource_name_id => param)
63
63
  end
64
64
 
65
+ private
66
+
67
+ def current_step_before?(nav_step)
68
+ index = wizard_steps.index(nav_step) || raise("step #{nav_step} not found in wizard_steps")
69
+ current = wizard_steps.index(step) || raise("current step not found in wizard_steps")
70
+ current < index
71
+ end
72
+
73
+ def current_step_after?(nav_step)
74
+ index = wizard_steps.index(nav_step) || raise("step #{nav_step} not found in wizard_steps")
75
+ current = wizard_steps.index(step) || raise("current step not found in wizard_steps")
76
+ current > index
77
+ end
78
+
65
79
  end
66
80
  end
@@ -2,8 +2,10 @@
2
2
 
3
3
  module EffectiveResourcesWizardHelper
4
4
 
5
- def render_wizard_sidebar(resource, numbers: true, &block)
6
- sidebar = content_tag(:div, class: 'nav list-group wizard-sidebar') do
5
+ def render_wizard_sidebar(resource, numbers: true, horizontal: false, &block)
6
+ klasses = ['wizard-sidebar', 'list-group', ('list-group-horizontal' if horizontal)].compact.join(' ')
7
+
8
+ sidebar = content_tag(:div, class: klasses) do
7
9
  resource.required_steps.map.with_index do |nav_step, index|
8
10
  render_wizard_sidebar_item(resource, nav_step, (index + 1 if numbers))
9
11
  end.join.html_safe
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # This module automatically generates slugs based on the :to_s field using a before_validation filter
4
4
  #
5
- # Mark your model with 'acts_as_sluggable' make sure you have a string field :slug
5
+ # Mark your model with 'acts_as_slugged' make sure you have a string field :slug
6
6
 
7
7
  module ActsAsSlugged
8
8
  extend ActiveSupport::Concern
@@ -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
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.8.29'.freeze
2
+ VERSION = '1.8.33'.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.29
4
+ version: 1.8.33
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-09-24 00:00:00.000000000 Z
11
+ date: 2021-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails