From 14740df9001a0ec5affbf56c225eacbefdd7092d Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Wed, 20 Apr 2022 22:42:45 +0200 Subject: [PATCH] Enhance refund admin UI This makes the refund form look better in non-english locales. - Use proper localization of amounts - Use actions translations in buttons and links - Fix refund icon class - Add a prompt to refund reason select --- .../app/views/spree/admin/payments/_list.html.erb | 2 +- backend/app/views/spree/admin/refunds/new.html.erb | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/app/views/spree/admin/payments/_list.html.erb b/backend/app/views/spree/admin/payments/_list.html.erb index 4500ed72c9c..2e808410793 100644 --- a/backend/app/views/spree/admin/payments/_list.html.erb +++ b/backend/app/views/spree/admin/payments/_list.html.erb @@ -58,7 +58,7 @@ <% allowed_actions = payment.actions.select { |a| can?(a.to_sym, payment) } %> <% allowed_actions.each do |action| %> <% if action == 'credit' %> - <%= link_to_with_icon 'reply', t('spree.refund'), new_admin_order_payment_refund_path(@order, payment), no_text: true %> + <%= link_to_with_icon 'mail-reply', t('spree.actions.refund'), new_admin_order_payment_refund_path(@order, payment), no_text: true %> <% elsif action == 'capture' && !@order.completed? %> <%# no capture prior to completion. payments get captured when the order completes. %> <% else %> diff --git a/backend/app/views/spree/admin/refunds/new.html.erb b/backend/app/views/spree/admin/refunds/new.html.erb index 4c883ff9fde..09a202108cb 100644 --- a/backend/app/views/spree/admin/refunds/new.html.erb +++ b/backend/app/views/spree/admin/refunds/new.html.erb @@ -10,14 +10,16 @@
- <%= t('spree.payment_amount') %>
- <%= @refund.payment.amount %> +
+ <%= number_to_currency @refund.payment.amount, + unit: Spree::Config.available_currencies.find { |c| c.iso_code == @refund.currency }&.symbol %>
- <%= t('spree.credit_allowed') %>
- <%= @refund.payment.credit_allowed %> +
+ <<%= number_to_currency @refund.payment.credit_allowed, + unit: Spree::Config.available_currencies.find { |c| c.iso_code == @refund.currency }&.symbol %>
@@ -29,13 +31,13 @@
<%= f.label :refund_reason_id %>
- <%= f.collection_select(:refund_reason_id, refund_reasons, :id, :name, {include_blank: true}, {class: 'custom-select fullwidth'}) %> + <%= f.collection_select(:refund_reason_id, refund_reasons, :id, :name, {prompt: t("spree.choose_reason")}, {class: 'custom-select fullwidth'}) %>
- <%= f.submit Spree::Refund.model_name.human, class: 'btn btn-primary' %> + <%= f.submit t('spree.actions.refund'), class: 'btn btn-primary' %> <%= link_to t('spree.actions.cancel'), admin_order_payments_url(@refund.payment.order), class: 'btn btn-primary' %>