effective_resources 1.0.11 → 1.0.12
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60db7705f1fb377c10d9bd981079ce1eea482636
|
4
|
+
data.tar.gz: f05b029bd2600fddbb9871b248d94b704617a35d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5acca8d4926d6cec59a2cffbbe521fb5abb873cb7e2559952ef9964d6832f9990984ade64711768d0ff412b6b61a2b8a3fbf5e149f9a19f7d32efaa90a022886
|
7
|
+
data.tar.gz: 92d3bf93a553331231c93c6f40d54dad32132d642fa0c62ab3421a382917c7e784c1233edea43a9651a81c9db190c587715266efcf12ff1de388feac7d322eb2
|
@@ -5,6 +5,7 @@ module Effective
|
|
5
5
|
include Effective::CrudController::Actions
|
6
6
|
include Effective::CrudController::Paths
|
7
7
|
include Effective::CrudController::PermittedParams
|
8
|
+
include Effective::CrudController::Respond
|
8
9
|
include Effective::CrudController::Save
|
9
10
|
include Effective::CrudController::Submits
|
10
11
|
|
@@ -75,25 +75,9 @@ module Effective
|
|
75
75
|
|
76
76
|
respond_to do |format|
|
77
77
|
if save_resource(resource, action)
|
78
|
-
|
79
|
-
|
80
|
-
format.html do
|
81
|
-
flash[:success] ||= resource_flash(:success, resource, action)
|
82
|
-
redirect_to(resource_redirect_path(action))
|
83
|
-
end
|
84
|
-
|
85
|
-
format.js do
|
86
|
-
flash.now[:success] ||= resource_flash(:success, resource, action)
|
87
|
-
reload_resource # create.js.erb
|
88
|
-
end
|
78
|
+
respond_with_success(format, resource, action)
|
89
79
|
else
|
90
|
-
|
91
|
-
flash.now[:danger] ||= resource_flash(:danger, resource, action)
|
92
|
-
|
93
|
-
run_callbacks(:resource_render)
|
94
|
-
|
95
|
-
format.html { render :new }
|
96
|
-
format.js {} # create.js.erb
|
80
|
+
respond_with_error(format, resource, action)
|
97
81
|
end
|
98
82
|
end
|
99
83
|
end
|
@@ -139,25 +123,9 @@ module Effective
|
|
139
123
|
|
140
124
|
respond_to do |format|
|
141
125
|
if save_resource(resource, action)
|
142
|
-
|
143
|
-
|
144
|
-
format.html do
|
145
|
-
flash[:success] ||= resource_flash(:success, resource, action)
|
146
|
-
redirect_to(resource_redirect_path(action))
|
147
|
-
end
|
148
|
-
|
149
|
-
format.js do
|
150
|
-
flash.now[:success] ||= resource_flash(:success, resource, action)
|
151
|
-
reload_resource # update.js.erb
|
152
|
-
end
|
126
|
+
respond_with_success(format, resource, action)
|
153
127
|
else
|
154
|
-
|
155
|
-
flash.now[:danger] ||= resource_flash(:danger, resource, action)
|
156
|
-
|
157
|
-
run_callbacks(:resource_render)
|
158
|
-
|
159
|
-
format.html { render :edit }
|
160
|
-
format.js { } # update.js.erb
|
128
|
+
respond_with_error(format, resource, action)
|
161
129
|
end
|
162
130
|
end
|
163
131
|
end
|
@@ -177,17 +145,7 @@ module Effective
|
|
177
145
|
|
178
146
|
respond_to do |format|
|
179
147
|
if save_resource(resource, action)
|
180
|
-
|
181
|
-
|
182
|
-
format.html do
|
183
|
-
flash[:success] ||= resource_flash(:success, resource, action)
|
184
|
-
redirect_to(resource_redirect_path(action))
|
185
|
-
end
|
186
|
-
|
187
|
-
format.js do
|
188
|
-
flash.now[:success] ||= resource_flash(:success, resource, action)
|
189
|
-
# destroy.js.erb
|
190
|
-
end
|
148
|
+
respond_with_success(format, resource, action)
|
191
149
|
else
|
192
150
|
flash.delete(:success)
|
193
151
|
request.format = :html # Don't run destroy.js.erb
|
@@ -217,18 +175,7 @@ module Effective
|
|
217
175
|
|
218
176
|
respond_to do |format|
|
219
177
|
if save_resource(resource, action)
|
220
|
-
|
221
|
-
|
222
|
-
format.html do
|
223
|
-
flash[:success] ||= resource_flash(:success, resource, action)
|
224
|
-
redirect_to(resource_redirect_path(action))
|
225
|
-
end
|
226
|
-
|
227
|
-
format.js do
|
228
|
-
flash.now[:success] ||= resource_flash(:success, resource, action)
|
229
|
-
reload_resource
|
230
|
-
render_member_action(action)
|
231
|
-
end
|
178
|
+
respond_with_success(format, resource, action) || render_member_action(action)
|
232
179
|
else
|
233
180
|
flash.delete(:success)
|
234
181
|
flash.now[:danger] ||= resource_flash(:danger, resource, action)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Effective
|
2
|
+
module CrudController
|
3
|
+
module Respond
|
4
|
+
def respond_with_success(format, resource, action)
|
5
|
+
if specific_redirect_path?
|
6
|
+
format.html do
|
7
|
+
flash[:success] ||= resource_flash(:success, resource, action)
|
8
|
+
redirect_to(resource_redirect_path(action))
|
9
|
+
end
|
10
|
+
|
11
|
+
format.js do
|
12
|
+
flash[:success] ||= resource_flash(:success, resource, action)
|
13
|
+
redirect_to(resource_redirect_path(action))
|
14
|
+
end
|
15
|
+
|
16
|
+
return true
|
17
|
+
end
|
18
|
+
|
19
|
+
# Render template if it exists
|
20
|
+
if lookup_context.template_exists?(action, _prefixes)
|
21
|
+
format.html do
|
22
|
+
flash.now[:success] ||= resource_flash(:success, resource, action)
|
23
|
+
# action.html.haml
|
24
|
+
end
|
25
|
+
|
26
|
+
format.js do
|
27
|
+
flash.now[:success] ||= resource_flash(:success, resource, action)
|
28
|
+
reload_resource
|
29
|
+
# action.js.erb
|
30
|
+
end
|
31
|
+
|
32
|
+
return false
|
33
|
+
end
|
34
|
+
|
35
|
+
# Default
|
36
|
+
format.html do
|
37
|
+
flash[:success] ||= resource_flash(:success, resource, action)
|
38
|
+
redirect_to(resource_redirect_path(action))
|
39
|
+
end
|
40
|
+
|
41
|
+
format.js do
|
42
|
+
flash[:success] ||= resource_flash(:success, resource, action)
|
43
|
+
redirect_to(resource_redirect_path(action))
|
44
|
+
end
|
45
|
+
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
def respond_with_error(format, resource, action)
|
50
|
+
flash.delete(:success)
|
51
|
+
flash.now[:danger] ||= resource_flash(:danger, resource, action)
|
52
|
+
|
53
|
+
run_callbacks(:resource_render)
|
54
|
+
|
55
|
+
case params[:action]
|
56
|
+
when 'create'
|
57
|
+
format.html { render :new }
|
58
|
+
when 'update'
|
59
|
+
format.html { render :edit }
|
60
|
+
else
|
61
|
+
format.html { render action }
|
62
|
+
end
|
63
|
+
|
64
|
+
format.js {}
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
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.0.
|
4
|
+
version: 1.0.12
|
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: 2018-11-
|
11
|
+
date: 2018-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- app/controllers/concerns/effective/crud_controller/dsl.rb
|
41
41
|
- app/controllers/concerns/effective/crud_controller/paths.rb
|
42
42
|
- app/controllers/concerns/effective/crud_controller/permitted_params.rb
|
43
|
+
- app/controllers/concerns/effective/crud_controller/respond.rb
|
43
44
|
- app/controllers/concerns/effective/crud_controller/save.rb
|
44
45
|
- app/controllers/concerns/effective/crud_controller/submits.rb
|
45
46
|
- app/controllers/concerns/effective/flash_messages.rb
|