Skip to content

Commit

Permalink
Merge pull request #2917 from michaelmichael/fix-issues-in-1960
Browse files Browse the repository at this point in the history
Improve text in "new promotions" form for better usability
  • Loading branch information
kennyadsl authored Oct 18, 2018
2 parents aa01616 + 5067e78 commit f265506
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/promotions/_actions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<legend align="center"><%= t('spree.promotion_actions') %></legend>
<% if can?(:update, @promotion) %>
<div class="field">
<%= label_tag :action_type, t('spree.add_action_of_type')%>
<%= label_tag :action_type, t('spree.adjustment_type')%>
<%= select_tag 'action_type', options, include_blank: t(:choose_promotion_action, scope: 'spree'), class: 'custom-select fullwidth' %>
</div>
<div class="filter-actions actions">
Expand Down
7 changes: 4 additions & 3 deletions backend/app/views/spree/admin/promotions/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<%= render partial: 'spree/shared/error_messages', locals: { target: @promotion } %>
<fieldset class="form-group no-border-bottom">
<legend><%= t '.general' %></legend>

<fieldset class="form-group no-border-bottom no-border-top">
<div class="row">
<div id="general_fields" class="col-9">
<div class="row">
Expand All @@ -14,6 +12,9 @@
<%= f.field_container :description do %>
<%= f.label :description %><br />
<%= f.text_area :description, rows: 7, class: 'fullwidth' %>
<span class="info">
<%= t('spree.character_limit') %>
</span>
<% end %>

<%= f.field_container :category do %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/promotions/_rules.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<% if can?(:update, @promotion) %>
<div class="field">
<%= label_tag :promotion_rule_type, t('spree.add_rule_of_type') %>
<%= label_tag :promotion_rule_type, t('spree.discount_rules') %>
<%= select_tag('promotion_rule[type]', options_for_promotion_rule_types(@promotion), include_blank: t(:choose_promotion_rule, scope: 'spree'), class: 'custom-select fullwidth') %>
</div>
<div class="filter-actions actions">
Expand Down
24 changes: 12 additions & 12 deletions backend/spec/features/admin/promotion_adjustments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
click_button "Create"
expect(page).to have_title("SAVE SAVE SAVE - Promotions")

select "Item total", from: "Add rule of type"
select "Item total", from: "Discount rules"
within('#rule_fields') { click_button "Add" }

find('[id$=_preferred_amount]').set(30)
within('#rule_fields') { click_button "Update" }

select "Create whole-order adjustment", from: "Add action of type"
select "Create whole-order adjustment", from: "Adjustment type"
within('#action_fields') do
click_button "Add"
select "Flat Rate", from: I18n.t('spree.admin.promotions.actions.calculator_label')
Expand Down Expand Up @@ -55,7 +55,7 @@
click_button "Create"
expect(page).to have_title("SAVE SAVE SAVE - Promotions")

select "Create whole-order adjustment", from: "Add action of type"
select "Create whole-order adjustment", from: "Adjustment type"
within('#action_fields') do
click_button "Add"
select "Flat Rate", from: I18n.t('spree.admin.promotions.actions.calculator_label')
Expand All @@ -81,13 +81,13 @@
click_button "Create"
expect(page).to have_title("SAVE SAVE SAVE - Promotions")

select "Item total", from: "Add rule of type"
select "Item total", from: "Discount rules"
within('#rule_fields') { click_button "Add" }

find('[id$=_preferred_amount]').set(30)
within('#rule_fields') { click_button "Update" }

select "Create whole-order adjustment", from: "Add action of type"
select "Create whole-order adjustment", from: "Adjustment type"
within('#action_fields') do
click_button "Add"
select "Flat Percent", from: I18n.t('spree.admin.promotions.actions.calculator_label')
Expand Down Expand Up @@ -118,12 +118,12 @@
click_button "Create"
expect(page).to have_title("SAVE SAVE SAVE - Promotions")

select "Product(s)", from: "Add rule of type"
select "Product(s)", from: "Discount rules"
within("#rule_fields") { click_button "Add" }
select2_search "RoR Mug", from: "Choose products"
within('#rule_fields') { click_button "Update" }

select "Create per-line-item adjustment", from: "Add action of type"
select "Create per-line-item adjustment", from: "Adjustment type"
within('#action_fields') do
click_button "Add"
select "Percent Per Item", from: I18n.t('spree.admin.promotions.actions.calculator_label')
Expand Down Expand Up @@ -152,12 +152,12 @@
click_button "Create"
expect(page).to have_title("SAVE SAVE SAVE - Promotions")

select "Item total", from: "Add rule of type"
select "Item total", from: "Discount rules"
within('#rule_fields') { click_button "Add" }
find('[id$=_preferred_amount]').set(30)
within('#rule_fields') { click_button "Update" }

select "Free shipping", from: "Add action of type"
select "Free shipping", from: "Adjustment type"
within('#action_fields') { click_button "Add" }
expect(page).to have_content('Makes all shipments for the order free')

Expand Down Expand Up @@ -205,12 +205,12 @@
click_button "Create"
expect(page).to have_title("SAVE SAVE SAVE - Promotions")

select "Item total", from: "Add rule of type"
select "Item total", from: "Discount rules"
within('#rule_fields') { click_button "Add" }
find('[id$=_preferred_amount]').set(50)
within('#rule_fields') { click_button "Update" }

select "Create whole-order adjustment", from: "Add action of type"
select "Create whole-order adjustment", from: "Adjustment type"
within('#action_fields') do
click_button "Add"
select "Flat Rate", from: I18n.t('spree.admin.promotions.actions.calculator_label')
Expand Down Expand Up @@ -257,7 +257,7 @@ def self.description
click_button "Create"
expect(page).to have_title("SAVE SAVE SAVE - Promotions")

select "Create per-line-item adjustment", from: "Add action of type"
select "Create per-line-item adjustment", from: "Adjustment type"
within('#action_fields') do
click_button "Add"
select "Complex Calculator", from: I18n.t('spree.admin.promotions.actions.calculator_label')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
end

scenario "adding an option value rule", js: true do
select "Option Value(s)", from: "Add rule of type"
select "Option Value(s)", from: "Discount rules"
within("#rules_container") { click_button "Add" }

within("#rules_container .promotion-block") do
Expand Down Expand Up @@ -46,7 +46,7 @@
option_value.update!(name: xss_string)
end
scenario "adding an option value rule", js: true do
select "Option Value(s)", from: "Add rule of type"
select "Option Value(s)", from: "Discount rules"
within("#rules_container") { click_button "Add" }

within("#rules_container .promotion-block") do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
given(:promotion) { create :promotion }

def add_promotion_rule_of_type(type)
select type, from: "Add rule of type"
select type, from: "Discount rules"
within("#rules_container") { click_button "Add" }
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
end

scenario "adding a tiered percent calculator", js: true do
select "Create whole-order adjustment", from: "Add action of type"
select "Create whole-order adjustment", from: "Adjustment type"
within('#action_fields') { click_button "Add" }

select "Tiered Percent", from: I18n.t('spree.admin.promotions.actions.calculator_label')
Expand Down
4 changes: 2 additions & 2 deletions backend/spec/features/admin/promotions/user_rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
let!(:other_user) { create(:user, email: 'bar@example.com') }

scenario "searching a user" do
select "User", from: "Add rule of type"
select "User", from: "Discount rules"
within("#rules_container") { click_button "Add" }

select2_search "foo", from: "Choose users", select: false
Expand All @@ -31,7 +31,7 @@
given!(:user) { create(:user, email: xss_string) }

scenario "adding an option value rule" do
select "User", from: "Add rule of type"
select "User", from: "Discount rules"
within("#rules_container") { click_button "Add" }

select2_search "<script>", from: "Choose users"
Expand Down
3 changes: 3 additions & 0 deletions core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ en:
adjustment_successfully_closed: Adjustment has been successfully closed!
adjustment_successfully_opened: Adjustment has been successfully opened!
adjustment_total: Adjustment Total
adjustment_type: Adjustment type
adjustments: Adjustments
admin:
stores:
Expand Down Expand Up @@ -1083,6 +1084,7 @@ en:
carton_orders: 'Other orders with Carton'
categories: Categories
category: Category
character_limit: Limit of 255 characters
charged: Charged
check: Check
check_stock_on_transfer: Check stock on transfer
Expand Down Expand Up @@ -1195,6 +1197,7 @@ en:
destroy: Destroy
details: Details
discount_amount: Discount Amount
discount_rules: Discount rules
dismiss_banner: No. Thanks! I'm not interested, do not display this message again
display: Display
download_promotion_code_list: Download Code List
Expand Down

0 comments on commit f265506

Please sign in to comment.