effective_resources 0.8.9 → 0.8.10
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: 7c8bdc84abf94942e54c5007aedf0d5ed6258473
|
4
|
+
data.tar.gz: b4cee9fb014e4a40ba1cdbba3d1caee1e45cf084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eefe5e914263f9fe5da1c41362d1c67b7289db996a19b86b5cc51edb67848ab07cdfcfa3ce049c7a38d3b85b2fcfd2901c9d6a7eba51aa31de8e0141ab975f56
|
7
|
+
data.tar.gz: 0b37485ef2faca4106f55b81cac1fb8966854c75f9fa8faf31ca1ca8d05d2e8f7b3ba3634ee34ed3a3c2403ea33f5c98475c27759138def3dd7cf7001540d8bd
|
@@ -324,29 +324,52 @@ module Effective
|
|
324
324
|
end
|
325
325
|
end
|
326
326
|
|
327
|
-
# No attributes are assigned or saved. We purely call action! on the resource.
|
328
327
|
def member_post_action(action)
|
329
328
|
raise 'expected post, patch or put http action' unless (request.post? || request.patch? || request.put?)
|
330
329
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
330
|
+
# TODO: This is a recent change. Used to not assign attributes. Is this breaking?
|
331
|
+
valid_params = (send(resource_params_method_name) rescue {})
|
332
|
+
resource.assign_attributes(valid_params)
|
333
|
+
|
334
|
+
respond_to do |format|
|
335
|
+
if save_resource(resource, action)
|
336
|
+
format.html do
|
337
|
+
flash[:success] ||= resource_flash(:success, resource, action)
|
338
|
+
redirect_to(resource_redirect_path)
|
339
|
+
end
|
340
|
+
|
341
|
+
format.js do
|
342
|
+
if specific_redirect_path?(action)
|
343
|
+
flash[:success] ||= resource_flash(:success, resource, action)
|
344
|
+
redirect_to(resource_redirect_path)
|
345
|
+
else
|
346
|
+
flash.now[:success] ||= resource_flash(:success, resource, action)
|
347
|
+
reload_resource
|
348
|
+
# action.js.erb
|
349
|
+
end
|
350
|
+
end
|
346
351
|
else
|
347
|
-
|
348
|
-
flash[:danger]
|
349
|
-
|
352
|
+
flash.delete(:success)
|
353
|
+
flash.now[:danger] ||= resource_flash(:danger, resource, action)
|
354
|
+
|
355
|
+
format.html do
|
356
|
+
if resource_edit_path && (referer_redirect_path || '').end_with?(resource_edit_path)
|
357
|
+
@page_title ||= "Edit #{resource}"
|
358
|
+
render :edit
|
359
|
+
elsif resource_new_path && (referer_redirect_path || '').end_with?(resource_new_path)
|
360
|
+
@page_title ||= "New #{resource_name.titleize}"
|
361
|
+
render :new
|
362
|
+
elsif resource_show_path && (referer_redirect_path || '').end_with?(resource_show_path)
|
363
|
+
@page_title ||= resource_name.titleize
|
364
|
+
render :show
|
365
|
+
else
|
366
|
+
@page_title ||= resource.to_s
|
367
|
+
flash[:danger] = flash.now[:danger]
|
368
|
+
redirect_to(referer_redirect_path || resource_redirect_path)
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
format.js {} # action.js.erb
|
350
373
|
end
|
351
374
|
end
|
352
375
|
end
|
@@ -544,8 +567,15 @@ module Effective
|
|
544
567
|
{ action: :save }
|
545
568
|
end
|
546
569
|
|
547
|
-
def
|
548
|
-
|
570
|
+
def submit_action(action)
|
571
|
+
self.class.submits[action.to_s] ||
|
572
|
+
self.class.submits.find { |_, v| v[:action] == action }&.last ||
|
573
|
+
{ action: action }
|
574
|
+
end
|
575
|
+
|
576
|
+
def specific_redirect_path?(action = nil)
|
577
|
+
submit = (action.nil? ? commit_action : submit_action(action))
|
578
|
+
(submit[:redirect].respond_to?(:call) ? instance_exec(&submit[:redirect]) : submit[:redirect]).present?
|
549
579
|
end
|
550
580
|
|
551
581
|
# Returns an ActiveRecord relation based on the computed value of `resource_scope` dsl method
|