effective_resources 2.20.0 → 2.20.2

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: 7425b10dfe261701d61c87772c9c031c6a38521e02c910833b30f2fb8238f3f8
4
- data.tar.gz: 265b68c8132d30d8b4fa3b7335dbfe889033c2565adeaa48ddd65a08f29ee92e
3
+ metadata.gz: 56b1a55c520efbd90c56d4e17d66fbdb328f4732e89e500279dcac8bd1a0490e
4
+ data.tar.gz: 9154c49ed7c9dcf18a98f5e6051f8bb516cf53f95cc0d9f4cbf777c8b93b3e25
5
5
  SHA512:
6
- metadata.gz: 0cc236d30dfa1523911297c17587a3a575238a25269836d24614b513408c8be88d7795d6985c63b167a2401805bc5d603d81c85a934bcc58063851c8fa7d7369
7
- data.tar.gz: 74a40cc66f62880522ade26fa0133cacf2c4f795e2dc0e742560ef2227c570a665482c0b87514728c2da9d2f16bf944654f28b7c1b5696de2434bb03bf4ce726
6
+ metadata.gz: a673a48025bda899630dd5edb0672dd12feff7e8f0b04d5ece1312bbc5bd50c318802ca5eb49980472afd0273586b658c1b1cb4b9b477314f69c6e87d13831c1
7
+ data.tar.gz: 8d7046ee355a352ef07c289dfa6deab682cf7233ef998fe85249dff4c602f5e3f570f476da593e5bc4214318a689fdf39c2b5fbc5e9be588d8726812b5562051
@@ -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
@@ -166,6 +166,10 @@ module ActsAsWizard
166
166
  has_completed_step?(required_steps.last)
167
167
  end
168
168
 
169
+ def start_step_requires_authenticated_user?
170
+ true
171
+ end
172
+
169
173
  def reset_all_wizard_steps!
170
174
  update!(wizard_steps: {})
171
175
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.20.0'.freeze
2
+ VERSION = '2.20.2'.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.20.0
4
+ version: 2.20.2
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-16 00:00:00.000000000 Z
11
+ date: 2024-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails