solidus_friendly_promotions 1.0.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile +1 -1
- data/MIGRATING.md +1 -1
- data/README.md +22 -16
- data/app/assets/config/solidus_friendly_promotions/manifest.js +7 -1
- data/app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb +85 -0
- data/app/controllers/solidus_friendly_promotions/admin/conditions_controller.rb +69 -0
- data/app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb +3 -3
- data/app/decorators/models/solidus_friendly_promotions/adjustment_decorator.rb +4 -4
- data/app/decorators/models/solidus_friendly_promotions/line_item_decorator.rb +2 -2
- data/app/decorators/models/solidus_friendly_promotions/order_decorator.rb +6 -6
- data/app/helpers/solidus_friendly_promotions/admin/benefits_helper.rb +19 -0
- data/app/helpers/solidus_friendly_promotions/admin/conditions_helper.rb +12 -0
- data/app/javascript/solidus_friendly_promotions/controllers/product_option_values_controller.js +1 -1
- data/app/javascript/solidus_friendly_promotions/web_components/number_with_currency.js +35 -0
- data/app/javascript/solidus_friendly_promotions/{jquery → web_components}/option_value_picker.js +8 -0
- data/app/javascript/solidus_friendly_promotions/web_components/product_picker.js +7 -0
- data/app/javascript/solidus_friendly_promotions/web_components/select_two.js +11 -0
- data/app/javascript/solidus_friendly_promotions/web_components/taxon_picker.js +7 -0
- data/app/javascript/solidus_friendly_promotions/web_components/user_picker.js +7 -0
- data/app/javascript/solidus_friendly_promotions/web_components/variant_picker.js +7 -0
- data/app/javascript/solidus_friendly_promotions.js +7 -11
- data/app/models/concerns/solidus_friendly_promotions/{actions/order_level_action.rb → benefits/order_benefit.rb} +2 -2
- data/app/models/concerns/solidus_friendly_promotions/{rules/line_item_applicable_order_rule.rb → conditions/line_item_applicable_order_condition.rb} +2 -2
- data/app/models/concerns/solidus_friendly_promotions/{rules/line_item_level_rule.rb → conditions/line_item_level_condition.rb} +2 -2
- data/app/models/concerns/solidus_friendly_promotions/{rules/order_level_rule.rb → conditions/order_level_condition.rb} +2 -2
- data/app/models/concerns/solidus_friendly_promotions/{rules/shipment_level_rule.rb → conditions/shipment_level_condition.rb} +2 -2
- data/app/models/solidus_friendly_promotions/{promotion_action.rb → benefit.rb} +48 -11
- data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_line_item.rb +6 -2
- data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_line_item_quantity_groups.rb +3 -3
- data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_shipment.rb +6 -2
- data/app/models/solidus_friendly_promotions/{actions → benefits}/create_discounted_item.rb +6 -7
- data/app/models/solidus_friendly_promotions/calculators/distributed_amount.rb +1 -1
- data/app/models/solidus_friendly_promotions/calculators/tiered_flat_rate.rb +1 -1
- data/app/models/solidus_friendly_promotions/calculators/tiered_percent.rb +1 -1
- data/app/models/solidus_friendly_promotions/calculators/tiered_percent_on_eligible_item_quantity.rb +4 -2
- data/app/models/solidus_friendly_promotions/{promotion_rule.rb → condition.rb} +13 -7
- data/app/models/solidus_friendly_promotions/condition_product.rb +8 -0
- data/app/models/solidus_friendly_promotions/condition_store.rb +8 -0
- data/app/models/solidus_friendly_promotions/condition_taxon.rb +8 -0
- data/app/models/solidus_friendly_promotions/{promotion_rules_user.rb → condition_user.rb} +2 -2
- data/app/models/solidus_friendly_promotions/{rules → conditions}/discounted_item_total.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/first_order.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/first_repeat_purchase_since.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/item_total.rb +5 -5
- data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_option_value.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_product.rb +8 -8
- data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_taxon.rb +8 -8
- data/app/models/solidus_friendly_promotions/{rules → conditions}/minimum_quantity.rb +8 -8
- data/app/models/solidus_friendly_promotions/{rules → conditions}/nth_order.rb +5 -5
- data/app/models/solidus_friendly_promotions/{rules → conditions}/one_use_per_user.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/option_value.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/product.rb +9 -9
- data/app/models/solidus_friendly_promotions/{rules → conditions}/shipping_method.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/store.rb +6 -6
- data/app/models/solidus_friendly_promotions/{rules → conditions}/taxon.rb +12 -12
- data/app/models/solidus_friendly_promotions/{rules → conditions}/user.rb +7 -7
- data/app/models/solidus_friendly_promotions/{rules → conditions}/user_logged_in.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/user_role.rb +3 -3
- data/app/models/solidus_friendly_promotions/eligibility_result.rb +1 -1
- data/app/models/solidus_friendly_promotions/eligibility_results.rb +7 -7
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/discount_order.rb +28 -29
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/load_promotions.rb +10 -11
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/persist_discounted_order.rb +2 -2
- data/app/models/solidus_friendly_promotions/order_promotion.rb +1 -1
- data/app/models/solidus_friendly_promotions/permission_sets/friendly_promotion_management.rb +1 -1
- data/app/models/solidus_friendly_promotions/promotion.rb +14 -43
- data/app/models/solidus_friendly_promotions/promotion_advertiser.rb +10 -0
- data/app/models/solidus_friendly_promotions/promotion_code.rb +1 -1
- data/app/models/solidus_friendly_promotions/shipping_rate_discount.rb +1 -1
- data/app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_line_item.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/actions → benefit_fields}/_adjust_line_item_quantity_groups.html.erb +4 -4
- data/app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_shipment.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/benefit_fields/_calculator_fields.erb +11 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/actions → benefit_fields}/_create_discounted_item.html.erb +8 -6
- data/app/views/solidus_friendly_promotions/admin/benefits/_benefit.html.erb +50 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/_calculator_select.html.erb +16 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/_form.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/_new_benefit.html.erb +33 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/_type_select.html.erb +16 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/edit.html.erb +19 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/new.html.erb +1 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/_default_fields.html.erb +1 -1
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/distributed_amount/_fields.html.erb +3 -3
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/flat_rate/_fields.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/flexi_rate/_fields.html.erb +24 -0
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/percent/_fields.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_flat_rate/_fields.html.erb +32 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_flat_rate/_tier_fields.html.erb +7 -8
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent/_fields.html.erb +47 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_percent/_tier_fields.html.erb +8 -7
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_percent_on_eligible_item_quantity/_fields.html.erb +11 -9
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +35 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_first_order.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_first_repeat_purchase_since.html.erb +7 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_item_total.html.erb +15 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_option_value.html.erb +25 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_line_item_product.html.erb +7 -7
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_taxon.html.erb +17 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_minimum_quantity.html.erb +5 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_nth_order.html.erb +15 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_one_use_per_user.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_option_value.html.erb +10 -10
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_product.html.erb +28 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_shipping_method.html.erb +3 -3
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_store.html.erb +9 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_taxon.html.erb +28 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_user.html.erb +7 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_user_logged_in.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_user_role.html.erb +15 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/line_item_option_value/_option_value_fields.html.erb +21 -0
- data/app/views/solidus_friendly_promotions/admin/conditions/_condition.html.erb +26 -0
- data/app/views/solidus_friendly_promotions/admin/conditions/_new_condition.html.erb +26 -0
- data/app/views/solidus_friendly_promotions/admin/conditions/_type_select.html.erb +20 -0
- data/app/views/solidus_friendly_promotions/admin/conditions/new.html.erb +1 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_code_batches/_form_fields.html.erb +5 -5
- data/app/views/solidus_friendly_promotions/admin/promotions/_form.html.erb +4 -4
- data/app/views/solidus_friendly_promotions/admin/promotions/_table_filter.html.erb +6 -6
- data/app/views/solidus_friendly_promotions/admin/promotions/edit.html.erb +7 -41
- data/app/views/solidus_friendly_promotions/admin/shared/_number_with_currency.html.erb +20 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_boolean.html.erb +14 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_decimal.html.erb +12 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_integer.html.erb +12 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_password.html.erb +12 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_string.html.erb +12 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_text.html.erb +12 -0
- data/bin/sandbox +3 -3
- data/config/importmap.rb +2 -0
- data/config/locales/en.yml +128 -94
- data/config/routes.rb +3 -2
- data/db/migrate/20231011120928_add_db_comments_to_friendly_promotion_rules_taxons.rb +2 -2
- data/db/migrate/20231011142040_add_db_comments_to_friendly_promotion_rules_users.rb +1 -1
- data/db/migrate/20231011190222_add_db_comments_to_friendly_promotion_actions.rb +1 -1
- data/db/migrate/20240409093831_add_action_reference_to_rules.rb +34 -0
- data/db/migrate/20240506142650_remove_promotion_rules_promotion_id.rb +5 -0
- data/db/migrate/20240508080834_rename_promotion_rules_to_conditions.rb +19 -0
- data/db/migrate/20240508131514_rename_friendly_promotion_actions_to_friendly_benefits.rb +19 -0
- data/db/migrate/20240612113608_update_column_comments_for_benefits.rb +31 -0
- data/db/migrate/20240612114132_update_column_comments_for_conditions.rb +30 -0
- data/db/migrate/20240612115209_update_column_comments_for_condition_stores.rb +23 -0
- data/db/migrate/20240612115749_update_column_comments_for_condition_products.rb +22 -0
- data/db/migrate/20240612120411_update_column_comments_for_condition_taxons.rb +24 -0
- data/db/migrate/20240612121049_update_column_comments_for_condition_users.rb +23 -0
- data/lib/generators/solidus_friendly_promotions/install/templates/initializer.rb +30 -30
- data/lib/solidus_friendly_promotions/configuration.rb +11 -3
- data/lib/solidus_friendly_promotions/migrate_adjustments.rb +11 -11
- data/lib/solidus_friendly_promotions/promotion_map.rb +17 -17
- data/lib/solidus_friendly_promotions/promotion_migrator.rb +16 -16
- data/lib/solidus_friendly_promotions/testing_support/factories/friendly_promotion_factory.rb +8 -34
- data/lib/solidus_friendly_promotions/testing_support/factories/friendly_shipping_rate_discount_factory.rb +2 -2
- data/lib/solidus_friendly_promotions/version.rb +1 -1
- data/lib/tasks/solidus_friendly_promotions/migrate_adjustments.rake +2 -2
- data/solidus_friendly_promotions.gemspec +2 -2
- metadata +114 -86
- data/.rubocop_todo.yml +0 -157
- data/app/controllers/solidus_friendly_promotions/admin/promotion_actions_controller.rb +0 -103
- data/app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb +0 -105
- data/app/helpers/solidus_friendly_promotions/admin/promotion_actions_helper.rb +0 -23
- data/app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb +0 -25
- data/app/models/solidus_friendly_promotions/products_promotion_rule.rb +0 -8
- data/app/models/solidus_friendly_promotions/promotion_rules_store.rb +0 -8
- data/app/models/solidus_friendly_promotions/promotion_rules_taxon.rb +0 -8
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_calculator_select.html.erb +0 -16
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_form.html.erb +0 -3
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_promotion_action.html.erb +0 -29
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_type_select.html.erb +0 -14
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_line_item.html.erb +0 -6
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_shipment.html.erb +0 -6
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_calculator_fields.erb +0 -9
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/flat_rate/_fields.html.erb +0 -6
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_flat_rate/_fields.html.erb +0 -34
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent/_fields.html.erb +0 -34
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +0 -27
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/edit.html.erb +0 -23
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/new.html.erb +0 -26
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/_promotion_rule.html.erb +0 -22
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/_type_select.html.erb +0 -20
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/new.html.erb +0 -24
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_order.html.erb +0 -3
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_repeat_purchase_since.html.erb +0 -6
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_item_total.html.erb +0 -17
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_option_value.html.erb +0 -25
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_taxon.html.erb +0 -17
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_minimum_quantity.html.erb +0 -5
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_nth_order.html.erb +0 -15
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_one_use_per_user.html.erb +0 -3
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_product.html.erb +0 -44
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_store.html.erb +0 -9
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_taxon.html.erb +0 -44
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user.html.erb +0 -7
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_logged_in.html.erb +0 -3
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_role.html.erb +0 -15
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/line_item_option_value/_option_value_fields.html.erb +0 -17
@@ -0,0 +1,16 @@
|
|
1
|
+
<%= form_with model: benefit, scope: :benefit, url: path, method: :get do |form| %>
|
2
|
+
<%= form.hidden_field :type %>
|
3
|
+
<div class="form-group">
|
4
|
+
<%= form.label :calculator_type %>
|
5
|
+
<%=
|
6
|
+
form.select :calculator_type,
|
7
|
+
options_for_benefit_calculator_types(form.object),
|
8
|
+
{
|
9
|
+
include_blank: t(:choose_benefit_calculator, scope: 'solidus_friendly_promotions')
|
10
|
+
},
|
11
|
+
class: 'custom-select fullwidth',
|
12
|
+
onchange: 'this.form.requestSubmit()',
|
13
|
+
required: true
|
14
|
+
%>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= turbo_frame_tag benefit.promotion, "new_benefit" do %>
|
2
|
+
<div class="card bg-light mb-3">
|
3
|
+
<div class="card-header">
|
4
|
+
<%= t(:add_benefit, scope: :solidus_friendly_promotions) %>
|
5
|
+
</div>
|
6
|
+
<div class="card-body">
|
7
|
+
<div class="row">
|
8
|
+
<div class="col-6">
|
9
|
+
<%= render 'solidus_friendly_promotions/admin/benefits/type_select', benefit: benefit %>
|
10
|
+
<% if benefit.available_calculators.any? %>
|
11
|
+
<%= render 'solidus_friendly_promotions/admin/benefits/calculator_select', path: solidus_friendly_promotions.new_admin_promotion_benefit_path(@promotion), benefit: benefit %>
|
12
|
+
<% if benefit.calculator %>
|
13
|
+
<%=
|
14
|
+
form_with(
|
15
|
+
model: benefit,
|
16
|
+
scope: :benefit,
|
17
|
+
url: solidus_friendly_promotions.admin_promotion_benefits_path(@promotion),
|
18
|
+
data: { turbo: false }
|
19
|
+
) do |form| %>
|
20
|
+
<%= render 'form', form: form %>
|
21
|
+
<div class="row">
|
22
|
+
<div class="col-12">
|
23
|
+
<%= button_tag t(:add, scope: [:solidus_friendly_promotions, :crud]), class: "btn btn-secondary float-right" %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%= form_with model: benefit, scope: :benefit, url: solidus_friendly_promotions.new_admin_promotion_benefit_path(@promotion), method: :get do |form| %>
|
2
|
+
<div class="form-group">
|
3
|
+
<%= form.label :type %>
|
4
|
+
<%= admin_hint SolidusFriendlyPromotions::Benefit.human_attribute_name(:type), t(:type, scope: [:solidus_friendly_promotions, :hints, "solidus_friendly_promotions/benefit"]) %>
|
5
|
+
<%=
|
6
|
+
form.select :type,
|
7
|
+
options_for_benefit_types(form.object),
|
8
|
+
{
|
9
|
+
include_blank: t(:choose_benefit, scope: 'solidus_friendly_promotions')
|
10
|
+
},
|
11
|
+
class: 'custom-select w-100',
|
12
|
+
onchange: 'this.form.requestSubmit()',
|
13
|
+
required: true
|
14
|
+
%>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= turbo_frame_tag @promotion, dom_id(@benefit) do %>
|
2
|
+
<%= render 'calculator_select', path: solidus_friendly_promotions.edit_admin_promotion_benefit_path(@promotion, @benefit), benefit: @benefit %>
|
3
|
+
|
4
|
+
<%=
|
5
|
+
form_with(
|
6
|
+
model: @benefit,
|
7
|
+
scope: :benefit,
|
8
|
+
url: solidus_friendly_promotions.admin_promotion_benefit_path(@promotion, @benefit),
|
9
|
+
) do |form| %>
|
10
|
+
<%= render "form", form: form %>
|
11
|
+
|
12
|
+
<div class="row">
|
13
|
+
<div class="col-12">
|
14
|
+
<%= button_tag "Update", class: "btn btn-secondary float-right" %>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render "new_benefit", benefit: @benefit %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% calculator.admin_form_preference_names.map do |name| %>
|
2
|
-
<%= render "
|
2
|
+
<%= render "solidus_friendly_promotions/admin/shared/preference_fields/#{calculator.preference_type(name)}",
|
3
3
|
name: "#{prefix}[calculator_attributes][preferred_#{name}]",
|
4
4
|
value: calculator.get_preference(name),
|
5
5
|
label: t(name.to_s, scope: 'spree', default: name.to_s.humanize) %>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<div class="
|
1
|
+
<div class="form-group">
|
2
2
|
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
3
|
<%= f.label :preferred_amount %>
|
4
|
-
<%= render "
|
4
|
+
<%= render "solidus_friendly_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_amount, currency_attr: :preferred_currency %>
|
5
5
|
<% end %>
|
6
6
|
</div>
|
7
7
|
|
8
|
-
<div class="
|
8
|
+
<div class="form-group">
|
9
9
|
<p>
|
10
10
|
<%= admin_hint(
|
11
11
|
calculator.model_name.human,
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_amount %>
|
4
|
+
<%= render "solidus_friendly_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_amount, currency_attr: :preferred_currency %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
data/app/views/solidus_friendly_promotions/admin/calculator_fields/flexi_rate/_fields.html.erb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_first_item %>
|
4
|
+
<%= render "solidus_friendly_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_first_item, currency: f.object.preferred_currency %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
7
|
+
<div class="form-group">
|
8
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
9
|
+
<%= f.label :preferred_additional_item %>
|
10
|
+
<%= render "solidus_friendly_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_additional_item, currency: f.object.preferred_currency %>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
13
|
+
<div class="form-group">
|
14
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
15
|
+
<%= f.label :preferred_max_items %>
|
16
|
+
<%= f.number_field :preferred_max_items, step: 1, min: 1, default: 1, class: "form-control" %>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
19
|
+
<div class="form-group">
|
20
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
21
|
+
<%= f.label :preferred_currency %>
|
22
|
+
<%= f.select :preferred_currency, Spree::Config.available_currencies.map(&:iso_code), {selected: f.object.preferred_currency }, { is: "select-two", class: "w-100"} %>
|
23
|
+
<% end %>
|
24
|
+
</div>
|
data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_flat_rate/_fields.html.erb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_base_amount %>
|
4
|
+
<%= render "solidus_friendly_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_base_amount, currency_attr: :preferred_currency %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="form-group">
|
9
|
+
<%= label_tag nil, calculator.class.human_attribute_name(:tiers) %>
|
10
|
+
<div data-controller="calculator-tiers">
|
11
|
+
<div class="d-flex">
|
12
|
+
<div class="item-total-label" style="flex-grow: 1">
|
13
|
+
<%= SolidusFriendlyPromotions::Calculators::TieredFlatRate.human_attribute_name(:order_item_total) %>
|
14
|
+
</div>
|
15
|
+
<div class="discount-label mx-2" style="flex-grow: 1">
|
16
|
+
<%= SolidusFriendlyPromotions::Calculators::TieredFlatRate.human_attribute_name(:discount) %>
|
17
|
+
</div>
|
18
|
+
<div class="tools m-3">
|
19
|
+
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<template data-calculator-tiers-target="template">
|
23
|
+
<%= render "solidus_friendly_promotions/admin/calculator_fields/tiered_flat_rate/tier_fields", tier: [nil, nil], form: form, currency: calculator.preferred_currency %>
|
24
|
+
</template>
|
25
|
+
<% form.object.calculator.preferred_tiers.each do |tier| %>
|
26
|
+
<%= render "solidus_friendly_promotions/admin/calculator_fields/tiered_flat_rate/tier_fields", tier: tier, form: form, currency: calculator.preferred_currency %>
|
27
|
+
<% end %>
|
28
|
+
<div class="my-3" data-calculator-tiers-target="links">
|
29
|
+
<%= link_to t(:add_tier, scope: [:solidus_friendly_promotions, :admin, :promotions, :calculator]), "#", class: "btn btn-outline-primary", data: { action: "click->calculator-tiers#add_association" } %>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</div>
|
@@ -1,10 +1,9 @@
|
|
1
|
-
<div class="fullwidth tier calculator-tiers">
|
2
|
-
<
|
3
|
-
|
4
|
-
<div class="col-6">
|
1
|
+
<div class="fullwidth tier calculator-tiers mb-3">
|
2
|
+
<div class="d-flex">
|
3
|
+
<div class="mr-2">
|
5
4
|
<div class="input-group">
|
6
5
|
<div class="input-group-prepend">
|
7
|
-
<span class="input-group-text"
|
6
|
+
<span class="input-group-text"><%= ::Money::Currency.find(currency).symbol %></span>
|
8
7
|
</div>
|
9
8
|
<input
|
10
9
|
class="js-base-input form-control"
|
@@ -14,10 +13,10 @@
|
|
14
13
|
>
|
15
14
|
</div>
|
16
15
|
</div>
|
17
|
-
<div class="
|
16
|
+
<div class="mx-2">
|
18
17
|
<div class="input-group">
|
19
18
|
<div class="input-group-prepend">
|
20
|
-
<span class="input-group-text"
|
19
|
+
<span class="input-group-text"><%= ::Money::Currency.find(currency).symbol %></span>
|
21
20
|
</div>
|
22
21
|
<input
|
23
22
|
class="js-value-input form-control"
|
@@ -27,6 +26,6 @@
|
|
27
26
|
>
|
28
27
|
</div>
|
29
28
|
</div>
|
29
|
+
<a class="fa fa-trash remove p-2" data-action="click->calculator-tiers#remove_association"></a>
|
30
30
|
</div>
|
31
|
-
<div class="clear"></div>
|
32
31
|
</div>
|
data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent/_fields.html.erb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_base_percent %>
|
4
|
+
<%= f.number_field :preferred_base_percent, step: 1, min: 0, max: 100, default: 1, class: "form-control" %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="form-group">
|
9
|
+
<%= label_tag(
|
10
|
+
"#{prefix}[calculator_attributes][preferred_currency]",
|
11
|
+
t('spree.currency')
|
12
|
+
) %>
|
13
|
+
<%= select_tag(
|
14
|
+
"#{prefix}[calculator_attributes][preferred_currency]",
|
15
|
+
options_for_select(
|
16
|
+
Spree::Config.available_currencies,
|
17
|
+
calculator.preferred_currency || Spree::Config[:currency]
|
18
|
+
),
|
19
|
+
{ is: "select-two", class: 'fullwidth' }
|
20
|
+
) %>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div class="form-group">
|
24
|
+
<%= label_tag nil, calculator.class.human_attribute_name(:tiers) %>
|
25
|
+
<div data-controller="calculator-tiers">
|
26
|
+
<div class="d-flex">
|
27
|
+
<div class="item-total-label" style="flex-grow: 1">
|
28
|
+
<%= SolidusFriendlyPromotions::Calculators::TieredPercent.human_attribute_name(:order_item_total) %>
|
29
|
+
</div>
|
30
|
+
<div class="discount-label mx-2" style="flex-grow: 1">
|
31
|
+
<%= SolidusFriendlyPromotions::Calculators::TieredPercent.human_attribute_name(:percent) %>
|
32
|
+
</div>
|
33
|
+
<div class="tools m-3">
|
34
|
+
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<template data-calculator-tiers-target="template">
|
38
|
+
<%= render "solidus_friendly_promotions/admin/calculator_fields/tiered_percent/tier_fields", tier: [nil, nil], form: form %>
|
39
|
+
</template>
|
40
|
+
<% form.object.calculator.preferred_tiers.each do |tier| %>
|
41
|
+
<%= render "solidus_friendly_promotions/admin/calculator_fields/tiered_percent/tier_fields", tier: tier, form: form %>
|
42
|
+
<% end %>
|
43
|
+
<div class="mb-3" data-calculator-tiers-target="links">
|
44
|
+
<%= link_to t(:add_tier, scope: [:solidus_friendly_promotions, :admin, :promotions, :calculator]), "#", class: "btn btn-outline-primary", data: { action: "click->calculator-tiers#add_association" } %>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
@@ -1,7 +1,6 @@
|
|
1
|
-
<div class="fullwidth tier calculator-tiers">
|
2
|
-
<
|
3
|
-
|
4
|
-
<div class="col-6">
|
1
|
+
<div class="fullwidth tier calculator-tiers mb-3">
|
2
|
+
<div class="d-flex">
|
3
|
+
<div class="mr-2">
|
5
4
|
<div class="input-group">
|
6
5
|
<div class="input-group-prepend">
|
7
6
|
<span class="input-group-text">$</span>
|
@@ -14,12 +13,14 @@
|
|
14
13
|
>
|
15
14
|
</div>
|
16
15
|
</div>
|
17
|
-
<div class="
|
16
|
+
<div class="mx-2">
|
18
17
|
<div class="input-group">
|
19
18
|
<input
|
20
19
|
class="js-value-input form-control right-align"
|
21
20
|
name="<%= form.object_name %>[calculator_attributes][preferred_tiers][<%= tier[0] %>]"
|
22
|
-
type="
|
21
|
+
type="number"
|
22
|
+
min="0"
|
23
|
+
max="100"
|
23
24
|
value="<%= tier[1] %>"
|
24
25
|
>
|
25
26
|
<div class="input-group-append">
|
@@ -27,6 +28,6 @@
|
|
27
28
|
</div>
|
28
29
|
</div>
|
29
30
|
</div>
|
31
|
+
<a class="fa fa-trash remove p-2" data-action="click->calculator-tiers#remove_association"></a>
|
30
32
|
</div>
|
31
|
-
<div class="clear"></div>
|
32
33
|
</div>
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_base_percent %>
|
4
|
+
<%= f.number_field :preferred_base_percent, step: 1, min: 0, max: 100, default: 1, class: "form-control" %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
5
7
|
|
6
|
-
<div class="
|
8
|
+
<div class="form-group">
|
7
9
|
<%= label_tag(
|
8
10
|
"#{prefix}[calculator_attributes][preferred_currency]",
|
9
11
|
t('spree.currency')
|
@@ -14,18 +16,18 @@
|
|
14
16
|
Spree::Config.available_currencies,
|
15
17
|
calculator.preferred_currency || Spree::Config[:currency]
|
16
18
|
),
|
17
|
-
{ class: '
|
19
|
+
{ is: "select-two", class: 'fullwidth' }
|
18
20
|
) %>
|
19
21
|
</div>
|
20
22
|
|
21
|
-
<div class="
|
23
|
+
<div class="form-group">
|
22
24
|
<%= label_tag nil, calculator.class.human_attribute_name(:tiers) %>
|
23
25
|
<div data-controller="calculator-tiers">
|
24
26
|
<template data-calculator-tiers-target="template">
|
25
|
-
<%= render "solidus_friendly_promotions/admin/
|
27
|
+
<%= render "solidus_friendly_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/tier_fields", tier: [nil, nil], form: form %>
|
26
28
|
</template>
|
27
29
|
<% form.object.calculator.preferred_tiers.each do |tier| %>
|
28
|
-
<%= render "solidus_friendly_promotions/admin/
|
30
|
+
<%= render "solidus_friendly_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/tier_fields", tier: tier, form: form %>
|
29
31
|
<% end %>
|
30
32
|
<div class="mb-3" data-calculator-tiers-target="links">
|
31
33
|
<%= link_to t(:add_tier, scope: [:solidus_friendly_promotions, :admin, :promotions, :calculator]), "#", class: "btn btn-outline-primary", data: { action: "click->calculator-tiers#add_association" } %>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<div class="fullwidth tier calculator-tiers mb-3">
|
2
|
+
<div class="d-flex">
|
3
|
+
<div class="mr-2">
|
4
|
+
<div class="input-group">
|
5
|
+
<div class="input-group-prepend">
|
6
|
+
<span class="input-group-text">∑</span>
|
7
|
+
</div>
|
8
|
+
<input
|
9
|
+
class="js-base-input form-control"
|
10
|
+
data-action="calculator-tiers#propagate_base_to_value_input"
|
11
|
+
type="number"
|
12
|
+
min=="1"
|
13
|
+
step="1"
|
14
|
+
value="<%= tier[0] %>"
|
15
|
+
>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
<div class="mx-2">
|
19
|
+
<div class="input-group">
|
20
|
+
<input
|
21
|
+
class="js-value-input form-control right-align"
|
22
|
+
name="<%= form.object_name %>[calculator_attributes][preferred_tiers][<%= tier[0] %>]"
|
23
|
+
type="number"
|
24
|
+
min="1"
|
25
|
+
max="100"
|
26
|
+
value="<%= tier[1] %>"
|
27
|
+
>
|
28
|
+
<div class="input-group-append">
|
29
|
+
<span class="input-group-text">%</span>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
<a class="fa fa-trash remove p-2" data-action="click->calculator-tiers#remove_association"></a>
|
34
|
+
</div>
|
35
|
+
</div>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="form-group">
|
5
|
+
<%= label_tag "#{param_prefix}[preferred_days_ago]", condition.class.human_attribute_name(:preferred_days_ago) %>
|
6
|
+
<%= number_field_tag "#{param_prefix}[preferred_days_ago]", condition.preferred_days_ago, class: 'fullwidth' %>
|
7
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
|
5
|
+
<div class="form-group">
|
6
|
+
<%= label_tag "#{param_prefix}[preferred_operator]", condition.class.human_attribute_name(:preferred_operator) %>
|
7
|
+
<%= select_tag "#{param_prefix}[preferred_operator]", options_for_select(condition.class.operator_options, condition.preferred_operator), {class: 'custom-select select_item_total fullwidth'} %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form-group">
|
11
|
+
<%= fields_for param_prefix, condition do |f| %>
|
12
|
+
<%= f.label :preferred_amount %>
|
13
|
+
<%= render "solidus_friendly_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_amount, currency_attr: :preferred_currency %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
data/app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_option_value.html.erb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
<p>
|
3
|
+
<%= condition.class.human_attribute_name(:description) %>
|
4
|
+
</p>
|
5
|
+
<div class="field promo-condition-option-values">
|
6
|
+
<div class="param-prefix hidden" data-param-prefix="<%= param_prefix %>"></div>
|
7
|
+
<div class="row">
|
8
|
+
<div class="col-6"><%= label_tag nil, Spree::Product.model_name.human %></div>
|
9
|
+
<div class="col-6"><%= label_tag nil, plural_resource_name(Spree::OptionValue) %></div>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<div class="form-group">
|
13
|
+
<div data-controller="product-option-values">
|
14
|
+
<template data-product-option-values-target="template">
|
15
|
+
<%= render "solidus_friendly_promotions/admin/condition_fields/line_item_option_value/option_value_fields", product_option_values: [nil, []], form: form %>
|
16
|
+
</template>
|
17
|
+
<% form.object.preferred_eligible_values.each do |product_option_values| %>
|
18
|
+
<%= render "solidus_friendly_promotions/admin/condition_fields/line_item_option_value/option_value_fields", product_option_values: product_option_values, form: form %>
|
19
|
+
<% end %>
|
20
|
+
<div class="mb-3" data-product-option-values-target="links">
|
21
|
+
<%= link_to t(:add_product, scope: [:solidus_friendly_promotions, :line_item_option_value_condition]), "#", class: "btn btn-outline-primary", data: { action: "click->product-option-values#add_row" } %>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</div>
|
@@ -1,19 +1,19 @@
|
|
1
1
|
<p>
|
2
|
-
<%=
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
3
|
</p>
|
4
4
|
<div class="row">
|
5
5
|
<div class="col-12">
|
6
|
-
<div class="field
|
7
|
-
<%= label_tag "#{param_prefix}_product_ids_string", t('solidus_friendly_promotions.
|
8
|
-
<%= hidden_field_tag "#{param_prefix}[product_ids_string]",
|
6
|
+
<div class="field products_condition_products">
|
7
|
+
<%= label_tag "#{param_prefix}_product_ids_string", t('solidus_friendly_promotions.product_condition.choose_products') %>
|
8
|
+
<%= hidden_field_tag "#{param_prefix}[product_ids_string]", condition.product_ids.join(","), class: "fullwidth", is: "product-picker" %>
|
9
9
|
</div>
|
10
10
|
</div>
|
11
11
|
<div class="col-12">
|
12
|
-
<div class="
|
13
|
-
<%= label_tag("#{param_prefix}_preferred_match_policy",
|
12
|
+
<div class="form-group">
|
13
|
+
<%= label_tag("#{param_prefix}_preferred_match_policy", condition.class.human_attribute_name(:preferred_match_policy)) %>
|
14
14
|
<%= select_tag(
|
15
15
|
"#{param_prefix}[preferred_match_policy]",
|
16
|
-
options_for_select(I18n.t("solidus_friendly_promotions.
|
16
|
+
options_for_select(I18n.t("solidus_friendly_promotions.conditions.line_item_product.match_policies").to_a.map(&:reverse), condition.preferred_match_policy),
|
17
17
|
class: "custom-select fullwidth"
|
18
18
|
) %>
|
19
19
|
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="field taxons_condition_taxons">
|
5
|
+
<%= label_tag "#{param_prefix}_taxon_ids_string", t("solidus_friendly_promotions.taxon_condition.choose_taxons") %>
|
6
|
+
<%= hidden_field_tag "#{param_prefix}[taxon_ids_string]", condition.taxon_ids.join(","), is: "taxon-picker", class: "fullwidth", id: "product_taxon_ids" %>
|
7
|
+
</div>
|
8
|
+
<div class="form-group">
|
9
|
+
<div class="form-group">
|
10
|
+
<%= label_tag("#{param_prefix}_preferred_match_policy", condition.class.human_attribute_name(:preferred_match_policy)) %>
|
11
|
+
<%= select_tag(
|
12
|
+
"#{param_prefix}[preferred_match_policy]",
|
13
|
+
options_for_select(I18n.t("solidus_friendly_promotions.conditions.line_item_taxon.match_policies").to_a.map(&:reverse), condition.preferred_match_policy),
|
14
|
+
class: "custom-select fullwidth",
|
15
|
+
) %>
|
16
|
+
</div>
|
17
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="row">
|
5
|
+
<div class="col-6">
|
6
|
+
<div class="form-group">
|
7
|
+
<%= SolidusFriendlyPromotions::Conditions::NthOrder.human_attribute_name(:form_text) %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<div class="col-6">
|
11
|
+
<div class="form-group">
|
12
|
+
<%= number_field_tag "#{param_prefix}[preferred_nth_order]", condition.preferred_nth_order, class: 'fullwidth' %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</div>
|
@@ -2,39 +2,39 @@
|
|
2
2
|
|
3
3
|
<% if context == :order %>
|
4
4
|
<p>
|
5
|
-
<%=
|
5
|
+
<%= condition.class.human_attribute_name(:description) %>
|
6
6
|
</p>
|
7
|
-
<div class="field promo-
|
7
|
+
<div class="field promo-condition-option-values">
|
8
8
|
<div class="param-prefix hidden" data-param-prefix="<%= param_prefix %>"></div>
|
9
9
|
<div class="row">
|
10
10
|
<div class="col-6"><%= label_tag nil, Spree::Product.model_name.human %></div>
|
11
11
|
<div class="col-6"><%= label_tag nil, plural_resource_name(Spree::OptionValue) %></div>
|
12
12
|
</div>
|
13
13
|
|
14
|
-
<div class="
|
14
|
+
<div class="form-group">
|
15
15
|
<div data-controller="product-option-values">
|
16
16
|
<template data-product-option-values-target="template">
|
17
|
-
<%= render "solidus_friendly_promotions/admin/
|
17
|
+
<%= render "solidus_friendly_promotions/admin/condition_fields/line_item_option_value/option_value_fields", product_option_values: [nil, []], form: form %>
|
18
18
|
</template>
|
19
19
|
<% form.object.preferred_eligible_values.each do |product_option_values| %>
|
20
|
-
<%= render "solidus_friendly_promotions/admin/
|
20
|
+
<%= render "solidus_friendly_promotions/admin/condition_fields/line_item_option_value/option_value_fields", product_option_values: product_option_values, form: form %>
|
21
21
|
<% end %>
|
22
22
|
<div class="mb-3" data-product-option-values-target="links">
|
23
|
-
<%= link_to
|
23
|
+
<%= link_to t(:add_product, scope: [:solidus_friendly_promotions, :option_value_condition]), "#", class: "btn btn-outline-primary", data: { action: "click->product-option-values#add_row" } %>
|
24
24
|
</div>
|
25
25
|
</div>
|
26
26
|
</div>
|
27
27
|
|
28
|
-
<div class="
|
28
|
+
<div class="form-group">
|
29
29
|
<%= form.label :preferred_line_item_applicable do %>
|
30
30
|
<%= form.check_box :preferred_line_item_applicable %>
|
31
|
-
<%=
|
31
|
+
<%= condition.class.human_attribute_name(:preferred_line_item_applicable) %>
|
32
32
|
<% end %>
|
33
33
|
</div>
|
34
34
|
</div>
|
35
35
|
<% else %>
|
36
36
|
<p>
|
37
|
-
<%= SolidusFriendlyPromotions::
|
37
|
+
<%= SolidusFriendlyPromotions::Conditions::LineItemOptionValue.human_attribute_name(:description) %>
|
38
38
|
</p>
|
39
39
|
<table>
|
40
40
|
<thead>
|
@@ -48,7 +48,7 @@
|
|
48
48
|
</tr>
|
49
49
|
</thead>
|
50
50
|
<tbody>
|
51
|
-
<%
|
51
|
+
<% condition.preferred_eligible_values.each do |product_id, option_value_ids| %>
|
52
52
|
<tr>
|
53
53
|
<td>
|
54
54
|
<%= Spree::Product.find(product_id).name %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<%= fields_for param_prefix, condition do |form| %>
|
5
|
+
<div class="field products_condition_products">
|
6
|
+
<%= form.label :product_ids_string, t('solidus_friendly_promotions.product_condition.choose_products') %>
|
7
|
+
<%= form.hidden_field :product_ids_string, value: condition.product_ids.join(","), class: "fullwidth", is: "product-picker" %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form-group">
|
11
|
+
<%
|
12
|
+
match_policy_options = options_for_select(
|
13
|
+
SolidusFriendlyPromotions::Conditions::Product::MATCH_POLICIES.map { |s| [t("solidus_friendly_promotions.product_condition.match_#{s}"),s] },
|
14
|
+
condition.preferred_match_policy
|
15
|
+
)
|
16
|
+
%>
|
17
|
+
<% select = form.select :preferred_match_policy, match_policy_options %>
|
18
|
+
<%= form.label :preferred_match_policy, t('solidus_friendly_promotions.product_condition.label', select: select).html_safe %>
|
19
|
+
</label>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<div class="form-group">
|
23
|
+
<%= form.label :preferred_line_item_applicable do %>
|
24
|
+
<%= form.check_box :preferred_line_item_applicable %>
|
25
|
+
<%= condition.class.human_attribute_name(:preferred_line_item_applicable) %>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<p>
|
2
|
-
<%=
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
3
|
</p>
|
4
4
|
<div class="form-group">
|
5
|
-
<%= label_tag "#{param_prefix}_preferred_shipping_method_ids", SolidusFriendlyPromotions::
|
5
|
+
<%= label_tag "#{param_prefix}_preferred_shipping_method_ids", SolidusFriendlyPromotions::Conditions::ShippingMethod.human_attribute_name(:preferred_shipping_method_ids) %>
|
6
6
|
<%= select_tag "#{param_prefix}[preferred_shipping_method_ids]",
|
7
7
|
options_from_collection_for_select(
|
8
|
-
Spree::ShippingMethod.all, :id, :name,
|
8
|
+
Spree::ShippingMethod.all, :id, :name, condition.preferred_shipping_method_ids
|
9
9
|
), class: 'select2 fullwidth', multiple: true %>
|
10
10
|
</div>
|