solidus_promotions 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintrc.json +10 -0
  3. data/.github/stale.yml +1 -0
  4. data/MIGRATING.md +184 -0
  5. data/README.md +122 -0
  6. data/Rakefile +20 -0
  7. data/app/assets/config/solidus_promotions/manifest.js +13 -0
  8. data/app/decorators/models/solidus_promotions/adjustment_decorator.rb +11 -0
  9. data/app/decorators/models/solidus_promotions/line_item_decorator.rb +27 -0
  10. data/app/decorators/models/solidus_promotions/order_decorator.rb +42 -0
  11. data/app/decorators/models/solidus_promotions/order_recalculator_decorator.rb +15 -0
  12. data/app/decorators/models/solidus_promotions/shipment_decorator.rb +14 -0
  13. data/app/decorators/models/solidus_promotions/shipping_rate_decorator.rb +29 -0
  14. data/app/helpers/solidus_promotions/admin/benefits_helper.rb +19 -0
  15. data/app/helpers/solidus_promotions/admin/conditions_helper.rb +14 -0
  16. data/app/helpers/solidus_promotions/admin/promotions_helper.rb +15 -0
  17. data/app/javascript/backend/solidus_promotions/controllers/application.js +9 -0
  18. data/app/javascript/backend/solidus_promotions/controllers/calculator_tiers_controller.js +37 -0
  19. data/app/javascript/backend/solidus_promotions/controllers/flash_controller.js +10 -0
  20. data/app/javascript/backend/solidus_promotions/controllers/index.js +8 -0
  21. data/app/javascript/backend/solidus_promotions/controllers/product_option_values_controller.js +62 -0
  22. data/app/javascript/backend/solidus_promotions/web_components/number_with_currency.js +35 -0
  23. data/app/javascript/backend/solidus_promotions/web_components/option_value_picker.js +52 -0
  24. data/app/javascript/backend/solidus_promotions/web_components/product_picker.js +7 -0
  25. data/app/javascript/backend/solidus_promotions/web_components/select_two.js +11 -0
  26. data/app/javascript/backend/solidus_promotions/web_components/taxon_picker.js +7 -0
  27. data/app/javascript/backend/solidus_promotions/web_components/user_picker.js +7 -0
  28. data/app/javascript/backend/solidus_promotions/web_components/variant_picker.js +7 -0
  29. data/app/javascript/backend/solidus_promotions.js +11 -0
  30. data/app/jobs/solidus_promotions/promotion_code_batch_job.rb +26 -0
  31. data/app/mailers/solidus_promotions/promotion_code_batch_mailer.rb +15 -0
  32. data/app/models/concerns/solidus_promotions/benefits/line_item_benefit.rb +15 -0
  33. data/app/models/concerns/solidus_promotions/benefits/order_benefit.rb +15 -0
  34. data/app/models/concerns/solidus_promotions/benefits/shipment_benefit.rb +15 -0
  35. data/app/models/concerns/solidus_promotions/calculators/promotion_calculator.rb +11 -0
  36. data/app/models/concerns/solidus_promotions/conditions/line_item_applicable_order_level_condition.rb +23 -0
  37. data/app/models/concerns/solidus_promotions/conditions/line_item_level_condition.rb +15 -0
  38. data/app/models/concerns/solidus_promotions/conditions/order_level_condition.rb +15 -0
  39. data/app/models/concerns/solidus_promotions/conditions/shipment_level_condition.rb +15 -0
  40. data/app/models/concerns/solidus_promotions/discountable_amount.rb +21 -0
  41. data/app/models/solidus_promotions/benefit.rb +123 -0
  42. data/app/models/solidus_promotions/benefits/adjust_line_item.rb +13 -0
  43. data/app/models/solidus_promotions/benefits/adjust_line_item_quantity_groups.rb +107 -0
  44. data/app/models/solidus_promotions/benefits/adjust_shipment.rb +13 -0
  45. data/app/models/solidus_promotions/benefits/create_discounted_item.rb +49 -0
  46. data/app/models/solidus_promotions/calculators/distributed_amount.rb +31 -0
  47. data/app/models/solidus_promotions/calculators/flat_rate.rb +23 -0
  48. data/app/models/solidus_promotions/calculators/flexi_rate.rb +26 -0
  49. data/app/models/solidus_promotions/calculators/percent.rb +19 -0
  50. data/app/models/solidus_promotions/calculators/tiered_flat_rate.rb +58 -0
  51. data/app/models/solidus_promotions/calculators/tiered_percent.rb +68 -0
  52. data/app/models/solidus_promotions/calculators/tiered_percent_on_eligible_item_quantity.rb +40 -0
  53. data/app/models/solidus_promotions/condition.rb +61 -0
  54. data/app/models/solidus_promotions/condition_product.rb +8 -0
  55. data/app/models/solidus_promotions/condition_store.rb +8 -0
  56. data/app/models/solidus_promotions/condition_taxon.rb +8 -0
  57. data/app/models/solidus_promotions/condition_user.rb +8 -0
  58. data/app/models/solidus_promotions/conditions/discounted_item_total.rb +22 -0
  59. data/app/models/solidus_promotions/conditions/first_order.rb +31 -0
  60. data/app/models/solidus_promotions/conditions/first_repeat_purchase_since.rb +31 -0
  61. data/app/models/solidus_promotions/conditions/item_total.rb +75 -0
  62. data/app/models/solidus_promotions/conditions/line_item_option_value.rb +37 -0
  63. data/app/models/solidus_promotions/conditions/line_item_product.rb +56 -0
  64. data/app/models/solidus_promotions/conditions/line_item_taxon.rb +59 -0
  65. data/app/models/solidus_promotions/conditions/minimum_quantity.rb +42 -0
  66. data/app/models/solidus_promotions/conditions/nth_order.rb +40 -0
  67. data/app/models/solidus_promotions/conditions/one_use_per_user.rb +25 -0
  68. data/app/models/solidus_promotions/conditions/option_value.rb +28 -0
  69. data/app/models/solidus_promotions/conditions/product.rb +85 -0
  70. data/app/models/solidus_promotions/conditions/shipping_method.rb +19 -0
  71. data/app/models/solidus_promotions/conditions/store.rb +26 -0
  72. data/app/models/solidus_promotions/conditions/taxon.rb +98 -0
  73. data/app/models/solidus_promotions/conditions/user.rb +35 -0
  74. data/app/models/solidus_promotions/conditions/user_logged_in.rb +16 -0
  75. data/app/models/solidus_promotions/conditions/user_role.rb +42 -0
  76. data/app/models/solidus_promotions/distributed_amounts_handler.rb +39 -0
  77. data/app/models/solidus_promotions/eligibility_result.rb +5 -0
  78. data/app/models/solidus_promotions/eligibility_results.rb +47 -0
  79. data/app/models/solidus_promotions/item_discount.rb +21 -0
  80. data/app/models/solidus_promotions/migration_support/order_promotion_syncer.rb +54 -0
  81. data/app/models/solidus_promotions/order_adjuster/choose_discounts.rb +21 -0
  82. data/app/models/solidus_promotions/order_adjuster/discount_order.rb +93 -0
  83. data/app/models/solidus_promotions/order_adjuster/load_promotions.rb +53 -0
  84. data/app/models/solidus_promotions/order_adjuster/persist_discounted_order.rb +79 -0
  85. data/app/models/solidus_promotions/order_adjuster.rb +33 -0
  86. data/app/models/solidus_promotions/order_promotion.rb +23 -0
  87. data/app/models/solidus_promotions/permission_sets/solidus_promotion_management.rb +15 -0
  88. data/app/models/solidus_promotions/promotion.rb +163 -0
  89. data/app/models/solidus_promotions/promotion_advertiser.rb +10 -0
  90. data/app/models/solidus_promotions/promotion_category.rb +9 -0
  91. data/app/models/solidus_promotions/promotion_code/batch_builder.rb +73 -0
  92. data/app/models/solidus_promotions/promotion_code.rb +56 -0
  93. data/app/models/solidus_promotions/promotion_code_batch.rb +25 -0
  94. data/app/models/solidus_promotions/promotion_finder.rb +10 -0
  95. data/app/models/solidus_promotions/promotion_handler/coupon.rb +113 -0
  96. data/app/models/solidus_promotions/promotion_handler/page.rb +30 -0
  97. data/app/models/solidus_promotions/shipping_rate_discount.rb +11 -0
  98. data/app/subscribers/solidus_promotions/order_promotion_subscriber.rb +20 -0
  99. data/bin/rails +13 -0
  100. data/config/importmap.rb +14 -0
  101. data/config/locales/en.yml +376 -0
  102. data/config/locales/promotion_categories.en.yml +6 -0
  103. data/config/locales/promotions.en.yml +6 -0
  104. data/config/routes.rb +38 -0
  105. data/db/migrate/20230703101637_create_promotions.rb +25 -0
  106. data/db/migrate/20230703113625_create_promotion_benefits.rb +15 -0
  107. data/db/migrate/20230703141116_create_promotion_categories.rb +14 -0
  108. data/db/migrate/20230703143943_create_promotion_conditions.rb +12 -0
  109. data/db/migrate/20230704083830_add_condition_join_tables.rb +31 -0
  110. data/db/migrate/20230704102444_create_promotion_codes.rb +11 -0
  111. data/db/migrate/20230704102656_create_promotion_code_batches.rb +34 -0
  112. data/db/migrate/20230705171556_create_order_promotions.rb +11 -0
  113. data/db/migrate/20230725074235_create_shipping_rate_discounts.rb +12 -0
  114. data/db/migrate/20231011100059_add_db_comments_to_order_promotions.rb +61 -0
  115. data/db/migrate/20231011120928_add_db_comments_to_condition_taxons.rb +54 -0
  116. data/db/migrate/20231011131324_add_db_comments_to_conditions.rb +60 -0
  117. data/db/migrate/20231011142040_add_db_comments_to_condition_users.rb +53 -0
  118. data/db/migrate/20231011155822_add_db_comments_to_promotions.rb +123 -0
  119. data/db/migrate/20231011163030_add_db_comments_to_promotion_codes.rb +60 -0
  120. data/db/migrate/20231011173312_add_db_comments_to_promotion_code_batches.rb +91 -0
  121. data/db/migrate/20231011184205_add_db_comments_to_condition_stores.rb +53 -0
  122. data/db/migrate/20231011190222_add_db_comments_to_benefits.rb +61 -0
  123. data/db/migrate/20231012020928_add_db_comments_to_condition_products.rb +52 -0
  124. data/db/migrate/20231012120928_add_db_comments_to_promotion_categories.rb +52 -0
  125. data/db/migrate/20231104135812_add_managed_by_order_benefit_to_line_items.rb +5 -0
  126. data/lib/components/admin/solidus_admin/orders/show/adjustments/index/source/solidus_promotions_benefit/component.rb +17 -0
  127. data/lib/components/admin/solidus_promotions/orders/index/component.rb +15 -0
  128. data/lib/components/admin/solidus_promotions/orders/index/component.yml +3 -0
  129. data/lib/components/admin/solidus_promotions/promotion_categories/index/component.rb +60 -0
  130. data/lib/components/admin/solidus_promotions/promotions/index/component.rb +108 -0
  131. data/lib/components/admin/solidus_promotions/promotions/index/component.yml +10 -0
  132. data/lib/controllers/admin/solidus_promotions/promotion_categories_controller.rb +29 -0
  133. data/lib/controllers/admin/solidus_promotions/promotions_controller.rb +46 -0
  134. data/lib/controllers/backend/solidus_promotions/admin/base_controller.rb +15 -0
  135. data/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb +85 -0
  136. data/lib/controllers/backend/solidus_promotions/admin/conditions_controller.rb +69 -0
  137. data/lib/controllers/backend/solidus_promotions/admin/promotion_categories_controller.rb +13 -0
  138. data/lib/controllers/backend/solidus_promotions/admin/promotion_code_batches_controller.rb +42 -0
  139. data/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb +58 -0
  140. data/lib/controllers/backend/solidus_promotions/admin/promotions_controller.rb +65 -0
  141. data/lib/generators/solidus_promotions/install/install_generator.rb +56 -0
  142. data/lib/generators/solidus_promotions/install/templates/initializer.rb +6 -0
  143. data/lib/solidus_promotions/configuration.rb +125 -0
  144. data/lib/solidus_promotions/engine.rb +115 -0
  145. data/lib/solidus_promotions/migrate_adjustments.rb +62 -0
  146. data/lib/solidus_promotions/migrate_order_promotions.rb +73 -0
  147. data/lib/solidus_promotions/promotion_map.rb +126 -0
  148. data/lib/solidus_promotions/promotion_migrator.rb +103 -0
  149. data/lib/solidus_promotions/testing_support/factories/completed_order_with_solidus_promotion_factory.rb +20 -0
  150. data/lib/solidus_promotions/testing_support/factories/solidus_order_promotion_factory.rb +8 -0
  151. data/lib/solidus_promotions/testing_support/factories/solidus_promotion_category_factory.rb +7 -0
  152. data/lib/solidus_promotions/testing_support/factories/solidus_promotion_code_factory.rb +8 -0
  153. data/lib/solidus_promotions/testing_support/factories/solidus_promotion_factory.rb +65 -0
  154. data/lib/solidus_promotions/testing_support/factories/solidus_shipping_rate_discount_factory.rb +14 -0
  155. data/lib/solidus_promotions/testing_support/factory_bot.rb +30 -0
  156. data/lib/solidus_promotions.rb +37 -0
  157. data/lib/tasks/solidus_promotions/migrate_adjustments.rake +17 -0
  158. data/lib/tasks/solidus_promotions/migrate_existing_promotions.rake +12 -0
  159. data/lib/tasks/solidus_promotions/migrate_order_promotions.rake +17 -0
  160. data/lib/views/backend/solidus_promotions/admin/benefit_fields/_adjust_line_item.html.erb +6 -0
  161. data/lib/views/backend/solidus_promotions/admin/benefit_fields/_adjust_line_item_quantity_groups.html.erb +13 -0
  162. data/lib/views/backend/solidus_promotions/admin/benefit_fields/_adjust_shipment.html.erb +6 -0
  163. data/lib/views/backend/solidus_promotions/admin/benefit_fields/_calculator_fields.erb +11 -0
  164. data/lib/views/backend/solidus_promotions/admin/benefit_fields/_create_discounted_item.html.erb +21 -0
  165. data/lib/views/backend/solidus_promotions/admin/benefits/_benefit.html.erb +50 -0
  166. data/lib/views/backend/solidus_promotions/admin/benefits/_calculator_select.html.erb +16 -0
  167. data/lib/views/backend/solidus_promotions/admin/benefits/_form.html.erb +3 -0
  168. data/lib/views/backend/solidus_promotions/admin/benefits/_new_benefit.html.erb +33 -0
  169. data/lib/views/backend/solidus_promotions/admin/benefits/_type_select.html.erb +16 -0
  170. data/lib/views/backend/solidus_promotions/admin/benefits/edit.html.erb +19 -0
  171. data/lib/views/backend/solidus_promotions/admin/benefits/new.html.erb +1 -0
  172. data/lib/views/backend/solidus_promotions/admin/calculator_fields/_default_fields.html.erb +6 -0
  173. data/lib/views/backend/solidus_promotions/admin/calculator_fields/distributed_amount/_fields.html.erb +18 -0
  174. data/lib/views/backend/solidus_promotions/admin/calculator_fields/flat_rate/_fields.html.erb +6 -0
  175. data/lib/views/backend/solidus_promotions/admin/calculator_fields/flexi_rate/_fields.html.erb +24 -0
  176. data/lib/views/backend/solidus_promotions/admin/calculator_fields/percent/_fields.html.erb +6 -0
  177. data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_flat_rate/_fields.html.erb +32 -0
  178. data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_flat_rate/_tier_fields.html.erb +31 -0
  179. data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent/_fields.html.erb +47 -0
  180. data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent/_tier_fields.html.erb +33 -0
  181. data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_fields.html.erb +36 -0
  182. data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +35 -0
  183. data/lib/views/backend/solidus_promotions/admin/condition_fields/_first_order.html.erb +3 -0
  184. data/lib/views/backend/solidus_promotions/admin/condition_fields/_first_repeat_purchase_since.html.erb +7 -0
  185. data/lib/views/backend/solidus_promotions/admin/condition_fields/_item_total.html.erb +15 -0
  186. data/lib/views/backend/solidus_promotions/admin/condition_fields/_line_item_option_value.html.erb +25 -0
  187. data/lib/views/backend/solidus_promotions/admin/condition_fields/_line_item_product.html.erb +21 -0
  188. data/lib/views/backend/solidus_promotions/admin/condition_fields/_line_item_taxon.html.erb +17 -0
  189. data/lib/views/backend/solidus_promotions/admin/condition_fields/_minimum_quantity.html.erb +5 -0
  190. data/lib/views/backend/solidus_promotions/admin/condition_fields/_nth_order.html.erb +15 -0
  191. data/lib/views/backend/solidus_promotions/admin/condition_fields/_one_use_per_user.html.erb +3 -0
  192. data/lib/views/backend/solidus_promotions/admin/condition_fields/_option_value.html.erb +63 -0
  193. data/lib/views/backend/solidus_promotions/admin/condition_fields/_product.html.erb +27 -0
  194. data/lib/views/backend/solidus_promotions/admin/condition_fields/_shipping_method.html.erb +10 -0
  195. data/lib/views/backend/solidus_promotions/admin/condition_fields/_store.html.erb +9 -0
  196. data/lib/views/backend/solidus_promotions/admin/condition_fields/_taxon.html.erb +27 -0
  197. data/lib/views/backend/solidus_promotions/admin/condition_fields/_user.html.erb +7 -0
  198. data/lib/views/backend/solidus_promotions/admin/condition_fields/_user_logged_in.html.erb +3 -0
  199. data/lib/views/backend/solidus_promotions/admin/condition_fields/_user_role.html.erb +15 -0
  200. data/lib/views/backend/solidus_promotions/admin/condition_fields/line_item_option_value/_option_value_fields.html.erb +21 -0
  201. data/lib/views/backend/solidus_promotions/admin/conditions/_condition.html.erb +26 -0
  202. data/lib/views/backend/solidus_promotions/admin/conditions/_new_condition.html.erb +26 -0
  203. data/lib/views/backend/solidus_promotions/admin/conditions/_type_select.html.erb +20 -0
  204. data/lib/views/backend/solidus_promotions/admin/conditions/new.html.erb +1 -0
  205. data/lib/views/backend/solidus_promotions/admin/promotion_categories/_form.html.erb +14 -0
  206. data/lib/views/backend/solidus_promotions/admin/promotion_categories/edit.html.erb +10 -0
  207. data/lib/views/backend/solidus_promotions/admin/promotion_categories/index.html.erb +47 -0
  208. data/lib/views/backend/solidus_promotions/admin/promotion_categories/new.html.erb +10 -0
  209. data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/_form_fields.html.erb +22 -0
  210. data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/download.csv.ruby +8 -0
  211. data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/index.html.erb +65 -0
  212. data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/new.html.erb +8 -0
  213. data/lib/views/backend/solidus_promotions/admin/promotion_codes/index.csv.ruby +8 -0
  214. data/lib/views/backend/solidus_promotions/admin/promotion_codes/index.html.erb +32 -0
  215. data/lib/views/backend/solidus_promotions/admin/promotion_codes/new.html.erb +31 -0
  216. data/lib/views/backend/solidus_promotions/admin/promotions/_form.html.erb +124 -0
  217. data/lib/views/backend/solidus_promotions/admin/promotions/_table.html.erb +57 -0
  218. data/lib/views/backend/solidus_promotions/admin/promotions/_table_filter.html.erb +78 -0
  219. data/lib/views/backend/solidus_promotions/admin/promotions/edit.html.erb +41 -0
  220. data/lib/views/backend/solidus_promotions/admin/promotions/index.html.erb +23 -0
  221. data/lib/views/backend/solidus_promotions/admin/promotions/new.html.erb +9 -0
  222. data/lib/views/backend/solidus_promotions/admin/shared/_number_with_currency.html.erb +20 -0
  223. data/lib/views/backend/solidus_promotions/admin/shared/_promotion_sub_menu.html.erb +14 -0
  224. data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_boolean.html.erb +14 -0
  225. data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_decimal.html.erb +12 -0
  226. data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
  227. data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_integer.html.erb +12 -0
  228. data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_password.html.erb +12 -0
  229. data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_string.html.erb +12 -0
  230. data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_text.html.erb +12 -0
  231. data/lib/views/backend/solidus_promotions/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb +2 -0
  232. data/lib/views/backend/solidus_promotions/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb +2 -0
  233. data/solidus_promotions.gemspec +33 -0
  234. metadata +366 -0
@@ -0,0 +1,16 @@
1
+ <%= form_with model: benefit, scope: :benefit, url: solidus_promotions.new_admin_promotion_benefit_path(@promotion), method: :get do |form| %>
2
+ <div class="form-group">
3
+ <%= form.label :type %>
4
+ <%= admin_hint SolidusPromotions::Benefit.human_attribute_name(:type), t(:type, scope: [:solidus_promotions, :hints, "solidus_promotions/benefit"]) %>
5
+ <%=
6
+ form.select :type,
7
+ options_for_benefit_types(form.object),
8
+ {
9
+ include_blank: t(:choose_benefit, scope: 'solidus_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_promotions.edit_admin_promotion_benefit_path(@promotion, @benefit), benefit: @benefit %>
3
+
4
+ <%=
5
+ form_with(
6
+ model: @benefit,
7
+ scope: :benefit,
8
+ url: solidus_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 %>
@@ -0,0 +1,6 @@
1
+ <% calculator.admin_form_preference_names.map do |name| %>
2
+ <%= render "solidus_promotions/admin/shared/preference_fields/#{calculator.preference_type(name)}",
3
+ name: "#{prefix}[calculator_attributes][preferred_#{name}]",
4
+ value: calculator.get_preference(name),
5
+ label: t(name.to_s, scope: 'spree', default: name.to_s.humanize) %>
6
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <div class="form-group">
2
+ <%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
3
+ <%= f.label :preferred_amount %>
4
+ <%= render "solidus_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_amount, currency_attr: :preferred_currency %>
5
+ <% end %>
6
+ </div>
7
+
8
+ <div class="form-group">
9
+ <p>
10
+ <%= admin_hint(
11
+ calculator.model_name.human,
12
+ calculator.class.human_attribute_name(:explanation)
13
+ ) %>
14
+
15
+ This amount will be the <strong>total</strong> discount spread amongst all
16
+ of the line items.
17
+ </p>
18
+ </div>
@@ -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_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_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_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_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
+ <%= SolidusPromotions::Calculators::TieredFlatRate.human_attribute_name(:order_item_total) %>
14
+ </div>
15
+ <div class="discount-label mx-2" style="flex-grow: 1">
16
+ <%= SolidusPromotions::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_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_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_promotions, :admin, :promotions, :calculator]), "#", class: "btn btn-outline-primary", data: { action: "click->calculator-tiers#add_association" } %>
30
+ </div>
31
+ </div>
32
+ </div>
@@ -0,0 +1,31 @@
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"><%= ::Money::Currency.find(currency).symbol %></span>
7
+ </div>
8
+ <input
9
+ class="js-base-input form-control"
10
+ data-action="calculator-tiers#propagate_base_to_value_input"
11
+ type="text"
12
+ value="<%= tier[0] %>"
13
+ >
14
+ </div>
15
+ </div>
16
+ <div class="mx-2">
17
+ <div class="input-group">
18
+ <div class="input-group-prepend">
19
+ <span class="input-group-text"><%= ::Money::Currency.find(currency).symbol %></span>
20
+ </div>
21
+ <input
22
+ class="js-value-input form-control"
23
+ name="<%= form.object_name %>[calculator_attributes][preferred_tiers][<%= tier[0] %>]"
24
+ type="text"
25
+ value="<%= tier[1] %>"
26
+ >
27
+ </div>
28
+ </div>
29
+ <a class="fa fa-trash remove p-2" data-action="click->calculator-tiers#remove_association"></a>
30
+ </div>
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
+ <%= SolidusPromotions::Calculators::TieredPercent.human_attribute_name(:order_item_total) %>
29
+ </div>
30
+ <div class="discount-label mx-2" style="flex-grow: 1">
31
+ <%= SolidusPromotions::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_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_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_promotions, :admin, :promotions, :calculator]), "#", class: "btn btn-outline-primary", data: { action: "click->calculator-tiers#add_association" } %>
45
+ </div>
46
+ </div>
47
+ </div>
@@ -0,0 +1,33 @@
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="text"
12
+ value="<%= tier[0] %>"
13
+ >
14
+ </div>
15
+ </div>
16
+ <div class="mx-2">
17
+ <div class="input-group">
18
+ <input
19
+ class="js-value-input form-control right-align"
20
+ name="<%= form.object_name %>[calculator_attributes][preferred_tiers][<%= tier[0] %>]"
21
+ type="number"
22
+ min="0"
23
+ max="100"
24
+ value="<%= tier[1] %>"
25
+ >
26
+ <div class="input-group-append">
27
+ <span class="input-group-text">%</span>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ <a class="fa fa-trash remove p-2" data-action="click->calculator-tiers#remove_association"></a>
32
+ </div>
33
+ </div>
@@ -0,0 +1,36 @@
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
+ <template data-calculator-tiers-target="template">
27
+ <%= render "solidus_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/tier_fields", tier: [nil, nil], form: form %>
28
+ </template>
29
+ <% form.object.calculator.preferred_tiers.each do |tier| %>
30
+ <%= render "solidus_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/tier_fields", tier: tier, form: form %>
31
+ <% end %>
32
+ <div class="mb-3" data-calculator-tiers-target="links">
33
+ <%= link_to t(:add_tier, scope: [:solidus_promotions, :admin, :promotions, :calculator]), "#", class: "btn btn-outline-primary", data: { action: "click->calculator-tiers#add_association" } %>
34
+ </div>
35
+ </div>
36
+ </div>
@@ -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_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_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_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_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>
@@ -0,0 +1,21 @@
1
+ <p>
2
+ <%= condition.class.human_attribute_name(:description) %>
3
+ </p>
4
+ <div class="row">
5
+ <div class="col-12">
6
+ <div class="field products_condition_products">
7
+ <%= label_tag "#{param_prefix}_product_ids_string", t('solidus_promotions.product_condition.choose_products') %>
8
+ <%= hidden_field_tag "#{param_prefix}[product_ids_string]", condition.product_ids.join(","), class: "fullwidth", is: "product-picker" %>
9
+ </div>
10
+ </div>
11
+ <div class="col-12">
12
+ <div class="form-group">
13
+ <%= label_tag("#{param_prefix}_preferred_match_policy", condition.class.human_attribute_name(:preferred_match_policy)) %>
14
+ <%= select_tag(
15
+ "#{param_prefix}[preferred_match_policy]",
16
+ options_for_select(I18n.t("solidus_promotions.conditions.line_item_product.match_policies").to_a.map(&:reverse), condition.preferred_match_policy),
17
+ class: "custom-select fullwidth"
18
+ ) %>
19
+ </div>
20
+ </div>
21
+ </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_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_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
+ <%= SolidusPromotions::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>
@@ -0,0 +1,63 @@
1
+ <% context = local_assigns[:context] || :order %>
2
+
3
+ <% if context == :order %>
4
+ <p>
5
+ <%= condition.class.human_attribute_name(:description) %>
6
+ </p>
7
+ <div class="field promo-condition-option-values">
8
+ <div class="param-prefix hidden" data-param-prefix="<%= param_prefix %>"></div>
9
+ <div class="row">
10
+ <div class="col-6"><%= label_tag nil, Spree::Product.model_name.human %></div>
11
+ <div class="col-6"><%= label_tag nil, plural_resource_name(Spree::OptionValue) %></div>
12
+ </div>
13
+
14
+ <div class="form-group">
15
+ <div data-controller="product-option-values">
16
+ <template data-product-option-values-target="template">
17
+ <%= render "solidus_promotions/admin/condition_fields/line_item_option_value/option_value_fields", product_option_values: [nil, []], form: form %>
18
+ </template>
19
+ <% form.object.preferred_eligible_values.each do |product_option_values| %>
20
+ <%= render "solidus_promotions/admin/condition_fields/line_item_option_value/option_value_fields", product_option_values: product_option_values, form: form %>
21
+ <% end %>
22
+ <div class="mb-3" data-product-option-values-target="links">
23
+ <%= link_to t(:add_product, scope: [:solidus_promotions, :option_value_condition]), "#", class: "btn btn-outline-primary", data: { action: "click->product-option-values#add_row" } %>
24
+ </div>
25
+ </div>
26
+ </div>
27
+
28
+ <div class="form-group">
29
+ <%= form.label :preferred_line_item_applicable do %>
30
+ <%= form.check_box :preferred_line_item_applicable %>
31
+ <%= condition.class.human_attribute_name(:preferred_line_item_applicable) %>
32
+ <% end %>
33
+ </div>
34
+ </div>
35
+ <% else %>
36
+ <p>
37
+ <%= SolidusPromotions::Conditions::LineItemOptionValue.human_attribute_name(:description) %>
38
+ </p>
39
+ <table>
40
+ <thead>
41
+ <tr>
42
+ <th>
43
+ <%= Spree::Product.model_name.human %>
44
+ </th>
45
+ <th>
46
+ <%= Spree::OptionValue.model_name.human(count: :other) %>
47
+ </th>
48
+ </tr>
49
+ </thead>
50
+ <tbody>
51
+ <% condition.preferred_eligible_values.each do |product_id, option_value_ids| %>
52
+ <tr>
53
+ <td>
54
+ <%= Spree::Product.find(product_id).name %>
55
+ </td>
56
+ <td>
57
+ <%= Spree::OptionValue.where(id: option_value_ids).map(&:name).join(", ") %>
58
+ </td>
59
+ </tr>
60
+ <% end %>
61
+ </tbody>
62
+ </table>
63
+ <% end %>
@@ -0,0 +1,27 @@
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_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
+ SolidusPromotions::Conditions::Product::MATCH_POLICIES.map { |s| [t("solidus_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_promotions.product_condition.label', select: select).html_safe %>
19
+ </div>
20
+
21
+ <div class="form-group">
22
+ <%= form.label :preferred_line_item_applicable do %>
23
+ <%= form.check_box :preferred_line_item_applicable %>
24
+ <%= condition.class.human_attribute_name(:preferred_line_item_applicable) %>
25
+ <% end %>
26
+ </div>
27
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <p>
2
+ <%= condition.class.human_attribute_name(:description) %>
3
+ </p>
4
+ <div class="form-group">
5
+ <%= label_tag "#{param_prefix}_preferred_shipping_method_ids", SolidusPromotions::Conditions::ShippingMethod.human_attribute_name(:preferred_shipping_method_ids) %>
6
+ <%= select_tag "#{param_prefix}[preferred_shipping_method_ids]",
7
+ options_from_collection_for_select(
8
+ Spree::ShippingMethod.all, :id, :name, condition.preferred_shipping_method_ids
9
+ ), class: 'select2 fullwidth', multiple: true %>
10
+ </div>
@@ -0,0 +1,9 @@
1
+ <p>
2
+ <%= condition.class.human_attribute_name(:description) %>
3
+ </p>
4
+ <div class="form-group">
5
+ <%= label_tag "#{param_prefix}[store_ids][]", Spree::Store.model_name.human(count: :other) %>
6
+ <%= select_tag "#{param_prefix}[store_ids][]",
7
+ options_from_collection_for_select(Spree::Store.all, :id, :name, condition.store_ids),
8
+ multiple: true, is: "select-two", class: "fullwidth" %>
9
+ </div>
@@ -0,0 +1,27 @@
1
+ <p>
2
+ <%= condition.class.human_attribute_name(:description) %>
3
+ </p>
4
+ <%= fields_for param_prefix, condition do |form| %>
5
+ <div class="field taxons_condition_taxons">
6
+ <%= form.label :taxon_ids_string, t('solidus_promotions.taxon_condition.choose_taxons') %>
7
+ <%= form.hidden_field :taxon_ids_string, value: condition.taxon_ids.join(","), is: "taxon-picker", class: "fullwidth" %>
8
+ </div>
9
+
10
+ <div class="form-group">
11
+ <%
12
+ match_policy_options = options_for_select(
13
+ SolidusPromotions::Conditions::Taxon::MATCH_POLICIES.map { |s| [t("solidus_promotions.taxon_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_promotions.taxon_condition.label', select: select).html_safe %>
19
+ </div>
20
+
21
+ <div class="form-group">
22
+ <%= form.label :preferred_line_item_applicable do %>
23
+ <%= form.check_box :preferred_line_item_applicable %>
24
+ <%= condition.class.human_attribute_name(:preferred_line_item_applicable) %>
25
+ <% end %>
26
+ </div>
27
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <p>
2
+ <%= condition.class.human_attribute_name(:description) %>
3
+ </p>
4
+ <div class="form-group">
5
+ <label><%= t('solidus_promotions.user_condition.choose_users') %></label><br>
6
+ <input type='hidden' name='<%= param_prefix %>[user_ids_string]' is="user-picker" class='fullwidth' value='<%= condition.user_ids.join(",") %>'>
7
+ </div>
@@ -0,0 +1,3 @@
1
+ <p>
2
+ <%= condition.class.human_attribute_name(:description) %>
3
+ </p>
@@ -0,0 +1,15 @@
1
+ <p>
2
+ <%= condition.class.human_attribute_name(:description) %>
3
+ </p>
4
+ <div class="form-group">
5
+ <%= label_tag "#{param_prefix}_preferred_role_ids", t('solidus_promotions.user_role_condition.choose_roles') %>
6
+ <%= select_tag "#{param_prefix}[preferred_role_ids]",
7
+ options_from_collection_for_select(
8
+ Spree::Role.all, :id, :name, condition.preferred_role_ids
9
+ ), class: 'fullwidth', is: 'select-two', multiple: true %>
10
+ </div>
11
+ <div class="form-group">
12
+ <label>
13
+ <%= t('solidus_promotions.user_role_condition.label', select: select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(SolidusPromotions::Conditions::UserRole::MATCH_POLICIES.map{ |s| [t("solidus_promotions.user_role_condition.match_#{s}"),s] }, condition.preferred_match_policy), { class: 'custom-select'})).html_safe %>
14
+ </label>
15
+ </div>