effective_resources 1.18.1 → 1.18.4

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: c0c85319423568e1dd19b9b1055bdd0c320bed118398156cc6cf8e8891c6d116
4
- data.tar.gz: 6f9729378c464d1de1fcd1556dc33c5591374efccee47e14044d99f278ff6ca9
3
+ metadata.gz: 52171b7c3dbc8a5221069508aaaa10bc8bf4b42df0b854213340fe05380bc42d
4
+ data.tar.gz: 1ac01b5683863cef99f255b2db462308b7057eba78461a6b0f97ef5795efc04f
5
5
  SHA512:
6
- metadata.gz: 11cedc4d9ee5dce6389bcb9e3505e6638abd6ef3ffefe2383f3ea91ea95cf1eff76c02185c563b3b595e4e0ee808828cd1f3bf6d8f758fef287b7437a9c45f45
7
- data.tar.gz: d3a9a54642101af184239b0cb63c33c8a9d66431061da366f1d8dbdd99ec70d2f645248aa5f7de3e235d2c77b7cf2675b8d46168a5c2da782ac937f47853d58e
6
+ metadata.gz: 6d47cee77bd3f791c5b93d98d9fb7066259b3d9949924bbd284e2dac2caa263895497a2361082fecd47ec0a7a0f10c9e22bd5d53f0d9c46bd1ba24e2f524010d
7
+ data.tar.gz: 1f9870c37a8140e9a6d38b45d84f65649ff18f57b86d5c4817b9ca0204457d0c731edcfd8d836f19793eeef3561b63a50c2f86e4c0e70f6ef230ff9867df0d19
@@ -262,4 +262,32 @@ module EffectiveResourcesHelper
262
262
  controller.class.try(:effective_wizard_controller?) && defined?(resource) && resource.draft?
263
263
  end
264
264
 
265
+ def wizard_card(resource, &block)
266
+ raise('expected a block') unless block_given?
267
+ raise('expected an acts_as_wizard resource') unless resource.class.respond_to?(:acts_as_wizard?)
268
+
269
+ step = resource.render_step
270
+ raise('expected a render_step') unless step.present?
271
+
272
+ title = resource.wizard_step_title(step)
273
+ raise("expected a title for step #{step}") unless title.present?
274
+
275
+ link = if edit_effective_wizard? && resource.can_visit_step?(step)
276
+ link_to('Edit', wizard_path(step), title: "Edit #{title}")
277
+ end
278
+
279
+ content_tag(:div, class: 'card') do
280
+ content_tag(:div, class: 'card-body yo') do
281
+ content_tag(:div, class: 'row') do
282
+ content_tag(:div, class: 'col-sm') do
283
+ content_tag(:h5, title, class: 'card-title')
284
+ end +
285
+ content_tag(:div, class: 'col-sm-auto text-right') do
286
+ (link || '')
287
+ end
288
+ end + capture(&block)
289
+ end
290
+ end
291
+ end
292
+
265
293
  end
@@ -6,7 +6,7 @@ module EffectiveResourcesWizardHelper
6
6
  klasses = ['wizard-sidebar', 'list-group', ('list-group-horizontal' if horizontal)].compact.join(' ')
7
7
 
8
8
  sidebar = content_tag(:div, class: klasses) do
9
- resource.required_steps.map.with_index do |nav_step, index|
9
+ resource.sidebar_steps.map.with_index do |nav_step, index|
10
10
  render_wizard_sidebar_item(resource, nav_step, (index + 1 if numbers))
11
11
  end.join.html_safe
12
12
  end
@@ -28,7 +28,10 @@ module ActsAsTokened
28
28
  def find(*args)
29
29
  return super unless args.length == 1
30
30
  return super if block_given?
31
- return find_by_id(args.first) if @_effective_reloading
31
+
32
+ if self.class.instance_variable_get(:@_effective_reloading) || (respond_to?(:klass) && klass.instance_variable_get(:@_effective_reloading))
33
+ return find_by_id(args.first)
34
+ end
32
35
 
33
36
  find_by_token(args.first) || raise(::ActiveRecord::RecordNotFound.new("Couldn't find #{name} with 'token'=#{args.first}"))
34
37
  end
@@ -29,6 +29,9 @@ module ActsAsWizard
29
29
 
30
30
  attr_accessor :current_user
31
31
 
32
+ # Used by the view when rendering each partial. Not the current step.
33
+ attr_accessor :render_step
34
+
32
35
  if Rails.env.test? # So our tests can override the required_steps method
33
36
  cattr_accessor :test_required_steps
34
37
  end
@@ -75,6 +78,10 @@ module ActsAsWizard
75
78
  steps
76
79
  end
77
80
 
81
+ def sidebar_steps
82
+ required_steps
83
+ end
84
+
78
85
  # For use in the summary partials. Does not include summary.
79
86
  def render_steps
80
87
  blacklist = [:start, :billing, :checkout, :submitted, :summary]
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.18.1'.freeze
2
+ VERSION = '1.18.4'.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.18.1
4
+ version: 1.18.4
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: 2022-06-24 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails