effective_resources 2.20.0 → 2.20.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d425bc9d1bc016b9979350a67a3dbeb8432d292bf627efcf5c01ac0512587b24
|
4
|
+
data.tar.gz: 678f168202e93a74102a713b39a57de79531c7c9cc36ac3f5e9b210657749592
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad93fbed04f488d6ba4061d9db1cc72e75831fbf083949576365d6046af692a3149f28aa4361285f37dbc4099a221a17777232a3263156a218394e4283b75137
|
7
|
+
data.tar.gz: c2ba9f5df09a3ad3bb6693d8501bbe11c1c53576d68b844e9fab620d92531847ccd172a81bf2881ec571acc44cabb944f7bffa81508c7e143c532accb25bf497
|
@@ -69,6 +69,29 @@ module Effective
|
|
69
69
|
root_path
|
70
70
|
end
|
71
71
|
|
72
|
+
def resource_redirect_error_path(resource, action)
|
73
|
+
submit = commit_action(action)
|
74
|
+
redirect = submit[:redirect_error].respond_to?(:call) ? instance_exec(&submit[:redirect_error]) : submit[:redirect_error]
|
75
|
+
|
76
|
+
# If we have a specific redirect for it
|
77
|
+
commit_action_redirect = case redirect
|
78
|
+
when :index ; resource_index_path
|
79
|
+
when :edit ; resource_edit_path
|
80
|
+
when :show ; resource_show_path
|
81
|
+
when :new ; resource_new_path
|
82
|
+
when :duplicate ; resource_duplicate_path
|
83
|
+
when :back ; referer_redirect_path
|
84
|
+
when :save ; [resource_edit_path, resource_show_path].compact.first
|
85
|
+
when Symbol ; resource_action_path(redirect)
|
86
|
+
when String ; redirect
|
87
|
+
else ; nil
|
88
|
+
end
|
89
|
+
|
90
|
+
return commit_action_redirect if commit_action_redirect.present?
|
91
|
+
|
92
|
+
resource_redirect_path(resource, action)
|
93
|
+
end
|
94
|
+
|
72
95
|
def referer_redirect_path
|
73
96
|
url = request.referer.to_s
|
74
97
|
|
@@ -96,6 +119,11 @@ module Effective
|
|
96
119
|
(submit[:redirect].respond_to?(:call) ? instance_exec(&submit[:redirect]) : submit[:redirect]).present?
|
97
120
|
end
|
98
121
|
|
122
|
+
def specific_redirect_error_path?(action = nil)
|
123
|
+
submit = commit_action(action)
|
124
|
+
(submit[:redirect_error].respond_to?(:call) ? instance_exec(&submit[:redirect_error]) : submit[:redirect_error]).present?
|
125
|
+
end
|
126
|
+
|
99
127
|
def resource_index_path
|
100
128
|
effective_resource.action_path(:index)
|
101
129
|
end
|
@@ -60,35 +60,49 @@ module Effective
|
|
60
60
|
flash.delete(:success)
|
61
61
|
flash.now[:danger] ||= resource_flash(:danger, resource, action)
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
when :create
|
66
|
-
format.html { render :new }
|
67
|
-
when :update
|
68
|
-
format.html { render :edit }
|
69
|
-
when :destroy
|
63
|
+
if specific_redirect_error_path?(action)
|
64
|
+
respond_to do |format|
|
70
65
|
format.html do
|
71
66
|
redirect_flash
|
72
|
-
redirect_to(
|
67
|
+
redirect_to(resource_redirect_error_path(resource, action))
|
73
68
|
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
69
|
+
|
70
|
+
format.js do
|
71
|
+
view = template_present?(action) ? action : :member_action
|
72
|
+
render(view, locals: { action: action }) # action.js.erb
|
73
|
+
end
|
74
|
+
end
|
75
|
+
else
|
76
|
+
respond_to do |format| # Default
|
77
|
+
case action_name.to_sym
|
78
|
+
when :create
|
80
79
|
format.html { render :new }
|
81
|
-
|
80
|
+
when :update
|
81
|
+
format.html { render :edit }
|
82
|
+
when :destroy
|
82
83
|
format.html do
|
83
84
|
redirect_flash
|
84
85
|
redirect_to(resource_redirect_path(resource, action))
|
85
86
|
end
|
87
|
+
else
|
88
|
+
if template_present?(action)
|
89
|
+
format.html { render(action, locals: { action: action }) }
|
90
|
+
elsif request.referer.to_s.end_with?('/edit')
|
91
|
+
format.html { render :edit }
|
92
|
+
elsif request.referer.to_s.end_with?('/new')
|
93
|
+
format.html { render :new }
|
94
|
+
else
|
95
|
+
format.html do
|
96
|
+
redirect_flash
|
97
|
+
redirect_to(resource_redirect_path(resource, action))
|
98
|
+
end
|
99
|
+
end
|
86
100
|
end
|
87
|
-
end
|
88
101
|
|
89
|
-
|
90
|
-
|
91
|
-
|
102
|
+
format.js do
|
103
|
+
view = template_present?(action) ? action : :member_action
|
104
|
+
render(view, locals: { action: action }) # action.js.erb
|
105
|
+
end
|
92
106
|
end
|
93
107
|
end
|
94
108
|
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: 2.20.
|
4
|
+
version: 2.20.1
|
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: 2024-04-
|
11
|
+
date: 2024-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|