solidus_friendly_promotions 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +61 -0
- data/.gem_release.yml +5 -0
- data/.github/stale.yml +1 -0
- data/.github_changelog_generator +2 -0
- data/.gitignore +21 -0
- data/.rspec +2 -0
- data/.rubocop.yml +29 -0
- data/.rubocop_todo.yml +157 -0
- data/.standard.yml +4 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +42 -0
- data/LICENSE +26 -0
- data/MIGRATING.md +134 -0
- data/README.md +144 -0
- data/Rakefile +7 -0
- data/app/assets/config/solidus_friendly_promotions/manifest.js +7 -0
- data/app/controllers/solidus_friendly_promotions/admin/base_controller.rb +54 -0
- data/app/controllers/solidus_friendly_promotions/admin/promotion_actions_controller.rb +103 -0
- data/app/controllers/solidus_friendly_promotions/admin/promotion_categories_controller.rb +13 -0
- data/app/controllers/solidus_friendly_promotions/admin/promotion_code_batches_controller.rb +30 -0
- data/app/controllers/solidus_friendly_promotions/admin/promotion_codes_controller.rb +58 -0
- data/app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb +105 -0
- data/app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb +64 -0
- data/app/decorators/models/solidus_friendly_promotions/adjustment_decorator.rb +26 -0
- data/app/decorators/models/solidus_friendly_promotions/line_item_decorator.rb +7 -0
- data/app/decorators/models/solidus_friendly_promotions/order_decorator.rb +42 -0
- data/app/decorators/models/solidus_friendly_promotions/order_recalculator_decorator.rb +13 -0
- data/app/decorators/models/solidus_friendly_promotions/shipment_decorator.rb +14 -0
- data/app/decorators/models/solidus_friendly_promotions/shipping_rate_decorator.rb +29 -0
- data/app/helpers/solidus_friendly_promotions/admin/promotion_actions_helper.rb +23 -0
- data/app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb +25 -0
- data/app/javascript/solidus_friendly_promotions/controllers/application.js +9 -0
- data/app/javascript/solidus_friendly_promotions/controllers/calculator_tiers_controller.js +37 -0
- data/app/javascript/solidus_friendly_promotions/controllers/flash_controller.js +10 -0
- data/app/javascript/solidus_friendly_promotions/controllers/index.js +8 -0
- data/app/javascript/solidus_friendly_promotions/controllers/product_option_values_controller.js +62 -0
- data/app/javascript/solidus_friendly_promotions/jquery/option_value_picker.js +44 -0
- data/app/javascript/solidus_friendly_promotions.js +12 -0
- data/app/jobs/solidus_friendly_promotions/promotion_code_batch_job.rb +26 -0
- data/app/mailers/solidus_friendly_promotions/promotion_code_batch_mailer.rb +15 -0
- data/app/models/concerns/solidus_friendly_promotions/discountable_amount.rb +21 -0
- data/app/models/concerns/solidus_friendly_promotions/rules/line_item_applicable_order_rule.rb +23 -0
- data/app/models/concerns/solidus_friendly_promotions/rules/line_item_level_rule.rb +15 -0
- data/app/models/concerns/solidus_friendly_promotions/rules/order_level_rule.rb +15 -0
- data/app/models/concerns/solidus_friendly_promotions/rules/shipment_level_rule.rb +15 -0
- data/app/models/solidus_friendly_promotions/actions/adjust_line_item.rb +15 -0
- data/app/models/solidus_friendly_promotions/actions/adjust_line_item_quantity_groups.rb +116 -0
- data/app/models/solidus_friendly_promotions/actions/adjust_shipment.rb +15 -0
- data/app/models/solidus_friendly_promotions/calculators/distributed_amount.rb +37 -0
- data/app/models/solidus_friendly_promotions/calculators/flat_rate.rb +21 -0
- data/app/models/solidus_friendly_promotions/calculators/flexi_rate.rb +24 -0
- data/app/models/solidus_friendly_promotions/calculators/percent.rb +17 -0
- data/app/models/solidus_friendly_promotions/calculators/tiered_flat_rate.rb +56 -0
- data/app/models/solidus_friendly_promotions/calculators/tiered_percent.rb +66 -0
- data/app/models/solidus_friendly_promotions/distributed_amounts_handler.rb +43 -0
- data/app/models/solidus_friendly_promotions/eligibility_result.rb +5 -0
- data/app/models/solidus_friendly_promotions/eligibility_results.rb +48 -0
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/choose_discounts.rb +21 -0
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/discount_order.rb +76 -0
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/load_promotions.rb +54 -0
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/persist_discounted_order.rb +81 -0
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster.rb +25 -0
- data/app/models/solidus_friendly_promotions/item_discount.rb +21 -0
- data/app/models/solidus_friendly_promotions/migration_support/order_promotion_syncer.rb +54 -0
- data/app/models/solidus_friendly_promotions/order_promotion.rb +23 -0
- data/app/models/solidus_friendly_promotions/permission_sets/friendly_promotion_management.rb +15 -0
- data/app/models/solidus_friendly_promotions/products_promotion_rule.rb +8 -0
- data/app/models/solidus_friendly_promotions/promotion.rb +166 -0
- data/app/models/solidus_friendly_promotions/promotion_action.rb +73 -0
- data/app/models/solidus_friendly_promotions/promotion_category.rb +9 -0
- data/app/models/solidus_friendly_promotions/promotion_code/batch_builder.rb +72 -0
- data/app/models/solidus_friendly_promotions/promotion_code.rb +55 -0
- data/app/models/solidus_friendly_promotions/promotion_code_batch.rb +25 -0
- data/app/models/solidus_friendly_promotions/promotion_handler/coupon.rb +113 -0
- data/app/models/solidus_friendly_promotions/promotion_handler/page.rb +30 -0
- data/app/models/solidus_friendly_promotions/promotion_rule.rb +55 -0
- data/app/models/solidus_friendly_promotions/promotion_rules_store.rb +8 -0
- data/app/models/solidus_friendly_promotions/promotion_rules_taxon.rb +8 -0
- data/app/models/solidus_friendly_promotions/promotion_rules_user.rb +8 -0
- data/app/models/solidus_friendly_promotions/rules/discounted_item_total.rb +22 -0
- data/app/models/solidus_friendly_promotions/rules/first_order.rb +31 -0
- data/app/models/solidus_friendly_promotions/rules/first_repeat_purchase_since.rb +31 -0
- data/app/models/solidus_friendly_promotions/rules/item_total.rb +86 -0
- data/app/models/solidus_friendly_promotions/rules/line_item_option_value.rb +37 -0
- data/app/models/solidus_friendly_promotions/rules/line_item_product.rb +52 -0
- data/app/models/solidus_friendly_promotions/rules/line_item_taxon.rb +55 -0
- data/app/models/solidus_friendly_promotions/rules/minimum_quantity.rb +48 -0
- data/app/models/solidus_friendly_promotions/rules/nth_order.rb +40 -0
- data/app/models/solidus_friendly_promotions/rules/one_use_per_user.rb +25 -0
- data/app/models/solidus_friendly_promotions/rules/option_value.rb +28 -0
- data/app/models/solidus_friendly_promotions/rules/product.rb +85 -0
- data/app/models/solidus_friendly_promotions/rules/shipping_method.rb +19 -0
- data/app/models/solidus_friendly_promotions/rules/store.rb +26 -0
- data/app/models/solidus_friendly_promotions/rules/taxon.rb +98 -0
- data/app/models/solidus_friendly_promotions/rules/user.rb +35 -0
- data/app/models/solidus_friendly_promotions/rules/user_logged_in.rb +16 -0
- data/app/models/solidus_friendly_promotions/rules/user_role.rb +42 -0
- data/app/models/solidus_friendly_promotions/shipping_rate_discount.rb +11 -0
- data/app/models/solidus_friendly_promotions/simple_order_contents.rb +27 -0
- data/app/models/solidus_friendly_promotions.rb +7 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_calculator_select.html.erb +16 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_form.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_promotion_action.html.erb +29 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_type_select.html.erb +14 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_line_item.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_line_item_quantity_groups.html.erb +13 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_shipment.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_calculator_fields.erb +8 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/_default_fields.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/distributed_amount/_fields.html.erb +56 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/flat_rate/_fields.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_flat_rate/_fields.html.erb +34 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_flat_rate/_tier_fields.html.erb +32 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent/_fields.html.erb +34 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent/_tier_fields.html.erb +32 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/edit.html.erb +23 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/new.html.erb +26 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_categories/_form.html.erb +14 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_categories/edit.html.erb +10 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_categories/index.html.erb +47 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_categories/new.html.erb +10 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_codes/index.csv.ruby +8 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_codes/index.html.erb +32 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_codes/new.html.erb +31 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/_promotion_rule.html.erb +22 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/_type_select.html.erb +20 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/new.html.erb +24 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_order.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_repeat_purchase_since.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_item_total.html.erb +17 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_option_value.html.erb +25 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_product.html.erb +21 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_taxon.html.erb +17 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_minimum_quantity.html.erb +5 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_nth_order.html.erb +15 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_one_use_per_user.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_option_value.html.erb +63 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_product.html.erb +44 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_shipping_method.html.erb +10 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_store.html.erb +9 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_taxon.html.erb +44 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user.html.erb +7 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_logged_in.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_role.html.erb +15 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/line_item_option_value/_option_value_fields.html.erb +17 -0
- data/app/views/solidus_friendly_promotions/admin/promotions/_activations_edit.html.erb +22 -0
- data/app/views/solidus_friendly_promotions/admin/promotions/_activations_new.html.erb +43 -0
- data/app/views/solidus_friendly_promotions/admin/promotions/_form.html.erb +96 -0
- data/app/views/solidus_friendly_promotions/admin/promotions/edit.html.erb +73 -0
- data/app/views/solidus_friendly_promotions/admin/promotions/index.html.erb +124 -0
- data/app/views/solidus_friendly_promotions/admin/promotions/new.html.erb +9 -0
- data/app/views/solidus_friendly_promotions/admin/shared/_promotion_sub_menu.html.erb +14 -0
- data/app/views/solidus_friendly_promotions/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb +2 -0
- data/app/views/solidus_friendly_promotions/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb +2 -0
- data/bin/console +17 -0
- data/bin/importmap +4 -0
- data/bin/rails +7 -0
- data/bin/rails-engine +13 -0
- data/bin/rails-sandbox +16 -0
- data/bin/rake +7 -0
- data/bin/sandbox +75 -0
- data/bin/setup +8 -0
- data/config/importmap.rb +12 -0
- data/config/initializers/solidus_friendly_promotions.rb +3 -0
- data/config/locales/en.yml +255 -0
- data/config/routes.rb +18 -0
- data/db/migrate/20230703101637_create_promotions.rb +16 -0
- data/db/migrate/20230703141116_create_promotion_categories.rb +14 -0
- data/db/migrate/20230703143943_create_promotion_rules.rb +12 -0
- data/db/migrate/20230704083830_add_rule_tables.rb +31 -0
- data/db/migrate/20230704093625_create_promotion_actions.rb +14 -0
- data/db/migrate/20230704102444_create_promotion_codes.rb +11 -0
- data/db/migrate/20230704102656_create_promotion_code_batches.rb +33 -0
- data/db/migrate/20230705171556_create_friendly_order_promotions.rb +11 -0
- data/db/migrate/20230725074235_create_shipping_rate_discounts.rb +12 -0
- data/db/migrate/20230928093138_add_lane_to_solidus_friendly_promotions_promotions.rb +5 -0
- data/db/migrate/20231006134042_add_customer_label_to_promotions.rb +7 -0
- data/db/migrate/20231011100059_add_db_comments_to_friendly_order_promotions.rb +61 -0
- data/db/migrate/20231011120928_add_db_comments_to_friendly_promotion_rules_taxons.rb +54 -0
- data/db/migrate/20231011131324_add_db_comments_to_friendly_promotion_rules.rb +60 -0
- data/db/migrate/20231011142040_add_db_comments_to_friendly_promotion_rules_users.rb +53 -0
- data/db/migrate/20231011154553_allow_null_promotion_ids.rb +9 -0
- data/db/migrate/20231011155822_add_db_comments_to_friendly_promotions.rb +123 -0
- data/db/migrate/20231011163030_add_db_comments_to_friendly_promotion_codes.rb +60 -0
- data/db/migrate/20231011173312_add_db_comments_to_friendly_promotion_code_batches.rb +91 -0
- data/db/migrate/20231011184205_add_db_comments_to_friendly_promotion_rules_stores.rb +53 -0
- data/db/migrate/20231011190222_add_db_comments_to_friendly_promotion_actions.rb +68 -0
- data/db/migrate/20231012020928_add_db_comments_to_friendly_products_promotion_rules.rb +52 -0
- data/db/migrate/20231012120928_add_db_comments_to_friendly_promotion_categories.rb +52 -0
- data/db/migrate/20231013181921_add_original_promotion_ids.rb +6 -0
- data/lib/generators/solidus_friendly_promotions/install/install_generator.rb +38 -0
- data/lib/generators/solidus_friendly_promotions/install/templates/initializer.rb +118 -0
- data/lib/solidus_friendly_promotions/configuration.rb +52 -0
- data/lib/solidus_friendly_promotions/engine.rb +37 -0
- data/lib/solidus_friendly_promotions/migrate_adjustments.rb +62 -0
- data/lib/solidus_friendly_promotions/migrate_order_promotions.rb +73 -0
- data/lib/solidus_friendly_promotions/nested_class_set.rb +24 -0
- data/lib/solidus_friendly_promotions/promotion_map.rb +96 -0
- data/lib/solidus_friendly_promotions/promotion_migrator.rb +103 -0
- data/lib/solidus_friendly_promotions/testing_support/factories/friendly_order_factory.rb +20 -0
- data/lib/solidus_friendly_promotions/testing_support/factories/friendly_order_promotion_factory.rb +8 -0
- data/lib/solidus_friendly_promotions/testing_support/factories/friendly_promotion_category_factory.rb +7 -0
- data/lib/solidus_friendly_promotions/testing_support/factories/friendly_promotion_code_factory.rb +8 -0
- data/lib/solidus_friendly_promotions/testing_support/factories/friendly_promotion_factory.rb +91 -0
- data/lib/solidus_friendly_promotions/testing_support/factories/friendly_shipping_rate_discount_factory.rb +14 -0
- data/lib/solidus_friendly_promotions/testing_support.rb +9 -0
- data/lib/solidus_friendly_promotions/version.rb +5 -0
- data/lib/solidus_friendly_promotions.rb +18 -0
- data/lib/tasks/solidus_friendly_promotions/migrate_adjustments.rake +17 -0
- data/lib/tasks/solidus_friendly_promotions/migrate_existing_promotions.rake +12 -0
- data/lib/tasks/solidus_friendly_promotions/migrate_order_promotions.rake +17 -0
- data/solidus_friendly_promotions.gemspec +40 -0
- metadata +392 -0
data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_taxon.html.erb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<p>
|
2
|
+
<%= promotion_rule.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="field taxons_rule_taxons">
|
5
|
+
<%= label_tag "#{param_prefix}_taxon_ids_string", t("solidus_friendly_promotions.taxon_rule.choose_taxons") %>
|
6
|
+
<%= hidden_field_tag "#{param_prefix}[taxon_ids_string]", promotion_rule.taxon_ids.join(","), class: "taxon_picker fullwidth", id: "product_taxon_ids" %>
|
7
|
+
</div>
|
8
|
+
<div class="field">
|
9
|
+
<div class="field">
|
10
|
+
<%= label_tag("#{param_prefix}_preferred_match_policy", promotion_rule.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.promotion_rules.line_item_taxon.match_policies").to_a.map(&:reverse), promotion_rule.preferred_match_policy),
|
14
|
+
class: "custom-select fullwidth",
|
15
|
+
) %>
|
16
|
+
</div>
|
17
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<p>
|
2
|
+
<%= promotion_rule.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="row">
|
5
|
+
<div class="col-6">
|
6
|
+
<div class="field">
|
7
|
+
<%= SolidusFriendlyPromotions::Rules::NthOrder.human_attribute_name(:form_text) %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<div class="col-6">
|
11
|
+
<div class="field">
|
12
|
+
<%= number_field_tag "#{param_prefix}[preferred_nth_order]", promotion_rule.preferred_nth_order, class: 'fullwidth' %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</div>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<% context = local_assigns[:context] || :order %>
|
2
|
+
|
3
|
+
<% if context == :order %>
|
4
|
+
<p>
|
5
|
+
<%= promotion_rule.class.human_attribute_name(:description) %>
|
6
|
+
</p>
|
7
|
+
<div class="field promo-rule-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="field">
|
15
|
+
<div data-controller="product-option-values">
|
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 %>
|
18
|
+
</template>
|
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 %>
|
21
|
+
<% end %>
|
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" } %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="field">
|
29
|
+
<%= form.label :preferred_line_item_applicable do %>
|
30
|
+
<%= form.check_box :preferred_line_item_applicable %>
|
31
|
+
<%= promotion_rule.class.human_attribute_name(:preferred_line_item_applicable) %>
|
32
|
+
<% end %>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<% else %>
|
36
|
+
<p>
|
37
|
+
<%= SolidusFriendlyPromotions::Rules::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
|
+
<% promotion_rule.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,44 @@
|
|
1
|
+
<% context = local_assigns[:context] || :order %>
|
2
|
+
|
3
|
+
<% if context == :order %>
|
4
|
+
<p>
|
5
|
+
<%= promotion_rule.class.human_attribute_name(:description) %>
|
6
|
+
</p>
|
7
|
+
<%= fields_for param_prefix, promotion_rule do |form| %>
|
8
|
+
<div class="field products_rule_products">
|
9
|
+
<%= form.label :product_ids_string, t('solidus_friendly_promotions.product_rule.choose_products') %>
|
10
|
+
<%= form.hidden_field :product_ids_string, value: promotion_rule.product_ids.join(","), class: "product_picker fullwidth" %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="field">
|
14
|
+
<%
|
15
|
+
match_policy_options = options_for_select(
|
16
|
+
SolidusFriendlyPromotions::Rules::Product::MATCH_POLICIES.map { |s| [t("solidus_friendly_promotions.product_rule.match_#{s}"),s] },
|
17
|
+
promotion_rule.preferred_match_policy
|
18
|
+
)
|
19
|
+
%>
|
20
|
+
<% select = form.select :preferred_match_policy, match_policy_options %>
|
21
|
+
<%= form.label :preferred_match_policy, t('solidus_friendly_promotions.product_rule.label', select: select).html_safe %>
|
22
|
+
</label>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<div class="field">
|
26
|
+
<%= form.label :preferred_line_item_applicable do %>
|
27
|
+
<%= form.check_box :preferred_line_item_applicable %>
|
28
|
+
<%= promotion_rule.class.human_attribute_name(:preferred_line_item_applicable) %>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
<% else %>
|
33
|
+
<p>
|
34
|
+
<% match_policy_translation_key = promotion_rule.preferred_match_policy == "none" ? :exclude : :include %>
|
35
|
+
<%= t(match_policy_translation_key, scope: [:solidus_friendly_promotions, :promotion_rules, :line_item_product, :match_policies]) %>
|
36
|
+
</p>
|
37
|
+
<ul>
|
38
|
+
<% promotion_rule.products.each do |product| %>
|
39
|
+
<li>
|
40
|
+
<%= product.name %>
|
41
|
+
</li>
|
42
|
+
<% end %>
|
43
|
+
</ul>
|
44
|
+
<% end %>
|
data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_shipping_method.html.erb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
<p>
|
2
|
+
<%= promotion_rule.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="form-group">
|
5
|
+
<%= label_tag "#{param_prefix}_preferred_shipping_method_ids", SolidusFriendlyPromotions::Rules::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, promotion_rule.preferred_shipping_method_ids
|
9
|
+
), class: 'select2 fullwidth', multiple: true %>
|
10
|
+
</div>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<p>
|
2
|
+
<%= promotion_rule.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="field">
|
5
|
+
<label><%= t("solidus_friendly_promotions.store_rule.choose_stores" ) %></label>
|
6
|
+
<%= select_tag "#{param_prefix}[store_ids][]",
|
7
|
+
options_from_collection_for_select(Spree::Store.all, :id, :name, promotion_rule.store_ids),
|
8
|
+
multiple: true, class: "select2 fullwidth" %>
|
9
|
+
</div>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<% context = local_assigns[:context] || :order %>
|
2
|
+
|
3
|
+
<% if context == :order %>
|
4
|
+
<p>
|
5
|
+
<%= promotion_rule.class.human_attribute_name(:description) %>
|
6
|
+
</p>
|
7
|
+
<%= fields_for param_prefix, promotion_rule do |form| %>
|
8
|
+
<div class="field taxons_rule_taxons">
|
9
|
+
<%= form.label :taxon_ids_string, t('solidus_friendly_promotions.taxon_rule.choose_taxons') %>
|
10
|
+
<%= form.hidden_field :taxon_ids_string, value: promotion_rule.taxon_ids.join(","), class: "taxon_picker fullwidth" %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="field">
|
14
|
+
<%
|
15
|
+
match_policy_options = options_for_select(
|
16
|
+
SolidusFriendlyPromotions::Rules::Taxon::MATCH_POLICIES.map { |s| [t("solidus_friendly_promotions.taxon_rule.match_#{s}"),s] },
|
17
|
+
promotion_rule.preferred_match_policy
|
18
|
+
)
|
19
|
+
%>
|
20
|
+
<% select = form.select :preferred_match_policy, match_policy_options %>
|
21
|
+
<%= form.label :preferred_match_policy, t('solidus_friendly_promotions.taxon_rule.label', select: select).html_safe %>
|
22
|
+
</label>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<div class="field">
|
26
|
+
<%= form.label :preferred_line_item_applicable do %>
|
27
|
+
<%= form.check_box :preferred_line_item_applicable %>
|
28
|
+
<%= promotion_rule.class.human_attribute_name(:preferred_line_item_applicable) %>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
<% else %>
|
33
|
+
<p>
|
34
|
+
<% match_policy_translation_key = promotion_rule.preferred_match_policy == "none" ? :exclude : :include %>
|
35
|
+
<%= t(match_policy_translation_key, scope: [:solidus_friendly_promotions, :promotion_rules, :line_item_taxon, :match_policies]) %>
|
36
|
+
</p>
|
37
|
+
<ul>
|
38
|
+
<% promotion_rule.taxons.each do |taxon| %>
|
39
|
+
<li>
|
40
|
+
<%= taxon.name %>
|
41
|
+
</li>
|
42
|
+
<% end %>
|
43
|
+
</ul>
|
44
|
+
<% end %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>
|
2
|
+
<%= promotion_rule.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="field">
|
5
|
+
<label><%= t('solidus_friendly_promotions.user_rule.choose_users') %></label><br>
|
6
|
+
<input type='hidden' name='<%= param_prefix %>[user_ids_string]' class='user_picker fullwidth' value='<%= promotion_rule.user_ids.join(",") %>'>
|
7
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<p>
|
2
|
+
<%= promotion_rule.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="form-group">
|
5
|
+
<%= label_tag "#{param_prefix}_preferred_role_ids", t('solidus_friendly_promotions.user_role_rule.choose_roles') %>
|
6
|
+
<%= select_tag "#{param_prefix}[preferred_role_ids]",
|
7
|
+
options_from_collection_for_select(
|
8
|
+
Spree::Role.all, :id, :name, promotion_rule.preferred_role_ids
|
9
|
+
), class: 'select2 fullwidth', multiple: true %>
|
10
|
+
</div>
|
11
|
+
<div class="form-group">
|
12
|
+
<label>
|
13
|
+
<%= t('solidus_friendly_promotions.user_role_rule.label', select: select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(SolidusFriendlyPromotions::Rules::UserRole::MATCH_POLICIES.map{ |s| [t("solidus_friendly_promotions.user_role_rule.match_#{s}"),s] }, promotion_rule.preferred_match_policy), { class: 'custom-select'})).html_safe %>
|
14
|
+
</label>
|
15
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="fullwidth promo-rule-option-value">
|
2
|
+
<div class="row">
|
3
|
+
<div class="col-6">
|
4
|
+
<input
|
5
|
+
class="product-select fullwidth"
|
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="col-5">
|
12
|
+
<input class="option-values-select fullwidth" name="<%= form.object_name %>[preferred_eligible_values][<%= product_option_values[0] %>]" type="hidden" value="<%= product_option_values[1].join(",") %>">
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
<a class="fa fa-trash remove" data-action="click->product-option-values#remove_row"></a>
|
16
|
+
<div class="clear"></div>
|
17
|
+
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<% if @promotion.apply_automatically? %>
|
2
|
+
<p>
|
3
|
+
<%= t('.auto') %>
|
4
|
+
</p>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<% if @promotion.codes.count == 1 %>
|
8
|
+
<p>
|
9
|
+
<%= t('.single_code_html', code: @promotion.codes.first.value) %>
|
10
|
+
</p>
|
11
|
+
<% elsif @promotion.codes.count > 1 %>
|
12
|
+
<p>
|
13
|
+
<%= t('.multiple_codes_html', count: @promotion.codes.count) %>
|
14
|
+
</p>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<% if @promotion.path %>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :path %>
|
20
|
+
<%= f.text_field :path, class: "fullwidth" %>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<% activation_type = params[:activation_type] || 'single_code' %>
|
2
|
+
<div class="row" id="js_promotion_activation">
|
3
|
+
<div class="col-3">
|
4
|
+
<div class="form-check">
|
5
|
+
<label class="form-check-label">
|
6
|
+
<%= radio_button_tag('activation_type', 'auto', activation_type == 'auto') %>
|
7
|
+
<%= t('.auto') %> <%= f.field_hint :promo_code_will_be_disabled %>
|
8
|
+
</label>
|
9
|
+
</div>
|
10
|
+
<div class="form-check">
|
11
|
+
<label class="form-check-label">
|
12
|
+
<%= radio_button_tag('activation_type', 'single_code', activation_type == 'single_code') %>
|
13
|
+
<%= t('.single_code') %>
|
14
|
+
</label>
|
15
|
+
</div>
|
16
|
+
<div class="form-check">
|
17
|
+
<label class="form-check-label">
|
18
|
+
<%= radio_button_tag('activation_type', 'multiple_codes', activation_type == 'multiple_codes') %>
|
19
|
+
<%= t('.multiple_codes') %>
|
20
|
+
</label>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
<div class="col-9">
|
24
|
+
<input name="promotion[apply_automatically]" type="hidden" value="0">
|
25
|
+
<div data-activation-type="auto">
|
26
|
+
<input name="promotion[apply_automatically]" type="hidden" value="1">
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div data-activation-type="single_code">
|
30
|
+
<div class="field">
|
31
|
+
<%= label_tag :single_code, SolidusFriendlyPromotions::PromotionCode.model_name.human, class: "required" %>
|
32
|
+
<%= text_field_tag :single_code, @promotion.codes.first.try!(:value), class: "fullwidth", required: true %>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<div data-activation-type="multiple_codes">
|
37
|
+
<%= fields_for :promotion_code_batch, @promotion_code_batch do |batch| %>
|
38
|
+
<%= render partial: 'spree/admin/promotion_code_batches/form_fields', locals: {f: f, batch: batch, promotion_id: params[:promotion_id]} %>
|
39
|
+
<% end %>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
</div>
|
43
|
+
</div>
|
@@ -0,0 +1,96 @@
|
|
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, SolidusFriendlyPromotions::PromotionCategory.model_name.human %><br>
|
27
|
+
<%=
|
28
|
+
f.collection_select(:promotion_category_id, @promotion_categories, :id, :name, { include_blank: t('solidus_friendly_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_friendly_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="field">
|
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="field">
|
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="field">
|
77
|
+
<%= f.field_container :lane do %>
|
78
|
+
<%= f.label :lane %><br>
|
79
|
+
<%=
|
80
|
+
f.select(:lane, SolidusFriendlyPromotions::Promotion.lane_options, {}, { class: 'custom-select fullwidth' })
|
81
|
+
%>
|
82
|
+
<% end %>
|
83
|
+
</div>
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
</fieldset>
|
87
|
+
|
88
|
+
<fieldset class="form-group no-border-bottom">
|
89
|
+
<legend><%= t '.activation' %></legend>
|
90
|
+
|
91
|
+
<% if @promotion.new_record? %>
|
92
|
+
<%= render 'spree/admin/promotions/activations_new', f: f %>
|
93
|
+
<% else %>
|
94
|
+
<%= render 'spree/admin/promotions/activations_edit', f: f %>
|
95
|
+
<% end %>
|
96
|
+
</fieldset>
|
@@ -0,0 +1,73 @@
|
|
1
|
+
<% admin_layout "full-width" %>
|
2
|
+
|
3
|
+
<% admin_breadcrumb(link_to plural_resource_name(SolidusFriendlyPromotions::Promotion), solidus_friendly_promotions.admin_promotions_path) %>
|
4
|
+
<% admin_breadcrumb(@promotion.name) %>
|
5
|
+
|
6
|
+
<%= content_for :head do %>
|
7
|
+
<%= javascript_importmap_tags "solidus_friendly_promotions", importmap: SolidusFriendlyPromotions.importmap %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% content_for :page_actions do %>
|
11
|
+
<li>
|
12
|
+
<% if can?(:show, SolidusFriendlyPromotions::PromotionCode) %>
|
13
|
+
<%= link_to t('solidus_friendly_promotions.view_promotion_codes_list'), solidus_friendly_promotions.admin_promotion_promotion_codes_path(promotion_id: @promotion.id), class: 'btn btn-primary' %>
|
14
|
+
|
15
|
+
<%= link_to t('solidus_friendly_promotions.download_promotion_codes_list'), solidus_friendly_promotions.admin_promotion_promotion_codes_path(promotion_id: @promotion.id, format: :csv), class: 'btn btn-primary' %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<% if can?(:show, SolidusFriendlyPromotions::PromotionCodeBatch) %>
|
19
|
+
<%= link_to plural_resource_name(SolidusFriendlyPromotions::PromotionCodeBatch), solidus_friendly_promotions.admin_promotion_promotion_code_batches_path(promotion_id: @promotion.id), class: 'btn btn-primary' %>
|
20
|
+
<% end %>
|
21
|
+
</li>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<%= form_for @promotion, url: object_url, method: :put do |f| %>
|
25
|
+
<%= render partial: 'form', locals: { f: f } %>
|
26
|
+
<% if can?(:update, @promotion) %>
|
27
|
+
<%= render partial: 'spree/admin/shared/edit_resource_links' %>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
|
32
|
+
<fieldset>
|
33
|
+
<legend align="center"><%= t(:order_rules, scope: :solidus_friendly_promotions) %></legend>
|
34
|
+
|
35
|
+
<%= render partial: 'solidus_friendly_promotions/admin/promotion_rules/promotion_rule', collection: promotion_rules_by_level(@promotion, :order), locals: { level: :order } %>
|
36
|
+
|
37
|
+
<%= turbo_frame_tag @promotion, "new_order_promotion_rule" do %>
|
38
|
+
<%= link_to t(:add_rule, scope: :solidus_friendly_promotions), solidus_friendly_promotions.new_admin_promotion_promotion_rule_path(@promotion, level: :order), class: 'btn btn-secondary' %>
|
39
|
+
<% end %>
|
40
|
+
</fieldset>
|
41
|
+
|
42
|
+
<div class="row">
|
43
|
+
<div class="col-12">
|
44
|
+
<%= turbo_frame_tag @promotion, "new_promotion_action" do %>
|
45
|
+
<%= link_to t(:add_action, scope: :solidus_friendly_promotions), solidus_friendly_promotions.new_admin_promotion_promotion_action_path(@promotion), class: 'btn btn-secondary' %>
|
46
|
+
<% end %>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<div class="row">
|
51
|
+
<% [:line_item, :shipment].each do |level| %>
|
52
|
+
<% if promotion_actions_by_level(@promotion, level).any? %>
|
53
|
+
<div class="col-6">
|
54
|
+
<fieldset>
|
55
|
+
<legend align="center"><%= t("#{level}_actions", scope: :solidus_friendly_promotions) %></legend>
|
56
|
+
|
57
|
+
<%= render partial: 'solidus_friendly_promotions/admin/promotion_actions/promotion_action', collection: promotion_actions_by_level(@promotion, level), locals: {} %>
|
58
|
+
</fieldset>
|
59
|
+
</div>
|
60
|
+
<div class="col-6">
|
61
|
+
<fieldset>
|
62
|
+
<legend align="center"><%= t("#{level}_rules", scope: :solidus_friendly_promotions) %></legend>
|
63
|
+
|
64
|
+
<%= render partial: 'solidus_friendly_promotions/admin/promotion_rules/promotion_rule', collection: promotion_rules_by_level(@promotion, level), locals: { level: level } %>
|
65
|
+
|
66
|
+
<%= turbo_frame_tag @promotion, "new_#{level}_promotion_rule" do %>
|
67
|
+
<%= link_to t(:add_rule, scope: :solidus_friendly_promotions), solidus_friendly_promotions.new_admin_promotion_promotion_rule_path(@promotion, level: level), class: 'btn btn-secondary' %>
|
68
|
+
<% end %>
|
69
|
+
</fieldset>
|
70
|
+
</div>
|
71
|
+
<% end %>
|
72
|
+
<% end %>
|
73
|
+
</div>
|
@@ -0,0 +1,124 @@
|
|
1
|
+
<% admin_breadcrumb(plural_resource_name(SolidusFriendlyPromotions::Promotion)) %>
|
2
|
+
|
3
|
+
<% content_for :page_actions do %>
|
4
|
+
<% if can? :create, SolidusFriendlyPromotions::Promotion %>
|
5
|
+
<li>
|
6
|
+
<%= link_to t('solidus_friendly_promotions.new_promotion'), solidus_friendly_promotions.new_admin_promotion_path, class: 'btn btn-primary' %>
|
7
|
+
</li>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<% content_for :table_filter_title do %>
|
12
|
+
<%= t('spree.search') %>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% content_for :table_filter do %>
|
16
|
+
<div data-hook="admin_promotions_index_search">
|
17
|
+
<%= search_form_for [:admin, @search] do |f| %>
|
18
|
+
<div class="row">
|
19
|
+
<div class="col-4">
|
20
|
+
<div class="field">
|
21
|
+
<%= label_tag :q_name_cont, SolidusFriendlyPromotions::Promotion.human_attribute_name(:name) %>
|
22
|
+
<%= f.text_field :name_cont, tabindex: 1 %>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div class="col-2">
|
27
|
+
<div class="field">
|
28
|
+
<%= label_tag :q_codes_value_cont, SolidusFriendlyPromotions::Promotion.human_attribute_name(:code) %>
|
29
|
+
<%= f.text_field :codes_value_cont, tabindex: 1 %>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class="col-2">
|
34
|
+
<div class="field">
|
35
|
+
<%= label_tag :q_path_cont, SolidusFriendlyPromotions::Promotion.human_attribute_name(:path) %>
|
36
|
+
<%= f.text_field :path_cont, tabindex: 1 %>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class="col-2">
|
41
|
+
<div class="field">
|
42
|
+
<%= label_tag :q_promotion_category_id_eq, SolidusFriendlyPromotions::PromotionCategory.model_name.human %><br>
|
43
|
+
<%= f.collection_select(:promotion_category_id_eq, @promotion_categories, :id, :name, { include_blank: t('solidus_friendly_promotions.match_choices.all') }, { class: 'custom-select fullwidth' }) %>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div class="col-2">
|
48
|
+
<div class="field">
|
49
|
+
<%= label_tag :active, SolidusFriendlyPromotions::Promotion.human_attribute_name(:active) %><br>
|
50
|
+
<%= f.check_box :active, label: false, as: :boolean, checked_value: true %>
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<div class="clearfix"></div>
|
56
|
+
|
57
|
+
<div class="actions filter-actions">
|
58
|
+
<div data-hook="admin_promotions_index_search_buttons">
|
59
|
+
<%= button_tag t('spree.filter_results'), class: 'btn btn-primary' %>
|
60
|
+
</div>
|
61
|
+
</div>
|
62
|
+
<% end %>
|
63
|
+
</div>
|
64
|
+
<% end %>
|
65
|
+
|
66
|
+
<%= paginate @promotions, theme: "solidus_admin" %>
|
67
|
+
|
68
|
+
<% if @promotions.length > 0 %>
|
69
|
+
<table class="index">
|
70
|
+
<thead>
|
71
|
+
<tr>
|
72
|
+
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:name) %></th>
|
73
|
+
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:code) %></th>
|
74
|
+
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:status) %></th>
|
75
|
+
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:usage_limit) %></th>
|
76
|
+
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:uses) %></th>
|
77
|
+
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:starts_at) %></th>
|
78
|
+
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:expires_at) %></th>
|
79
|
+
<th class="actions"></th>
|
80
|
+
</tr>
|
81
|
+
</thead>
|
82
|
+
<tbody>
|
83
|
+
<% @promotions.each do |promotion| %>
|
84
|
+
<tr id="<%= spree_dom_id promotion %>">
|
85
|
+
<td><%= promotion.name %></td>
|
86
|
+
<td>
|
87
|
+
<%= (promotion.codes.size == 1) ? promotion.codes.pluck(:value).first : t('solidus_friendly_promotions.number_of_codes', count: promotion.codes.size) %>
|
88
|
+
</td>
|
89
|
+
<td>
|
90
|
+
<span class="pill pill-<%= promotion.active? ? 'active' : 'inactive' %>">
|
91
|
+
<%= t(admin_promotion_status(promotion), scope: 'solidus_friendly_promotions.admin.promotion_status') %>
|
92
|
+
</span>
|
93
|
+
</td>
|
94
|
+
<td>
|
95
|
+
<%= promotion.usage_limit.nil? ? "∞" : promotion.usage_limit %>
|
96
|
+
</td>
|
97
|
+
<td>
|
98
|
+
<%= promotion.usage_count %>
|
99
|
+
</td>
|
100
|
+
<td>
|
101
|
+
<%= promotion.starts_at.to_fs(:long) if promotion.starts_at %>
|
102
|
+
</td>
|
103
|
+
<td>
|
104
|
+
<%= promotion.expires_at.to_fs(:long) if promotion.expires_at %>
|
105
|
+
</td>
|
106
|
+
<td class="actions">
|
107
|
+
<% if can?(:edit, promotion) %>
|
108
|
+
<%= link_to_edit promotion, no_text: true %>
|
109
|
+
<% end %>
|
110
|
+
<% if can?(:destroy, promotion) %>
|
111
|
+
<%= link_to_delete promotion, no_text: true %>
|
112
|
+
<% end %>
|
113
|
+
</td>
|
114
|
+
</tr>
|
115
|
+
<% end %>
|
116
|
+
</tbody>
|
117
|
+
</table>
|
118
|
+
<% else %>
|
119
|
+
<div class="no-objects-found">
|
120
|
+
<%= render 'spree/admin/shared/no_objects_found',
|
121
|
+
resource: SolidusFriendlyPromotions::Promotion,
|
122
|
+
new_resource_url: new_object_url %>
|
123
|
+
</div>
|
124
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% admin_layout "full-width" %>
|
2
|
+
|
3
|
+
<% admin_breadcrumb(link_to plural_resource_name(SolidusFriendlyPromotions::Promotion), solidus_friendly_promotions.admin_promotions_path) %>
|
4
|
+
<% admin_breadcrumb(t('solidus_friendly_promotions.new_promotion')) %>
|
5
|
+
|
6
|
+
<%= form_for @promotion, url: collection_url do |f| %>
|
7
|
+
<%= render partial: 'form', locals: { f: f } %>
|
8
|
+
<%= render partial: 'spree/admin/shared/new_resource_links' %>
|
9
|
+
<% end %>
|