effective_resources 2.19.13 → 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: 5c3b294943394c17234dc15366796c5f67b89f6dd040d054ee864fdbfc462e9a
4
- data.tar.gz: c3c8654723ffbd11ad5756d051e9bf1d810acf071defb65155410ef42e5eb917
3
+ metadata.gz: d425bc9d1bc016b9979350a67a3dbeb8432d292bf627efcf5c01ac0512587b24
4
+ data.tar.gz: 678f168202e93a74102a713b39a57de79531c7c9cc36ac3f5e9b210657749592
5
5
  SHA512:
6
- metadata.gz: a6c58fe8690a02c8f843cf6843ae98ff892a4f79c374e9a1c843307e9a0a732e4f2a2edae5021c64c25784f27731ded2d8f6a96209795e942d97f50f851b10af
7
- data.tar.gz: 7e01d7dc9735a2fbb6c21816ae737f680131cc91daf560b814034f606fb27d6c93248f5e7517d40b13eee6bc2ae9150a5864c4d9f821ee31e9ef11cfa2d94806
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
- respond_to do |format|
64
- case action_name.to_sym
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(resource_redirect_path(resource, action))
67
+ redirect_to(resource_redirect_error_path(resource, action))
73
68
  end
74
- else
75
- if template_present?(action)
76
- format.html { render(action, locals: { action: action }) }
77
- elsif request.referer.to_s.end_with?('/edit')
78
- format.html { render :edit }
79
- elsif request.referer.to_s.end_with?('/new')
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
- else
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
- format.js do
90
- view = template_present?(action) ? action : :member_action
91
- render(view, locals: { action: action }) # action.js.erb
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
@@ -262,9 +262,9 @@ module EffectiveDeviseUser
262
262
  (respond_to?(:archived?) && archived?) ? :archived : super
263
263
  end
264
264
 
265
- # Any password will work in development or mode
265
+ # Any password will work in development mode
266
266
  def valid_password?(password)
267
- Rails.env.development? || Rails.env.staging? || super
267
+ Rails.env.development? || super
268
268
  end
269
269
 
270
270
  # Send devise & devise_invitable emails via active job
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.19.13'.freeze
2
+ VERSION = '2.20.1'.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: 2.19.13
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-10 00:00:00.000000000 Z
11
+ date: 2024-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails