effective_resources 1.8.12 → 1.8.17

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: b61bac97524b1592c39a8b701f2c7bb0af87f9c5e882e75cbd1c2144e2284c38
4
- data.tar.gz: 5c3d1674d1cdec588970c5358f307399c24d177300f04f81ffd8fde5e8b1e916
3
+ metadata.gz: 0162db8b9e57f6f0289551a07214bbba02f4154d8786fa38a92e51c023317f17
4
+ data.tar.gz: b993410fb958c5efa5a8d281a8def12f8b1e02c209e56ba9835d283a0e33ef44
5
5
  SHA512:
6
- metadata.gz: 9ffaaa83f17ee7dc3865da68bb1e3dbc7c9416fe68fd77c106cc51f1e9d23691cd35e1017f23428534d2001b897220d19b8daa0f27a96a004b29b8ef04aa8c91
7
- data.tar.gz: 315828b2d06aa231f15dbae213f5dfcbc9e5721c53786e17aa10ee87d6e574f83c026c383f6f1782c08415df087b8d7a2fc7ccea828e56444cc2b173bf795bab
6
+ metadata.gz: a8d89ebcead9ac5fee2263e5dc6fe83703a103f7daa6e3501a53fdc169b14a0adc65176a46b8fa7ac3310e348afce0b805fe007d14c48a07d38811bdad2f7f6c
7
+ data.tar.gz: 8f59af5c2225dce3a7378317688f53a4ce79b6db2502f10cd0632b605e9ad5c02c21eba28ec45d8b428c1e1e9ba229d976c4bc1b9a944cfdbf27771f988cde95
@@ -15,7 +15,16 @@ module Effective
15
15
 
16
16
  format.js do
17
17
  flash[:success] ||= resource_flash(:success, resource, action)
18
- render(action, locals: { remote_form_redirect: resource_redirect_path(resource, action)}) # action.js.erb
18
+
19
+ if params[:_datatable_action]
20
+ redirect_to(resource_redirect_path(resource, action))
21
+ else
22
+ render(
23
+ (template_present?(action) ? action : :member_action),
24
+ locals: { action: action, remote_form_redirect: resource_redirect_path(resource, action)}
25
+ )
26
+ end
27
+
19
28
  end
20
29
  end
21
30
  elsif template_present?(action)
@@ -46,9 +46,9 @@ module Effective
46
46
  end
47
47
  end
48
48
 
49
- def resource_wizard_step_title(step)
49
+ def resource_wizard_step_title(resource, step)
50
50
  return if step == 'wicked_finish'
51
- effective_resource.klass.const_get(:WIZARD_STEPS).fetch(step)
51
+ resource.wizard_step_title(step)
52
52
  end
53
53
 
54
54
  def resource_wizard_steps
@@ -8,7 +8,7 @@ module Effective
8
8
  self.resource ||= resource_scope.new
9
9
  EffectiveResources.authorize!(self, :new, resource)
10
10
 
11
- redirect_to resource_wizard_path(:new, resource_wizard_steps.first)
11
+ redirect_to resource_wizard_path(:new, resource.first_uncompleted_step || resource_wizard_steps.first)
12
12
  end
13
13
 
14
14
  def show
@@ -49,7 +49,7 @@ module Effective
49
49
  Rails.logger.info " Unable to visit step :#{step}. Last can_visit_step? is :#{next_step}. Change the acts_as_wizard model's can_visit_step?(step) function to change this."
50
50
  end
51
51
 
52
- flash[:success] = "You have been redirected to the #{resource_wizard_step_title(next_step)} step."
52
+ flash[:success] = "You have been redirected to the #{resource_wizard_step_title(resource, next_step)} step."
53
53
  redirect_to wizard_path(next_step)
54
54
  end
55
55
 
@@ -66,7 +66,7 @@ module Effective
66
66
  # before_action :assign_page_title, only: [:show, :update]
67
67
  # Assign page title
68
68
  def assign_page_title
69
- @page_title ||= resource_wizard_step_title(step)
69
+ @page_title ||= resource_wizard_step_title(resource, step)
70
70
  end
71
71
 
72
72
  end
@@ -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 ||= next_step
12
+ @skip_to ||= resource.required_steps.find { |s| s == next_step } || resource.first_uncompleted_step
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))
@@ -116,7 +116,6 @@ module EffectiveResourcesHelper
116
116
  locals = {
117
117
  resource: resource,
118
118
  effective_resource: effective_resource,
119
- formats: [:html],
120
119
  format_block: (block if block_given?),
121
120
  namespace: namespace,
122
121
  actions: actions,
@@ -133,7 +132,7 @@ module EffectiveResourcesHelper
133
132
  spacer_template: spacer_template
134
133
  )
135
134
  else
136
- render(partial, locals)
135
+ render(partial: partial, formats: [:html], locals: locals)
137
136
  end
138
137
  end
139
138
 
@@ -20,7 +20,7 @@ module EffectiveResourcesWizardHelper
20
20
  def render_wizard_sidebar_item(resource, nav_step, index = nil)
21
21
  # From Controller
22
22
  current = (nav_step == step)
23
- title = resource_wizard_step_title(nav_step)
23
+ title = resource_wizard_step_title(resource, nav_step)
24
24
 
25
25
  # From Model
26
26
  disabled = !resource.can_visit_step?(nav_step)
@@ -43,6 +43,7 @@ module ActsAsWizard
43
43
  wizard_steps[current_step.to_sym] ||= Time.zone.now
44
44
  end
45
45
 
46
+ # Use can_visit_step? required_steps and wizard_step_title(step) to control the wizard behaviour
46
47
  def can_visit_step?(step)
47
48
  can_revisit_completed_steps(step)
48
49
  end
@@ -52,6 +53,10 @@ module ActsAsWizard
52
53
  self.class.const_get(:WIZARD_STEPS).keys
53
54
  end
54
55
 
56
+ def wizard_step_title(step)
57
+ self.class.const_get(:WIZARD_STEPS).fetch(step)
58
+ end
59
+
55
60
  def first_completed_step
56
61
  required_steps.find { |step| has_completed_step?(step) }
57
62
  end
@@ -78,8 +78,20 @@ module Effective
78
78
  # acpa/admin/shirts
79
79
  (names.length).downto(1).each do |n|
80
80
  names.combination(n).to_a.each do |pieces|
81
- klass_pieces = pieces.map { |piece| piece.classify } * '::'
82
- klass = klass_pieces.safe_constantize
81
+ klass = begin
82
+ klass_pieces = pieces.map { |piece| piece.classify } * '::'
83
+ klass_pieces.safe_constantize
84
+ end
85
+
86
+ klass ||= if pieces.length > 1
87
+ klass_pieces = ([pieces.first.classify] + pieces[1..-1].map { |piece| piece.classify }) * '::'
88
+ klass_pieces.safe_constantize
89
+ end
90
+
91
+ klass ||= if pieces.length > 1
92
+ klass_pieces = ([pieces.first.classify.pluralize] + pieces[1..-1].map { |piece| piece.classify }) * '::'
93
+ klass_pieces.safe_constantize
94
+ end
83
95
 
84
96
  if klass.present? && klass.class != Module
85
97
  @namespaces ||= (names - pieces)
@@ -31,14 +31,14 @@ module Effective
31
31
  end
32
32
 
33
33
  def route_name_fallbacks
34
- mod = class_name.split('::').first.downcase
34
+ mod = class_name.split('::').first.to_s.downcase
35
35
 
36
36
  matches = [
37
37
  route_name.singularize,
38
38
  [*namespace, plural_name].join('/'),
39
39
  [*namespace, name].join('/'),
40
- [mod, *namespace, plural_name].join('/'),
41
- [mod, *namespace, name].join('/')
40
+ [*mod, *namespace, plural_name].join('/'),
41
+ [*mod, *namespace, name].join('/')
42
42
  ]
43
43
  end
44
44
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.8.12'.freeze
2
+ VERSION = '1.8.17'.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.12
4
+ version: 1.8.17
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-04-14 00:00:00.000000000 Z
11
+ date: 2021-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails