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,21 @@
1
+ <div class="fullwidth promo-condition-option-value d-flex align-content-stretch mb-3">
2
+ <div class="mr-2" style="flex-grow: 1;">
3
+ <input
4
+ is="product-picker"
5
+ class="w-100"
6
+ data-action="select2Change->product-option-values#propagate_product_id_to_value_input"
7
+ type="hidden"
8
+ value="<%= product_option_values[0] %>"
9
+ >
10
+ </div>
11
+ <div class="mr-2 ml-2" style="flex-grow: 1;">
12
+ <input
13
+ is="option-value-picker"
14
+ class="fullwidth"
15
+ name="<%= form.object_name %>[preferred_eligible_values][<%= product_option_values[0] %>]"
16
+ type="hidden"
17
+ value="<%= product_option_values[1].join(",") %>"
18
+ >
19
+ </div>
20
+ <a class="fa fa-trash remove p-2" data-action="click->product-option-values#remove_row"></a>
21
+ </div>
@@ -0,0 +1,26 @@
1
+ <div class="card bg-light mb-3 ">
2
+ <div class="card-header">
3
+ <%= condition.class.model_name.human %>
4
+ <span class="float-right">
5
+ <% if can?(:destroy, condition) %>
6
+ <%= link_to_with_icon 'trash', '', solidus_promotions.admin_promotion_benefit_condition_path(@promotion, condition.benefit, condition), method: :delete, class: 'delete' %>
7
+ <% end %>
8
+ </span>
9
+ </div>
10
+ <div class="card-body">
11
+ <%= form_with model: condition, scope: :condition, url: solidus_promotions.admin_promotion_benefit_condition_path(@promotion, condition.benefit, condition), method: :patch do |form| %>
12
+ <% param_prefix = "promotion[conditions_attributes][#{condition.id}]" %>
13
+ <%= hidden_field_tag "#{param_prefix}[id]", condition.id %>
14
+ <%= render partial: "spree/shared/error_messages", locals: { target: condition } %>
15
+ <%= render condition, condition: condition, param_prefix: "condition", form: form %>
16
+
17
+ <% if condition.updateable? %>
18
+ <div class="row">
19
+ <div class="col-12">
20
+ <%= form.submit(t(:update, scope: [:solidus_promotions, :crud]), class: "btn btn-secondary float-right") %>
21
+ </div>
22
+ </div>
23
+ <% end %>
24
+ <% end %>
25
+ </div>
26
+ </div>
@@ -0,0 +1,26 @@
1
+ <%= turbo_frame_tag condition.benefit, "new_condition" do %>
2
+ <div class="card bg-light mb-3">
3
+ <div class="card-header">
4
+ <%= t(:add_condition, scope: :solidus_promotions) %>
5
+ </div>
6
+ <div class="card-body">
7
+ <%= render 'solidus_promotions/admin/conditions/type_select', benefit: condition.benefit %>
8
+ <% flash.each do |severity, message| %>
9
+ <%= content_tag(:div, "", data: { controller: :flash, severity: severity, message: message }) %>
10
+ <% end %>
11
+ <% if condition.valid? %>
12
+ <%= form_with model: condition, scope: "condition", url: solidus_promotions.admin_promotion_benefit_conditions_path(@promotion, condition.benefit), data: { turbo: false } do |form| %>
13
+ <%= hidden_field_tag "condition[type]", condition.class.name %>
14
+ <%= render condition, condition: condition, param_prefix: "condition", form: form %>
15
+
16
+ <div class="row">
17
+ <div class="col-12">
18
+ <%= form.submit(t(:add, scope: [:solidus_promotions, :crud]), class: "btn btn-secondary float-right") %>
19
+ </div>
20
+ </div>
21
+
22
+ <% end %>
23
+ <% end %>
24
+ </div>
25
+ </div>
26
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <%= form_with(
2
+ model: @condition || benefit.conditions.build,
3
+ scope: :condition,
4
+ url: solidus_promotions.new_admin_promotion_benefit_condition_path(@promotion, benefit),
5
+ method: :get,
6
+ class: "mb-3"
7
+ ) do |form| %>
8
+ <%= form.label :type %>
9
+ <%= admin_hint SolidusPromotions::Condition.human_attribute_name(:type), t(:conditions, scope: [:solidus_promotions, :hints, "solidus_promotions/benefit"]) %>
10
+ <%=
11
+ form.select :type,
12
+ options_for_condition_types(benefit, @condition),
13
+ {
14
+ include_blank: t(:choose_condition, scope: 'solidus_promotions')
15
+ },
16
+ class: 'custom-select fullwidth',
17
+ onchange: 'this.form.requestSubmit()',
18
+ required: true
19
+ %>
20
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render "new_condition", condition: @condition %>
@@ -0,0 +1,14 @@
1
+ <%= render partial: 'spree/shared/error_messages', locals: { target: @promotion_category } %>
2
+
3
+ <div class='row'>
4
+ <div class='col-4'>
5
+ <%= f.field_container :name do %>
6
+ <%= f.label :name %>
7
+ <%= f.text_field :name, class: 'fullwidth' %>
8
+ <% end %>
9
+ <%= f.field_container :code do %>
10
+ <%= f.label :code %>
11
+ <%= f.text_field :code, class: 'fullwidth' %>
12
+ <% end %>
13
+ </div>
14
+ </div>
@@ -0,0 +1,10 @@
1
+ <% admin_breadcrumb(link_to plural_resource_name(SolidusPromotions::Promotion), solidus_promotions.admin_promotions_path) %>
2
+ <% admin_breadcrumb(link_to plural_resource_name(SolidusPromotions::PromotionCategory), solidus_promotions.admin_promotion_categories_path) %>
3
+ <% admin_breadcrumb(@promotion_category.name) %>
4
+
5
+ <%= form_for @promotion_category, url: object_url, method: :put do |f| %>
6
+ <fieldset class="no-border-top">
7
+ <%= render partial: 'form', locals: { f: f } %>
8
+ <%= render partial: 'spree/admin/shared/edit_resource_links' %>
9
+ </fieldset>
10
+ <% end %>
@@ -0,0 +1,47 @@
1
+ <% admin_breadcrumb(link_to plural_resource_name(SolidusPromotions::Promotion), solidus_promotions.admin_promotions_path) %>
2
+ <% admin_breadcrumb(plural_resource_name(SolidusPromotions::PromotionCategory)) %>
3
+
4
+ <% content_for :page_actions do %>
5
+ <% if can?(:create, SolidusPromotions::PromotionCategory) %>
6
+ <li>
7
+ <%= link_to t('solidus_promotions.new_promotion_category'), solidus_promotions.new_admin_promotion_category_path, class: 'btn btn-primary' %>
8
+ </li>
9
+ <% end %>
10
+ <% end %>
11
+
12
+ <% if @promotion_categories.any? %>
13
+ <table class="index">
14
+ <colgroup>
15
+ <col style="width: 40%">
16
+ <col style="width: 40%">
17
+ <col style="width: 20%">
18
+ </colgroup>
19
+ <thead>
20
+ <th><%= SolidusPromotions::PromotionCategory.human_attribute_name :name %></th>
21
+ <th><%= SolidusPromotions::PromotionCategory.human_attribute_name :code %></th>
22
+ <th class='actions'></th>
23
+ </thead>
24
+ <tbody>
25
+ <% @promotion_categories.each do |category| %>
26
+ <tr>
27
+ <td><%= category.name %></td>
28
+ <td><%= category.code %></td>
29
+ <td class="actions">
30
+ <% if can?(:update, category) %>
31
+ <%= link_to_edit category, no_text: true %>
32
+ <% end %>
33
+ <% if can?(:destroy, category) %>
34
+ <%= link_to_delete category, no_text: true %>
35
+ <% end %>
36
+ </td>
37
+ </tr>
38
+ <% end %>
39
+ </tbody>
40
+ </table>
41
+ <% else %>
42
+ <div class="no-objects-found">
43
+ <%= render 'spree/admin/shared/no_objects_found',
44
+ resource: SolidusPromotions::PromotionCategory,
45
+ new_resource_url: new_object_url %>
46
+ </div>
47
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <% admin_breadcrumb(link_to plural_resource_name(SolidusPromotions::Promotion), solidus_promotions.admin_promotions_path) %>
2
+ <% admin_breadcrumb(link_to plural_resource_name(SolidusPromotions::PromotionCategory), solidus_promotions.admin_promotion_categories_path) %>
3
+ <% admin_breadcrumb(t('solidus_promotions.new_promotion_category')) %>
4
+
5
+ <%= form_for :promotion_category, url: collection_url do |f| %>
6
+ <fieldset class="no-border-top">
7
+ <%= render partial: 'form', locals: { f: f } %>
8
+ <%= render partial: 'spree/admin/shared/new_resource_links' %>
9
+ </fieldset>
10
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <div class="form-group">
2
+ <%= batch.label :base_code, class: "required" %>
3
+ <%= batch.text_field :base_code, class: "fullwidth", required: true %>
4
+ </div>
5
+ <div class="form-group">
6
+ <%= batch.label :number_of_codes, class: "required" %>
7
+ <%= batch.number_field :number_of_codes, class: "fullwidth", min: 1, required: true %>
8
+ </div>
9
+ <div class="form-group">
10
+ <%= batch.label :join_characters %>
11
+ <%= batch.text_field :join_characters, class: "fullwidth" %>
12
+ </div>
13
+ <% unless promotion_id %>
14
+ <div class="form-group">
15
+ <%= f.label :per_code_usage_limit %>
16
+ <%= f.text_field :per_code_usage_limit, class: "fullwidth" %>
17
+ </div>
18
+ <% end %>
19
+ <div class="form-group">
20
+ <%= batch.label :email %>
21
+ <%= batch.text_field :email, class: "fullwidth" %>
22
+ </div>
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ CSV.generate do |csv|
4
+ csv << ["Code"]
5
+ @promotion_code_batch.promotion_codes.order(:id).pluck(:value).each do |value|
6
+ csv << [value]
7
+ end
8
+ end
@@ -0,0 +1,65 @@
1
+ <% admin_breadcrumb(link_to plural_resource_name(SolidusPromotions::Promotion), solidus_promotions.admin_promotions_path) %>
2
+ <% admin_breadcrumb(link_to @promotion.name, solidus_promotions.edit_admin_promotion_path(@promotion.id)) %>
3
+ <% admin_breadcrumb(plural_resource_name(SolidusPromotions::PromotionCodeBatch)) %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <% if can?(:create, SolidusPromotions::PromotionCodeBatch) %>
8
+ <%= link_to t('solidus_promotions.new_promotion_code_batch'), new_object_url, class: 'btn btn-primary' %>
9
+ <% end %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <% if @promotion_code_batches.any? %>
14
+ <table>
15
+ <thead>
16
+ <tr>
17
+ <th><%= SolidusPromotions::PromotionCodeBatch.human_attribute_name(:base_code) %></th>
18
+ <th><%= SolidusPromotions::PromotionCodeBatch.human_attribute_name(:total_codes) %></th>
19
+ <th><%= SolidusPromotions::PromotionCodeBatch.human_attribute_name(:status) %></th>
20
+ <th><%= SolidusPromotions::PromotionCodeBatch.human_attribute_name(:email) %></th>
21
+ </tr>
22
+ </thead>
23
+ <tbody>
24
+ <% @promotion_code_batches.each do |promotion_code_batch| %>
25
+ <tr>
26
+ <td><%= promotion_code_batch.base_code %></td>
27
+ <td><%= promotion_code_batch.number_of_codes %></td>
28
+ <td>
29
+ <% if promotion_code_batch.error.present? %>
30
+ <%= t(
31
+ "solidus_promotions.promotion_code_batches.errored",
32
+ error: promotion_code_batch.error
33
+ ) %>
34
+ <% elsif promotion_code_batch.finished? %>
35
+ <%= t(
36
+ "solidus_promotions.promotion_code_batches.finished",
37
+ number_of_codes: promotion_code_batch.number_of_codes
38
+ ) %>
39
+ <%= link_to(
40
+ t('solidus_promotions.download_promotion_codes_list'),
41
+ admin_promotion_promotion_code_batch_download_path(
42
+ promotion_code_batch_id: promotion_code_batch.id,
43
+ format: :csv
44
+ )
45
+ ) %>
46
+ <% else %>
47
+ <%= t(
48
+ "solidus_promotions.promotion_code_batches.processing",
49
+ number_of_codes: promotion_code_batch.number_of_codes,
50
+ number_of_codes_processed: promotion_code_batch.promotion_codes.count
51
+ ) %>
52
+ <% end %>
53
+ </td>
54
+ <td><%= promotion_code_batch.email %></td>
55
+ </tr>
56
+ <% end %>
57
+ </tbody>
58
+ </table>
59
+ <% else %>
60
+ <div class="no-objects-found">
61
+ <%= render 'spree/admin/shared/no_objects_found',
62
+ resource: SolidusPromotions::PromotionCodeBatch,
63
+ new_resource_url: new_object_url %>
64
+ </div>
65
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <% admin_breadcrumb(link_to plural_resource_name(SolidusPromotions::Promotion), solidus_promotions.admin_promotions_path) %>
2
+ <% admin_breadcrumb(link_to @promotion.name, solidus_promotions.admin_promotion_path(@promotion.id)) %>
3
+ <% admin_breadcrumb(plural_resource_name(SolidusPromotions::PromotionCodeBatch)) %>
4
+ <%= form_for :promotion_code_batch, url: collection_url do |batch| %>
5
+ <%= batch.hidden_field :promotion_id, value: params[:promotion_id] %>
6
+ <%= render partial: 'form_fields', locals: {batch: batch, promotion_id: params[:promotion_id]} %>
7
+ <%= batch.submit t('spree.actions.create'), class: 'btn btn-primary' %>
8
+ <% end %>
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ CSV.generate do |csv|
4
+ csv << ["Code"]
5
+ @promotion_codes.order(:id).pluck(:value).each do |value|
6
+ csv << [value]
7
+ end
8
+ end
@@ -0,0 +1,32 @@
1
+ <% admin_breadcrumb link_to plural_resource_name(SolidusPromotions::Promotion), solidus_promotions.admin_promotions_path %>
2
+ <% admin_breadcrumb link_to(@promotion.name, solidus_promotions.edit_admin_promotion_path(@promotion)) %>
3
+ <% admin_breadcrumb plural_resource_name(SolidusPromotions::PromotionCode) %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <% if can?(:create, SolidusPromotions::PromotionCode) && !@promotion.apply_automatically? %>
8
+ <%= link_to t('solidus_promotions.create_promotion_code'), solidus_promotions.new_admin_promotion_promotion_code_path(promotion_id: @promotion.id), class: 'btn btn-primary' %>
9
+ <% end %>
10
+
11
+ <%= link_to t('solidus_promotions.download_promotion_codes_list'), solidus_promotions.admin_promotion_promotion_codes_path(promotion_id: @promotion.id, format: :csv), class: 'btn btn-primary' %>
12
+ </li>
13
+ <% end %>
14
+
15
+ <div class="pagination-summary">
16
+ <%= page_entries_info(@promotion_codes) %>
17
+ </div>
18
+
19
+ <table>
20
+ <thead>
21
+ <th><%= SolidusPromotions::PromotionCode.human_attribute_name :value %></th>
22
+ </thead>
23
+ <tbody>
24
+ <% @promotion_codes.each do |promotion_code| %>
25
+ <tr>
26
+ <td><%= promotion_code.value %></td>
27
+ </tr>
28
+ <% end %>
29
+ </tbody>
30
+ </table>
31
+
32
+ <%= paginate @promotion_codes, theme: "solidus_admin" %>
@@ -0,0 +1,31 @@
1
+ <% admin_breadcrumb link_to plural_resource_name(SolidusPromotions::Promotion), solidus_promotions.admin_promotions_path %>
2
+ <% admin_breadcrumb link_to(@promotion.name, solidus_promotions.edit_admin_promotion_path(@promotion)) %>
3
+ <% admin_breadcrumb plural_resource_name(SolidusPromotions::PromotionCode) %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <%= link_to t('solidus_promotions.view_promotion_codes_list'), admin_promotion_promotion_codes_path(promotion_id: @promotion.id), class: 'btn btn-primary' %>
8
+
9
+ <%= link_to t('solidus_promotions.download_promotion_codes_list'), admin_promotion_promotion_codes_path(promotion_id: @promotion.id, format: :csv), class: 'btn btn-primary' %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <%= form_for [:admin, @promotion, @promotion_code], method: :post do |f| %>
14
+ <fieldset class="no-border-top">
15
+ <%= render partial: 'spree/shared/error_messages', locals: { target: @promotion_code } %>
16
+
17
+ <div class="row">
18
+ <div class="col-4">
19
+ <%= f.field_container :value do %>
20
+ <%= f.label :value, class: 'required' %>
21
+ <%= f.text_field :value, class: 'fullwidth', required: true %>
22
+ <% end %>
23
+ </div>
24
+ </div>
25
+
26
+ <div class="form-buttons filter-actions actions" data-hook="buttons">
27
+ <%= f.submit t('spree.actions.create'), class: 'btn btn-primary' %>
28
+ <%= link_to t('spree.actions.cancel'), solidus_promotions.admin_promotion_promotion_codes_url(@promotion), class: 'button' %>
29
+ </div>
30
+ </fieldset>
31
+ <% end %>
@@ -0,0 +1,124 @@
1
+ <%= render partial: 'spree/shared/error_messages', locals: { target: @promotion } %>
2
+ <fieldset class="form-group no-border-bottom no-border-top">
3
+ <div class="row">
4
+ <div id="general_fields" class="col-9">
5
+ <div class="row">
6
+ <div class="col-12">
7
+ <%= f.field_container :name do %>
8
+ <%= f.label :name, class: 'required' %>
9
+ <%= f.text_field :name, class: 'fullwidth', required: true %>
10
+ <% end %>
11
+
12
+ <%= f.field_container :customer_label do %>
13
+ <%= f.label :customer_label, class: 'required' %>
14
+ <%= f.text_field :customer_label, class: 'fullwidth', required: true %>
15
+ <% end %>
16
+
17
+ <%= f.field_container :description do %>
18
+ <%= f.label :description %><br>
19
+ <%= f.text_area :description, rows: 7, class: 'fullwidth' %>
20
+ <span class="info">
21
+ <%= t('spree.character_limit') %>
22
+ </span>
23
+ <% end %>
24
+
25
+ <%= f.field_container :category do %>
26
+ <%= f.label :promotion_category_id, SolidusPromotions::PromotionCategory.model_name.human %><br>
27
+ <%=
28
+ f.collection_select(:promotion_category_id, @promotion_categories, :id, :name, { include_blank: t('solidus_promotions.match_choices.none') },
29
+ { class: 'custom-select fullwidth' })
30
+ %>
31
+ <% end %>
32
+ </div>
33
+ </div>
34
+ </div>
35
+
36
+ <div id="expiry_fields" class="col-3">
37
+ <%= f.field_container :overall_usage_limit do %>
38
+ <%= f.label :usage_limit %><br>
39
+ <%= f.number_field :usage_limit, min: 0, class: 'fullwidth' %><br>
40
+ <span class="info">
41
+ <%= t('solidus_promotions.current_promotion_usage', count: @promotion.usage_count) %>
42
+ </span>
43
+ <% end %>
44
+
45
+ <% if @promotion.persisted? %>
46
+ <%= f.field_container :per_code_usage_limit do %>
47
+ <%= f.label :per_code_usage_limit %><br>
48
+ <%= f.number_field :per_code_usage_limit, min: 0, class: 'fullwidth' %><br>
49
+ <% end %>
50
+ <% end %>
51
+
52
+ <div id="starts_at_field" class="form-group">
53
+ <%= f.label :starts_at %>
54
+ <%= f.field_hint :starts_at %>
55
+ <%=
56
+ f.text_field :starts_at,
57
+ value: datepicker_field_value(@promotion.starts_at, with_time: true),
58
+ placeholder: t(".starts_at_placeholder"),
59
+ class: 'datepicker datepicker-from fullwidth',
60
+ data: { :'enable-time' => true, :'default-hour' => 0 }
61
+ %>
62
+ </div>
63
+
64
+ <div id="expires_at_field" class="form-group">
65
+ <%= f.label :expires_at %>
66
+ <%= f.field_hint :expires_at %>
67
+ <%=
68
+ f.text_field :expires_at,
69
+ value: datepicker_field_value(@promotion.expires_at,
70
+ with_time: true),
71
+ placeholder: t(".expires_at_placeholder"),
72
+ class: 'datepicker datepicker-to fullwidth',
73
+ data: { :'enable-time' => true, :'default-hour' => 0 }
74
+ %>
75
+ </div>
76
+ <div class="form-group">
77
+ <%= f.field_container :lane do %>
78
+ <%= f.label :lane %><br>
79
+ <%=
80
+ f.select(:lane, SolidusPromotions::Promotion.lane_options, {}, { class: 'custom-select fullwidth' })
81
+ %>
82
+ <% end %>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </fieldset>
87
+
88
+ <fieldset class="form-group row no-border-bottom">
89
+ <legend><%= t '.activation' %></legend>
90
+
91
+ <div class="col-4">
92
+ <%= f.field_container :apply_automatically do %>
93
+ <%= f.label :apply_automatically do %>
94
+ <%= f.check_box :apply_automatically, disabled: f.object.codes.any? || f.object.path.present? %>
95
+ <%= SolidusPromotions::Promotion.human_attribute_name(:apply_automatically) %>
96
+ <%= f.field_hint :promo_code_will_be_disabled %>
97
+ <% end %>
98
+ <% end %>
99
+ </div>
100
+
101
+ <% if f.object.new_record? || f.object.present? %>
102
+ <div class="col-4">
103
+ <%= f.field_container :path do %>
104
+ <%= f.label :path %>
105
+ <%= f.text_field :path, class: "fullwidth", disabled: f.object.apply_automatically || f.object.codes.present? %>
106
+ <% end %>
107
+ </div>
108
+ <% end %>
109
+
110
+ <div class="col-4">
111
+ <% if f.object.new_record? %>
112
+ <div id="promotion_single_code" class="form-group">
113
+ <%= label_tag :single_code, SolidusPromotions::PromotionCode.model_name.human %>
114
+ <%= text_field_tag :single_code, @promotion.codes.first.try!(:value), class: "fullwidth", disabled: f.object.apply_automatically || f.object.path.present? %>
115
+ </div>
116
+ <% else %>
117
+ <div class="codes-present">
118
+ <p>
119
+ <%= t('.codes_present') %>
120
+ </p>
121
+ </div>
122
+ <% end %>
123
+ </div>
124
+ </fieldset>
@@ -0,0 +1,57 @@
1
+ <table class="index">
2
+ <thead>
3
+ <tr>
4
+ <th><%= sort_link @search, :name %></th>
5
+ <th><%= SolidusPromotions::Promotion.human_attribute_name(:code) %></th>
6
+ <th><%= SolidusPromotions::Promotion.human_attribute_name(:status) %></th>
7
+ <th><%= SolidusPromotions::Promotion.human_attribute_name(:usage) %></th>
8
+ <th><%= sort_link @search, :starts_at %></th>
9
+ <th><%= sort_link @search, :expires_at %></th>
10
+ <th><%= SolidusPromotions::Promotion.human_attribute_name(:lane) %></th>
11
+ <th><%= sort_link @search, :updated_at %></th>
12
+ <th class="actions"></th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <% promotions.each do |promotion| %>
17
+ <tr class="<%= 'deleted' if promotion.discarded? %>" id="<%= spree_dom_id promotion %>">
18
+ <td><%= promotion.name %></td>
19
+ <td>
20
+ <%= (promotion.codes.size == 1) ? promotion.codes.pluck(:value).first : t('solidus_promotions.number_of_codes', count: promotion.codes.size) %>
21
+ </td>
22
+ <td>
23
+ <span class="pill pill-<%= promotion.active? ? 'active' : 'inactive' %>">
24
+ <%= t(admin_promotion_status(promotion), scope: 'solidus_promotions.admin.promotion_status') %>
25
+ </span>
26
+ </td>
27
+ <td>
28
+ <% if promotion.usage_limit.nil? %>
29
+ <%= promotion.discounted_orders.exists? ? t(:say_yes, scope: :spree) : t(:say_no, scope: :spree) %>
30
+ <% else %>
31
+ <%= promotion.usage_count %> / <%= promotion.usage_limit %>
32
+ <% end %>
33
+ </td>
34
+ <td>
35
+ <%= l(promotion.starts_at, format: :short) if promotion.starts_at %>
36
+ </td>
37
+ <td>
38
+ <%= l(promotion.expires_at, format: :short) if promotion.expires_at %>
39
+ </td>
40
+ <td>
41
+ <%= SolidusPromotions::Promotion.human_enum_name(:lane, promotion.lane) %>
42
+ </td>
43
+ <td>
44
+ <%= l(promotion.updated_at, format: :short) %>
45
+ </td>
46
+ <td class="actions">
47
+ <% if can?(:edit, promotion) && !promotion.discarded? %>
48
+ <%= link_to_edit promotion, no_text: true %>
49
+ <% end %>
50
+ <% if can?(:destroy, promotion) && !promotion.discarded? %>
51
+ <%= link_to_delete promotion, no_text: true %>
52
+ <% end %>
53
+ </td>
54
+ </tr>
55
+ <% end %>
56
+ </tbody>
57
+ </table>
@@ -0,0 +1,78 @@
1
+ <% content_for :table_filter_title do %>
2
+ <%= t('spree.search') %>
3
+ <% end %>
4
+
5
+ <% content_for :table_filter do %>
6
+ <div data-hook="admin_promotions_index_search">
7
+ <%= search_form_for [:admin, search] do |f| %>
8
+ <div class="row">
9
+ <div class="col-4">
10
+ <div class="form-group">
11
+ <%= label_tag :q_name_cont, SolidusPromotions::Promotion.human_attribute_name(:name) %>
12
+ <%= f.text_field :name_cont, tabindex: 1, class: "w-100" %>
13
+ </div>
14
+ </div>
15
+
16
+ <div class="col-4">
17
+ <div class="form-group">
18
+ <%= label_tag :q_customer_label_cont, SolidusPromotions::Promotion.human_attribute_name(:customer_label) %>
19
+ <%= f.text_field :customer_label_cont, tabindex: 1, class: "w-100" %>
20
+ </div>
21
+ </div>
22
+
23
+ <div class="col-2">
24
+ <div class="form-group">
25
+ <%= label_tag :q_codes_value_cont, SolidusPromotions::Promotion.human_attribute_name(:code) %>
26
+ <%= f.text_field :codes_value_cont, tabindex: 1, class: "w-100" %>
27
+ </div>
28
+ </div>
29
+
30
+ <div class="col-2">
31
+ <div class="form-group">
32
+ <%= label_tag :q_path_cont, SolidusPromotions::Promotion.human_attribute_name(:path) %>
33
+ <%= f.text_field :path_cont, tabindex: 1, class: "w-100" %>
34
+ </div>
35
+ </div>
36
+
37
+ <div class="col-2">
38
+ <div class="date-range-filter form-group">
39
+ <%= label_tag :q_active, SolidusPromotions::Promotion.human_attribute_name(:active) %>
40
+ <%= f.text_field :active, value: params[:q][:active],
41
+ class: 'datepicker datepicker-from fullwidth',
42
+ data: { :'enable-time' => true, :'default-hour' => 0 } %>
43
+ </div>
44
+ </div>
45
+
46
+ <div class="col-2">
47
+ <div class="field checkbox">
48
+ <label>
49
+ <%= f.check_box :with_discarded, { checked: params[:q][:with_discarded] == 'true', class: 'js-with-discarded-input' }, 'true', 'false' %>
50
+ <%= t('spree.show_deleted') %>
51
+ </label>
52
+ </div>
53
+ </div>
54
+
55
+ <div class="col-2">
56
+ <div class="form-group">
57
+ <%= label_tag :q_promotion_category_id_eq, SolidusPromotions::PromotionCategory.model_name.human %><br>
58
+ <%= f.collection_select(:promotion_category_id_eq, @promotion_categories, :id, :name, { include_blank: t(:all, scope: :spree) }, { class: 'custom-select fullwidth' }) %>
59
+ </div>
60
+ </div>
61
+
62
+ <div class="col-2">
63
+ <div class="form-group">
64
+ <%= label_tag :q_lane_eq, SolidusPromotions::Promotion.human_attribute_name(:lane) %><br>
65
+ <%= f.select(:lane_eq, SolidusPromotions::Promotion.lane_options, { include_blank: t(:all, scope: :spree) }, { class: 'custom-select fullwidth' }) %>
66
+ </div>
67
+ </div>
68
+
69
+ </div>
70
+
71
+ <div class="actions filter-actions">
72
+ <div data-hook="admin_promotions_index_search_buttons">
73
+ <%= button_tag t('spree.filter_results'), class: 'btn btn-primary' %>
74
+ </div>
75
+ </div>
76
+ <% end %>
77
+ </div>
78
+ <% end %>