effective_resources 1.8.11 → 1.8.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/effective/crud_controller.rb +4 -0
- data/app/controllers/concerns/effective/crud_controller/respond.rb +1 -4
- data/app/controllers/concerns/effective/flash_messages.rb +4 -4
- data/app/controllers/concerns/effective/wizard_controller.rb +2 -2
- data/app/controllers/concerns/effective/wizard_controller/actions.rb +1 -1
- data/app/controllers/concerns/effective/wizard_controller/before_actions.rb +2 -2
- data/app/helpers/effective_resources_helper.rb +1 -2
- data/app/helpers/effective_resources_wizard_helper.rb +1 -1
- data/app/models/concerns/acts_as_wizard.rb +6 -1
- data/app/models/effective/resources/init.rb +14 -2
- data/app/models/effective/resources/naming.rb +3 -3
- data/lib/effective_resources/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a854fdf544ea77faf7d45b251f8161b54ef66685c71730d6b4bdef42298ac371
|
4
|
+
data.tar.gz: 22d0141d18a049ed853d2ba54197758e46817ffdf6704c1facee7850cad5bef6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa64174fb405b2499a303ed87d64b8e32aa4d7c48388875c811919526935679a4c98bfef973e0f41b2124257b5d9d46207e906f85776d5eb5c0bf487ee086179
|
7
|
+
data.tar.gz: e00c2e31e5430de0a3e19d2f0d607fa73426edbbe8f7d31c0936f60a418a4bf92206fef2d904d2ba78dab1bfffc132235056ad138ede924642cabdeffd8a6408
|
@@ -27,7 +27,6 @@ module Effective
|
|
27
27
|
|
28
28
|
format.js do
|
29
29
|
flash.now[:success] ||= resource_flash(:success, resource, action)
|
30
|
-
#reload_resource unless action == :destroy # Removed.
|
31
30
|
render(action) # action.js.erb
|
32
31
|
end
|
33
32
|
end
|
@@ -96,9 +95,7 @@ module Effective
|
|
96
95
|
end
|
97
96
|
|
98
97
|
def template_present?(action)
|
99
|
-
|
100
|
-
|
101
|
-
formats = [request.format.symbol.to_s.sub('json', 'js').presence || 'html']
|
98
|
+
formats = [(request.format.symbol.to_s.sub('json', 'js').presence || 'html').to_sym]
|
102
99
|
lookup_context.template_exists?(action, _prefixes, formats: formats)
|
103
100
|
end
|
104
101
|
|
@@ -9,9 +9,9 @@ module Effective
|
|
9
9
|
raise 'expected an ActiveRecord resource' unless (name || resource.class.respond_to?(:model_name))
|
10
10
|
|
11
11
|
name ||= if resource.respond_to?(:destroyed?) && resource.destroyed?
|
12
|
-
|
12
|
+
resource_human_name
|
13
13
|
else
|
14
|
-
resource.to_s.presence
|
14
|
+
resource.to_s.presence || resource_human_name
|
15
15
|
end
|
16
16
|
|
17
17
|
"Successfully #{action_verb(action)} #{name || 'resource'}".html_safe
|
@@ -27,9 +27,9 @@ module Effective
|
|
27
27
|
messages = flash_errors(resource, e: e)
|
28
28
|
|
29
29
|
name ||= if resource.respond_to?(:destroyed?) && resource.destroyed?
|
30
|
-
|
30
|
+
resource_human_name
|
31
31
|
else
|
32
|
-
resource.to_s.presence
|
32
|
+
resource.to_s.presence || resource_human_name
|
33
33
|
end
|
34
34
|
|
35
35
|
["Unable to #{action}", (" #{name}" if name), (": #{messages}" if messages)].compact.join.html_safe
|
@@ -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
|
-
|
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
|
@@ -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
|
@@ -65,7 +70,7 @@ module ActsAsWizard
|
|
65
70
|
end
|
66
71
|
|
67
72
|
def has_completed_step?(step)
|
68
|
-
wizard_steps[step].present?
|
73
|
+
(errors.present? ? wizard_steps_was : wizard_steps)[step].present?
|
69
74
|
end
|
70
75
|
|
71
76
|
def next_step
|
@@ -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
|
-
|
82
|
-
|
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
|
|
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.
|
4
|
+
version: 1.8.16
|
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-
|
11
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|