forked from solidusio/solidus
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request solidusio#5658 from mamhoff/legacy-promos-prep/cla…
…ss-set-extensions Nested Class Set extension, Promotion configuration object
- Loading branch information
Showing
23 changed files
with
460 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
backend/app/views/spree/admin/promotions/actions/_create_adjustment.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<%= render partial: 'spree/admin/promotions/actions/promotion_calculators_with_custom_fields', | ||
locals: { calculators: @calculators, promotion_action: promotion_action, param_prefix: param_prefix } %> | ||
locals: { calculators: promotion_action.available_calculators, promotion_action: promotion_action, param_prefix: param_prefix } %> |
2 changes: 1 addition & 1 deletion
2
backend/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<%= render( | ||
"spree/admin/promotions/actions/promotion_calculators_with_custom_fields", | ||
calculators: Rails.application.config.spree.calculators.promotion_actions_create_item_adjustments, | ||
calculators: promotion_action.available_calculators, | ||
promotion_action: promotion_action, | ||
param_prefix: param_prefix | ||
) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spree/core/class_constantizer" | ||
|
||
module Spree | ||
module Core | ||
class NestedClassSet | ||
attr_reader :klass_sets | ||
|
||
def initialize(hash = {}) | ||
@klass_sets = hash.map do |key, value| | ||
[ | ||
key.to_s, | ||
ClassConstantizer::Set.new(default: value) | ||
] | ||
end.to_h | ||
end | ||
|
||
def [](klass) | ||
klass_sets[klass.to_s] || [] | ||
end | ||
|
||
def []=(klass, klasses) | ||
klass_sets[klass.to_s] = ClassConstantizer::Set.new(default: klasses.map(&:to_s)) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spree | ||
module Core | ||
class PromotionConfiguration | ||
include Core::EnvironmentExtension | ||
|
||
add_nested_class_set :calculators, default: { | ||
"Spree::Promotion::Actions::CreateAdjustment" => %w[ | ||
Spree::Calculator::FlatPercentItemTotal | ||
Spree::Calculator::FlatRate | ||
Spree::Calculator::FlexiRate | ||
Spree::Calculator::TieredPercent | ||
Spree::Calculator::TieredFlatRate | ||
], | ||
"Spree::Promotion::Actions::CreateItemAdjustments" => %w[ | ||
Spree::Calculator::DistributedAmount | ||
Spree::Calculator::FlatRate | ||
Spree::Calculator::FlexiRate | ||
Spree::Calculator::PercentOnLineItem | ||
Spree::Calculator::TieredPercent | ||
], | ||
"Spree::Promotion::Actions::CreateQuantityAdjustments" => %w[ | ||
Spree::Calculator::PercentOnLineItem | ||
Spree::Calculator::FlatRate | ||
] | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.