effective_resources 1.11.0 → 1.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/effective/wizard_controller/before_actions.rb +18 -0
- data/app/controllers/concerns/effective/wizard_controller/permitted_params.rb +19 -0
- data/app/controllers/concerns/effective/wizard_controller.rb +11 -0
- data/app/models/concerns/acts_as_purchasable_wizard.rb +1 -1
- data/app/models/concerns/acts_as_wizard.rb +4 -0
- data/app/models/effective/after_commit.rb +4 -2
- data/app/models/effective/resources/relation.rb +1 -3
- data/lib/effective_resources/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47e241da2411f181fa4a176db6791e1416b861f38061c9186fdf595df78767e2
|
4
|
+
data.tar.gz: 76dc05f7974a967a14c608161e9c57e90eb66a962f32ca923b4913bd1f4f15bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dc99f690d6f2aa26bfa240df5d9b5887ff4811ecf834178269934c5ef35cdd195180cc137302a2d31dee371ca5d012077f8d0113d146410d76fc9f6b06d2723
|
7
|
+
data.tar.gz: aebfd8aff7b492dbf304ae5be5b3c63d6432754b2272c4c77a0aff64e1685add92fa70dadc385589c56e0b55dfc430156a18a9945bdb22fa73488ec970bbba10
|
@@ -35,6 +35,20 @@ module Effective
|
|
35
35
|
|
36
36
|
# setup_wizard from Wicked called now
|
37
37
|
|
38
|
+
# Allow only 1 in-progress wizard at a time
|
39
|
+
def redirect_if_existing
|
40
|
+
return if step == 'wicked_finish'
|
41
|
+
return if resource.blank?
|
42
|
+
return if resource.try(:done?)
|
43
|
+
return unless resource_scope.respond_to?(:in_progress)
|
44
|
+
|
45
|
+
existing = resource_scope.in_progress.where.not(id: resource).first
|
46
|
+
return unless existing.present?
|
47
|
+
|
48
|
+
flash[:success] = "You have been redirected to your in-progress wizard"
|
49
|
+
redirect_to resource_wizard_path(existing, existing.next_step)
|
50
|
+
end
|
51
|
+
|
38
52
|
# before_action :enforce_can_visit_step, only: [:show, :update]
|
39
53
|
# Make sure I have permission for this step
|
40
54
|
def enforce_can_visit_step
|
@@ -76,6 +90,10 @@ module Effective
|
|
76
90
|
resource.ready!
|
77
91
|
end
|
78
92
|
|
93
|
+
def clear_flash_success
|
94
|
+
@_delete_flash_success = true
|
95
|
+
end
|
96
|
+
|
79
97
|
end
|
80
98
|
end
|
81
99
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Effective
|
2
|
+
module WizardController
|
3
|
+
module PermittedParams
|
4
|
+
BLACKLIST = [
|
5
|
+
:created_at, :updated_at,
|
6
|
+
:token, :slug, :price,
|
7
|
+
:logged_change_ids, :orders, :purchased_order_id,
|
8
|
+
:status, :status_steps, :wizard_steps,
|
9
|
+
:submitted_at, :completed_at, :reviewed_at, :approved_at, :declined_at, :purchased_at,
|
10
|
+
:declined_reason
|
11
|
+
]
|
12
|
+
|
13
|
+
def resource_permitted_params
|
14
|
+
permitted_name = params.key?(effective_resource.name) ? effective_resource.name : effective_resource.resource_name
|
15
|
+
params.require(permitted_name).except(BLACKLIST).permit!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -7,6 +7,7 @@ module Effective
|
|
7
7
|
|
8
8
|
include Effective::WizardController::Actions
|
9
9
|
include Effective::WizardController::BeforeActions
|
10
|
+
include Effective::WizardController::PermittedParams
|
10
11
|
include Effective::WizardController::Save
|
11
12
|
include Effective::WizardController::WickedOverrides
|
12
13
|
|
@@ -23,10 +24,14 @@ module Effective
|
|
23
24
|
before_action :assign_resource
|
24
25
|
before_action :authorize_resource
|
25
26
|
before_action :assign_required_steps
|
27
|
+
|
26
28
|
before_action :setup_wizard # Wicked
|
27
29
|
|
28
30
|
before_action :enforce_can_visit_step
|
29
31
|
|
32
|
+
before_action :redirect_if_existing, only: [:show, :new]
|
33
|
+
before_action :clear_flash_success, only: [:update]
|
34
|
+
|
30
35
|
before_action :assign_current_step
|
31
36
|
before_action :assign_page_title
|
32
37
|
|
@@ -42,6 +47,12 @@ module Effective
|
|
42
47
|
flash[:danger] = "Unknown step. You have been moved to the #{resource_wizard_steps.first} step."
|
43
48
|
redirect_to wizard_path(resource_wizard_steps.first)
|
44
49
|
end
|
50
|
+
|
51
|
+
# effective_resources on save callback
|
52
|
+
after_action do
|
53
|
+
flash.clear if @_delete_flash_success
|
54
|
+
end
|
55
|
+
|
45
56
|
end
|
46
57
|
|
47
58
|
def find_wizard_resource
|
@@ -62,7 +62,7 @@ module ActsAsPurchasableWizard
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# From Billing Step
|
65
|
-
order.billing_address = owner.billing_address if owner.billing_address.present?
|
65
|
+
order.billing_address = owner.billing_address if owner.try(:billing_address).present?
|
66
66
|
|
67
67
|
# Important to add/remove anything
|
68
68
|
order.save!
|
@@ -28,8 +28,10 @@ module Effective
|
|
28
28
|
def self.register_callback(connection:, name:, callback:)
|
29
29
|
raise ArgumentError, "#{name} expected a block" unless callback
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
in_transaction = (connection.transaction_open? && connection.current_transaction.joinable?)
|
32
|
+
|
33
|
+
# Execute immediately when outside transaction
|
34
|
+
return callback.call unless in_transaction
|
33
35
|
|
34
36
|
after_commit = Effective::AfterCommit.new("#{name}": callback)
|
35
37
|
connection.add_transaction_record(after_commit)
|
@@ -95,8 +95,6 @@ module Effective
|
|
95
95
|
relation.where(is_null("#{sql_column}_id")).where(is_null("#{sql_column}_type"))
|
96
96
|
elsif type.present? && id.present? # This was from a polymorphic select
|
97
97
|
relation.where("#{sql_column}_id = ?", id).where("#{sql_column}_type = ?", type)
|
98
|
-
elsif name == :user # Polymorphic user
|
99
|
-
relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
|
100
98
|
else # Maybe from a string field
|
101
99
|
collection = relation.none
|
102
100
|
|
@@ -106,7 +104,7 @@ module Effective
|
|
106
104
|
resource = Effective::Resource.new(klass_name)
|
107
105
|
next unless resource.klass.present?
|
108
106
|
|
109
|
-
collection = collection.or(relation.where("#{name}_id": resource.search_any(term), "#{name}_type": klass_name))
|
107
|
+
collection = collection.or(relation.where("#{name}_id": resource.search_any(term, fuzzy: fuzzy), "#{name}_type": klass_name))
|
110
108
|
end
|
111
109
|
|
112
110
|
collection
|
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.
|
4
|
+
version: 1.12.3
|
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: 2022-
|
11
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- app/controllers/concerns/effective/wizard_controller.rb
|
146
146
|
- app/controllers/concerns/effective/wizard_controller/actions.rb
|
147
147
|
- app/controllers/concerns/effective/wizard_controller/before_actions.rb
|
148
|
+
- app/controllers/concerns/effective/wizard_controller/permitted_params.rb
|
148
149
|
- app/controllers/concerns/effective/wizard_controller/save.rb
|
149
150
|
- app/controllers/concerns/effective/wizard_controller/wicked_overrides.rb
|
150
151
|
- app/helpers/effective_acts_as_email_form_helper.rb
|