Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Improve promotion rules management

Damian Legawiecd206b9b1efa1
diff --git a/admin/app/views/spree/admin/promotions/_rule_form.html.erb b/admin/app/views/spree/admin/promotions/_rule_form.html.erb
index e74edca090..84c24f8d7e 100644
--- a/admin/app/views/spree/admin/promotions/_rule_form.html.erb
+++ b/admin/app/views/spree/admin/promotions/_rule_form.html.erb
@@ -1,12 +1,16 @@
-<div class="bg-gray-25 border rounded p-3 nested-form-wrapper border-bottom mb-3 pb-3" data-controller="rule-form" data-new-record="<%= rf.object.new_record? %>">
+<div class="bg-gray-25 border rounded pt-3 px-3 pb-0 nested-form-wrapper border-bottom mb-3 position-relative" data-controller="rule-form" data-new-record="<%= rf.object.new_record? %>">
<% if rf.object.new_record? %>
<% @promotion_rules.each do |promotion_rule| %>
<template id="rule-form-template-<%= promotion_rule.to_s.demodulize %>" data-rule-form-target="template">
+ <p class="text-muted form-text">
+ <%= Spree.t("promotion_rule_types.#{promotion_rule.to_s.demodulize.underscore}.description") %>
+ </p>
<%= render "spree/admin/promotions/rules/#{promotion_rule.to_s.demodulize.underscore}", rule_form: rf, prefix: prefix %>
</template>
<% end %>
<div class="form-group">
+ <%= rf.label :type, Spree.t(:rule_type) %>
<%= rf.select :type, @rule_types, {}, { class: 'custom-select', data: { action: 'rule-form#replace' } } %>
</div>
<% else %>
@@ -16,12 +20,16 @@
<% end %>
<div class="form-group" data-rule-form-target="value">
<% if rf.object.type.present? %>
+ <p class="text-muted form-text">
+ <%= Spree.t("promotion_rule_types.#{rf.object.type.demodulize.underscore}.description") %>
+ </p>
<%= render "spree/admin/promotions/rules/#{rf.object.type.demodulize.underscore}", rule_form: rf, prefix: prefix %>
<% end %>
</div>
- <button type="button" data-action="nested-form#remove" class="btn btn-sm btn-danger">
- <%= icon('x', class: 'mr-0') %>
- <%= Spree.t(:remove_condition) %>
- </button>
+ <div class="position-absolute right-0 top-0">
+ <button type="button" data-action="nested-form#remove" class="btn btn-sm btn-danger with-tip mt-1 mr-1 rounded-sm px-1" title="<%= Spree.t(:remove_condition) %>">
+ <%= icon('trash', class: 'mr-0') %>
+ </button>
+ </div>
<%= rf.hidden_field :_destroy if rf.object.persisted? %>
</div>
diff --git a/admin/app/views/spree/admin/promotions/rules/_country.html.erb b/admin/app/views/spree/admin/promotions/rules/_country.html.erb
index 085665a31c..b5d0acab22 100644
--- a/admin/app/views/spree/admin/promotions/rules/_country.html.erb
+++ b/admin/app/views/spree/admin/promotions/rules/_country.html.erb
@@ -1,4 +1,3 @@
-
<% active_option ||= current_store.default_country_iso %>
<% active_option = rule_form.object.preferred_country_iso if rule_form.object.persisted? && rule_form.object.respond_to?(:preferred_country_iso) %>
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 46dd688977..2b9db5992d 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -1572,8 +1572,11 @@ en:
promotion_not_cloned: 'Promotion has not been cloned. Reason: %{error}'
promotion_rule: Promotion Rule
promotion_rule_types:
+ currency:
+ description: Limit to orders in a specific currency
+ name: Currency
country:
- description: Order is shipped to proper (or default) country
+ description: Limit to orders with shipping address in a specific country
name: Country
first_order:
description: Must be the customer's first order