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.
Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile +1 -1
  4. data/MIGRATING.md +1 -1
  5. data/README.md +22 -16
  6. data/app/assets/config/solidus_friendly_promotions/manifest.js +7 -1
  7. data/app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb +85 -0
  8. data/app/controllers/solidus_friendly_promotions/admin/conditions_controller.rb +69 -0
  9. data/app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb +3 -3
  10. data/app/decorators/models/solidus_friendly_promotions/adjustment_decorator.rb +4 -4
  11. data/app/decorators/models/solidus_friendly_promotions/line_item_decorator.rb +2 -2
  12. data/app/decorators/models/solidus_friendly_promotions/order_decorator.rb +6 -6
  13. data/app/helpers/solidus_friendly_promotions/admin/benefits_helper.rb +19 -0
  14. data/app/helpers/solidus_friendly_promotions/admin/conditions_helper.rb +12 -0
  15. data/app/javascript/solidus_friendly_promotions/controllers/product_option_values_controller.js +1 -1
  16. data/app/javascript/solidus_friendly_promotions/web_components/number_with_currency.js +35 -0
  17. data/app/javascript/solidus_friendly_promotions/{jquery → web_components}/option_value_picker.js +8 -0
  18. data/app/javascript/solidus_friendly_promotions/web_components/product_picker.js +7 -0
  19. data/app/javascript/solidus_friendly_promotions/web_components/select_two.js +11 -0
  20. data/app/javascript/solidus_friendly_promotions/web_components/taxon_picker.js +7 -0
  21. data/app/javascript/solidus_friendly_promotions/web_components/user_picker.js +7 -0
  22. data/app/javascript/solidus_friendly_promotions/web_components/variant_picker.js +7 -0
  23. data/app/javascript/solidus_friendly_promotions.js +7 -11
  24. data/app/models/concerns/solidus_friendly_promotions/{actions/order_level_action.rb → benefits/order_benefit.rb} +2 -2
  25. data/app/models/concerns/solidus_friendly_promotions/{rules/line_item_applicable_order_rule.rb → conditions/line_item_applicable_order_condition.rb} +2 -2
  26. data/app/models/concerns/solidus_friendly_promotions/{rules/line_item_level_rule.rb → conditions/line_item_level_condition.rb} +2 -2
  27. data/app/models/concerns/solidus_friendly_promotions/{rules/order_level_rule.rb → conditions/order_level_condition.rb} +2 -2
  28. data/app/models/concerns/solidus_friendly_promotions/{rules/shipment_level_rule.rb → conditions/shipment_level_condition.rb} +2 -2
  29. data/app/models/solidus_friendly_promotions/{promotion_action.rb → benefit.rb} +48 -11
  30. data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_line_item.rb +6 -2
  31. data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_line_item_quantity_groups.rb +3 -3
  32. data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_shipment.rb +6 -2
  33. data/app/models/solidus_friendly_promotions/{actions → benefits}/create_discounted_item.rb +6 -7
  34. data/app/models/solidus_friendly_promotions/calculators/distributed_amount.rb +1 -1
  35. data/app/models/solidus_friendly_promotions/calculators/tiered_flat_rate.rb +1 -1
  36. data/app/models/solidus_friendly_promotions/calculators/tiered_percent.rb +1 -1
  37. data/app/models/solidus_friendly_promotions/calculators/tiered_percent_on_eligible_item_quantity.rb +4 -2
  38. data/app/models/solidus_friendly_promotions/{promotion_rule.rb → condition.rb} +13 -7
  39. data/app/models/solidus_friendly_promotions/condition_product.rb +8 -0
  40. data/app/models/solidus_friendly_promotions/condition_store.rb +8 -0
  41. data/app/models/solidus_friendly_promotions/condition_taxon.rb +8 -0
  42. data/app/models/solidus_friendly_promotions/{promotion_rules_user.rb → condition_user.rb} +2 -2
  43. data/app/models/solidus_friendly_promotions/{rules → conditions}/discounted_item_total.rb +3 -3
  44. data/app/models/solidus_friendly_promotions/{rules → conditions}/first_order.rb +3 -3
  45. data/app/models/solidus_friendly_promotions/{rules → conditions}/first_repeat_purchase_since.rb +3 -3
  46. data/app/models/solidus_friendly_promotions/{rules → conditions}/item_total.rb +5 -5
  47. data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_option_value.rb +3 -3
  48. data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_product.rb +8 -8
  49. data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_taxon.rb +8 -8
  50. data/app/models/solidus_friendly_promotions/{rules → conditions}/minimum_quantity.rb +8 -8
  51. data/app/models/solidus_friendly_promotions/{rules → conditions}/nth_order.rb +5 -5
  52. data/app/models/solidus_friendly_promotions/{rules → conditions}/one_use_per_user.rb +3 -3
  53. data/app/models/solidus_friendly_promotions/{rules → conditions}/option_value.rb +3 -3
  54. data/app/models/solidus_friendly_promotions/{rules → conditions}/product.rb +9 -9
  55. data/app/models/solidus_friendly_promotions/{rules → conditions}/shipping_method.rb +3 -3
  56. data/app/models/solidus_friendly_promotions/{rules → conditions}/store.rb +6 -6
  57. data/app/models/solidus_friendly_promotions/{rules → conditions}/taxon.rb +12 -12
  58. data/app/models/solidus_friendly_promotions/{rules → conditions}/user.rb +7 -7
  59. data/app/models/solidus_friendly_promotions/{rules → conditions}/user_logged_in.rb +3 -3
  60. data/app/models/solidus_friendly_promotions/{rules → conditions}/user_role.rb +3 -3
  61. data/app/models/solidus_friendly_promotions/eligibility_result.rb +1 -1
  62. data/app/models/solidus_friendly_promotions/eligibility_results.rb +7 -7
  63. data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/discount_order.rb +28 -29
  64. data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/load_promotions.rb +10 -11
  65. data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/persist_discounted_order.rb +2 -2
  66. data/app/models/solidus_friendly_promotions/order_promotion.rb +1 -1
  67. data/app/models/solidus_friendly_promotions/permission_sets/friendly_promotion_management.rb +1 -1
  68. data/app/models/solidus_friendly_promotions/promotion.rb +14 -43
  69. data/app/models/solidus_friendly_promotions/promotion_advertiser.rb +10 -0
  70. data/app/models/solidus_friendly_promotions/promotion_code.rb +1 -1
  71. data/app/models/solidus_friendly_promotions/shipping_rate_discount.rb +1 -1
  72. data/app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_line_item.html.erb +6 -0
  73. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/actions → benefit_fields}/_adjust_line_item_quantity_groups.html.erb +4 -4
  74. data/app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_shipment.html.erb +6 -0
  75. data/app/views/solidus_friendly_promotions/admin/benefit_fields/_calculator_fields.erb +11 -0
  76. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/actions → benefit_fields}/_create_discounted_item.html.erb +8 -6
  77. data/app/views/solidus_friendly_promotions/admin/benefits/_benefit.html.erb +50 -0
  78. data/app/views/solidus_friendly_promotions/admin/benefits/_calculator_select.html.erb +16 -0
  79. data/app/views/solidus_friendly_promotions/admin/benefits/_form.html.erb +3 -0
  80. data/app/views/solidus_friendly_promotions/admin/benefits/_new_benefit.html.erb +33 -0
  81. data/app/views/solidus_friendly_promotions/admin/benefits/_type_select.html.erb +16 -0
  82. data/app/views/solidus_friendly_promotions/admin/benefits/edit.html.erb +19 -0
  83. data/app/views/solidus_friendly_promotions/admin/benefits/new.html.erb +1 -0
  84. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/_default_fields.html.erb +1 -1
  85. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/distributed_amount/_fields.html.erb +3 -3
  86. data/app/views/solidus_friendly_promotions/admin/calculator_fields/flat_rate/_fields.html.erb +6 -0
  87. data/app/views/solidus_friendly_promotions/admin/calculator_fields/flexi_rate/_fields.html.erb +24 -0
  88. data/app/views/solidus_friendly_promotions/admin/calculator_fields/percent/_fields.html.erb +6 -0
  89. data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_flat_rate/_fields.html.erb +32 -0
  90. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_flat_rate/_tier_fields.html.erb +7 -8
  91. data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent/_fields.html.erb +47 -0
  92. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_percent/_tier_fields.html.erb +8 -7
  93. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_percent_on_eligible_item_quantity/_fields.html.erb +11 -9
  94. data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +35 -0
  95. data/app/views/solidus_friendly_promotions/admin/condition_fields/_first_order.html.erb +3 -0
  96. data/app/views/solidus_friendly_promotions/admin/condition_fields/_first_repeat_purchase_since.html.erb +7 -0
  97. data/app/views/solidus_friendly_promotions/admin/condition_fields/_item_total.html.erb +15 -0
  98. data/app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_option_value.html.erb +25 -0
  99. data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_line_item_product.html.erb +7 -7
  100. data/app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_taxon.html.erb +17 -0
  101. data/app/views/solidus_friendly_promotions/admin/condition_fields/_minimum_quantity.html.erb +5 -0
  102. data/app/views/solidus_friendly_promotions/admin/condition_fields/_nth_order.html.erb +15 -0
  103. data/app/views/solidus_friendly_promotions/admin/condition_fields/_one_use_per_user.html.erb +3 -0
  104. data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_option_value.html.erb +10 -10
  105. data/app/views/solidus_friendly_promotions/admin/condition_fields/_product.html.erb +28 -0
  106. data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_shipping_method.html.erb +3 -3
  107. data/app/views/solidus_friendly_promotions/admin/condition_fields/_store.html.erb +9 -0
  108. data/app/views/solidus_friendly_promotions/admin/condition_fields/_taxon.html.erb +28 -0
  109. data/app/views/solidus_friendly_promotions/admin/condition_fields/_user.html.erb +7 -0
  110. data/app/views/solidus_friendly_promotions/admin/condition_fields/_user_logged_in.html.erb +3 -0
  111. data/app/views/solidus_friendly_promotions/admin/condition_fields/_user_role.html.erb +15 -0
  112. data/app/views/solidus_friendly_promotions/admin/condition_fields/line_item_option_value/_option_value_fields.html.erb +21 -0
  113. data/app/views/solidus_friendly_promotions/admin/conditions/_condition.html.erb +26 -0
  114. data/app/views/solidus_friendly_promotions/admin/conditions/_new_condition.html.erb +26 -0
  115. data/app/views/solidus_friendly_promotions/admin/conditions/_type_select.html.erb +20 -0
  116. data/app/views/solidus_friendly_promotions/admin/conditions/new.html.erb +1 -0
  117. data/app/views/solidus_friendly_promotions/admin/promotion_code_batches/_form_fields.html.erb +5 -5
  118. data/app/views/solidus_friendly_promotions/admin/promotions/_form.html.erb +4 -4
  119. data/app/views/solidus_friendly_promotions/admin/promotions/_table_filter.html.erb +6 -6
  120. data/app/views/solidus_friendly_promotions/admin/promotions/edit.html.erb +7 -41
  121. data/app/views/solidus_friendly_promotions/admin/shared/_number_with_currency.html.erb +20 -0
  122. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_boolean.html.erb +14 -0
  123. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_decimal.html.erb +12 -0
  124. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
  125. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_integer.html.erb +12 -0
  126. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_password.html.erb +12 -0
  127. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_string.html.erb +12 -0
  128. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_text.html.erb +12 -0
  129. data/bin/sandbox +3 -3
  130. data/config/importmap.rb +2 -0
  131. data/config/locales/en.yml +128 -94
  132. data/config/routes.rb +3 -2
  133. data/db/migrate/20231011120928_add_db_comments_to_friendly_promotion_rules_taxons.rb +2 -2
  134. data/db/migrate/20231011142040_add_db_comments_to_friendly_promotion_rules_users.rb +1 -1
  135. data/db/migrate/20231011190222_add_db_comments_to_friendly_promotion_actions.rb +1 -1
  136. data/db/migrate/20240409093831_add_action_reference_to_rules.rb +34 -0
  137. data/db/migrate/20240506142650_remove_promotion_rules_promotion_id.rb +5 -0
  138. data/db/migrate/20240508080834_rename_promotion_rules_to_conditions.rb +19 -0
  139. data/db/migrate/20240508131514_rename_friendly_promotion_actions_to_friendly_benefits.rb +19 -0
  140. data/db/migrate/20240612113608_update_column_comments_for_benefits.rb +31 -0
  141. data/db/migrate/20240612114132_update_column_comments_for_conditions.rb +30 -0
  142. data/db/migrate/20240612115209_update_column_comments_for_condition_stores.rb +23 -0
  143. data/db/migrate/20240612115749_update_column_comments_for_condition_products.rb +22 -0
  144. data/db/migrate/20240612120411_update_column_comments_for_condition_taxons.rb +24 -0
  145. data/db/migrate/20240612121049_update_column_comments_for_condition_users.rb +23 -0
  146. data/lib/generators/solidus_friendly_promotions/install/templates/initializer.rb +30 -30
  147. data/lib/solidus_friendly_promotions/configuration.rb +11 -3
  148. data/lib/solidus_friendly_promotions/migrate_adjustments.rb +11 -11
  149. data/lib/solidus_friendly_promotions/promotion_map.rb +17 -17
  150. data/lib/solidus_friendly_promotions/promotion_migrator.rb +16 -16
  151. data/lib/solidus_friendly_promotions/testing_support/factories/friendly_promotion_factory.rb +8 -34
  152. data/lib/solidus_friendly_promotions/testing_support/factories/friendly_shipping_rate_discount_factory.rb +2 -2
  153. data/lib/solidus_friendly_promotions/version.rb +1 -1
  154. data/lib/tasks/solidus_friendly_promotions/migrate_adjustments.rake +2 -2
  155. data/solidus_friendly_promotions.gemspec +2 -2
  156. metadata +114 -86
  157. data/.rubocop_todo.yml +0 -157
  158. data/app/controllers/solidus_friendly_promotions/admin/promotion_actions_controller.rb +0 -103
  159. data/app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb +0 -105
  160. data/app/helpers/solidus_friendly_promotions/admin/promotion_actions_helper.rb +0 -23
  161. data/app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb +0 -25
  162. data/app/models/solidus_friendly_promotions/products_promotion_rule.rb +0 -8
  163. data/app/models/solidus_friendly_promotions/promotion_rules_store.rb +0 -8
  164. data/app/models/solidus_friendly_promotions/promotion_rules_taxon.rb +0 -8
  165. data/app/views/solidus_friendly_promotions/admin/promotion_actions/_calculator_select.html.erb +0 -16
  166. data/app/views/solidus_friendly_promotions/admin/promotion_actions/_form.html.erb +0 -3
  167. data/app/views/solidus_friendly_promotions/admin/promotion_actions/_promotion_action.html.erb +0 -29
  168. data/app/views/solidus_friendly_promotions/admin/promotion_actions/_type_select.html.erb +0 -14
  169. data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_line_item.html.erb +0 -6
  170. data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_shipment.html.erb +0 -6
  171. data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_calculator_fields.erb +0 -9
  172. data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/flat_rate/_fields.html.erb +0 -6
  173. data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_flat_rate/_fields.html.erb +0 -34
  174. data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent/_fields.html.erb +0 -34
  175. data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +0 -27
  176. data/app/views/solidus_friendly_promotions/admin/promotion_actions/edit.html.erb +0 -23
  177. data/app/views/solidus_friendly_promotions/admin/promotion_actions/new.html.erb +0 -26
  178. data/app/views/solidus_friendly_promotions/admin/promotion_rules/_promotion_rule.html.erb +0 -22
  179. data/app/views/solidus_friendly_promotions/admin/promotion_rules/_type_select.html.erb +0 -20
  180. data/app/views/solidus_friendly_promotions/admin/promotion_rules/new.html.erb +0 -24
  181. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_order.html.erb +0 -3
  182. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_repeat_purchase_since.html.erb +0 -6
  183. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_item_total.html.erb +0 -17
  184. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_option_value.html.erb +0 -25
  185. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_taxon.html.erb +0 -17
  186. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_minimum_quantity.html.erb +0 -5
  187. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_nth_order.html.erb +0 -15
  188. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_one_use_per_user.html.erb +0 -3
  189. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_product.html.erb +0 -44
  190. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_store.html.erb +0 -9
  191. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_taxon.html.erb +0 -44
  192. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user.html.erb +0 -7
  193. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_logged_in.html.erb +0 -3
  194. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_role.html.erb +0 -15
  195. 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,3 @@
1
+ <%= form.hidden_field :type %>
2
+ <%= form.hidden_field :calculator_type %>
3
+ <%= render form.object, benefit: form.object, param_prefix: form.object_name, form: form %>
@@ -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 "spree/admin/shared/preference_fields/#{calculator.preference_type(name)}",
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="field">
1
+ <div class="form-group">
2
2
  <%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
3
3
  <%= f.label :preferred_amount %>
4
- <%= render "spree/admin/shared/number_with_currency", f: f, amount_attr: :preferred_amount, currency_attr: :preferred_currency %>
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="field">
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>
@@ -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>
@@ -0,0 +1,6 @@
1
+ <div class="form-group">
2
+ <%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
3
+ <%= f.label :preferred_percent %>
4
+ <%= f.number_field :preferred_percent, step: 1, min: 1, max: 100, default: 1, class: "form-control" %>
5
+ <% end %>
6
+ </div>
@@ -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
- <a class="fa fa-trash remove" data-action="click->calculator-tiers#remove_association"></a>
3
- <div class="row">
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">$</span>
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="col-6">
16
+ <div class="mx-2">
18
17
  <div class="input-group">
19
18
  <div class="input-group-prepend">
20
- <span class="input-group-text">$</span>
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>
@@ -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
- <a class="fa fa-trash remove" data-action="click->calculator-tiers#remove_association"></a>
3
- <div class="row">
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="col-6">
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="text"
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
- <%= render "spree/admin/shared/preference_fields/#{calculator.preference_type(:base_percent)}",
2
- name: "#{prefix}[calculator_attributes][preferred_base_percent]",
3
- value: calculator.preferred_base_percent,
4
- label: calculator.class.human_attribute_name(:preferred_base_percent) %>
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="field">
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: 'custom-select fullwidth' }
19
+ { is: "select-two", class: 'fullwidth' }
18
20
  ) %>
19
21
  </div>
20
22
 
21
- <div class="field">
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/promotion_actions/calculators/tiered_percent/tier_fields", tier: [nil, nil], form: form %>
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/promotion_actions/calculators/tiered_percent/tier_fields", tier: tier, form: form %>
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,3 @@
1
+ <p>
2
+ <%= condition.class.human_attribute_name(:description) %>
3
+ </p>
@@ -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>
@@ -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
- <%= promotion_rule.class.human_attribute_name(:description) %>
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 products_rule_products">
7
- <%= label_tag "#{param_prefix}_product_ids_string", t('solidus_friendly_promotions.product_rule.choose_products') %>
8
- <%= hidden_field_tag "#{param_prefix}[product_ids_string]", promotion_rule.product_ids.join(","), class: "product_picker fullwidth" %>
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="field">
13
- <%= label_tag("#{param_prefix}_preferred_match_policy", promotion_rule.class.human_attribute_name(: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.promotion_rules.line_item_product.match_policies").to_a.map(&:reverse), promotion_rule.preferred_match_policy),
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,5 @@
1
+ <div class="form-group">
2
+ <% field_name = "#{param_prefix}[preferred_minimum_quantity]" %>
3
+ <%= label_tag field_name, condition.model_name.human %>
4
+ <%= number_field_tag field_name, condition.preferred_minimum_quantity, class: "fullwidth", min: 1 %>
5
+ </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>
@@ -0,0 +1,3 @@
1
+ <p>
2
+ <%= condition.class.human_attribute_name(:description) %>
3
+ </p>
@@ -2,39 +2,39 @@
2
2
 
3
3
  <% if context == :order %>
4
4
  <p>
5
- <%= promotion_rule.class.human_attribute_name(:description) %>
5
+ <%= condition.class.human_attribute_name(:description) %>
6
6
  </p>
7
- <div class="field promo-rule-option-values">
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="field">
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/promotion_rules/rules/line_item_option_value/option_value_fields", product_option_values: [nil, []], form: form %>
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/promotion_rules/rules/line_item_option_value/option_value_fields", product_option_values: product_option_values, form: form %>
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 "Add Row", "#", class: "btn btn-outline-primary", data: { action: "click->product-option-values#add_row" } %>
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="field">
28
+ <div class="form-group">
29
29
  <%= form.label :preferred_line_item_applicable do %>
30
30
  <%= form.check_box :preferred_line_item_applicable %>
31
- <%= promotion_rule.class.human_attribute_name(:preferred_line_item_applicable) %>
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::Rules::LineItemOptionValue.human_attribute_name(:description) %>
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
- <% promotion_rule.preferred_eligible_values.each do |product_id, option_value_ids| %>
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
- <%= promotion_rule.class.human_attribute_name(:description) %>
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::Rules::ShippingMethod.human_attribute_name(:preferred_shipping_method_ids) %>
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, promotion_rule.preferred_shipping_method_ids
8
+ Spree::ShippingMethod.all, :id, :name, condition.preferred_shipping_method_ids
9
9
  ), class: 'select2 fullwidth', multiple: true %>
10
10
  </div>