From 90c8a118d9e79adc0afcbcd2ce2756c94b4f900d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20S=C4=99k?= Date: Tue, 7 Jan 2025 13:57:58 +0100 Subject: [PATCH 1/4] Add condition for order refund payments --- config/twig_hooks/admin/order/show.yaml | 3 +++ .../order/content/sections/payments.html.twig | 6 ++++++ .../sections/payments/refund_header.html.twig | 10 +++++++--- .../sections/payments/refund_items.html.twig | 15 ++++++--------- 4 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 templates/admin/order/content/sections/payments.html.twig diff --git a/config/twig_hooks/admin/order/show.yaml b/config/twig_hooks/admin/order/show.yaml index d5256e70e..572b2ff58 100644 --- a/config/twig_hooks/admin/order/show.yaml +++ b/config/twig_hooks/admin/order/show.yaml @@ -42,6 +42,9 @@ sylius_twig_hooks: priority: 0 'sylius_admin.order.show.content.sections#left': + payments: + template: '@SyliusRefundPlugin/admin/order/content/sections/payments.html.twig' + priority: 100 credit_memos: template: '@SyliusRefundPlugin/admin/order/content/sections/credit_memos.html.twig' priority: 50 diff --git a/templates/admin/order/content/sections/payments.html.twig b/templates/admin/order/content/sections/payments.html.twig new file mode 100644 index 000000000..35a6d6080 --- /dev/null +++ b/templates/admin/order/content/sections/payments.html.twig @@ -0,0 +1,6 @@ +{% set order = hookable_metadata.context.resource %} +{% set refund_payments = get_all_refund_payments_by_order(order) %} + +
+ {% hook 'payments' with { refund_payments } %} +
diff --git a/templates/admin/order/content/sections/payments/refund_header.html.twig b/templates/admin/order/content/sections/payments/refund_header.html.twig index 64239f4f7..cb67e3a3c 100644 --- a/templates/admin/order/content/sections/payments/refund_header.html.twig +++ b/templates/admin/order/content/sections/payments/refund_header.html.twig @@ -1,3 +1,7 @@ -
- {% hook 'refund_header' %} -
+{% set refund_payments = hookable_metadata.context.refund_payments %} + +{% if refund_payments|length > 0 %} +
+ {% hook 'refund_header' %} +
+{% endif %} diff --git a/templates/admin/order/content/sections/payments/refund_items.html.twig b/templates/admin/order/content/sections/payments/refund_items.html.twig index e6d797853..2bd0c0ee2 100644 --- a/templates/admin/order/content/sections/payments/refund_items.html.twig +++ b/templates/admin/order/content/sections/payments/refund_items.html.twig @@ -1,20 +1,17 @@ -{% set order = hookable_metadata.context.resource %} -{% set refund_payments = get_all_refund_payments_by_order(order) %} +{% set refund_payments = hookable_metadata.context.refund_payments %} -
- {% if order.hasPayments %} +{% if refund_payments|length > 0 %} +
{% for refund_payment in refund_payments %} - {% hook 'refund_item' with { resource: order, refund_payment } %} + {% hook 'refund_item' with { refund_payment } %} {% endfor %}
- {% else %} - {{ 'sylius.ui.no_payments'|trans }} - {% endif %} -
+
+{% endif %} From 7235335fd7f7ea22174ef346c4ec3fe7b7a361a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20S=C4=99k?= Date: Tue, 7 Jan 2025 14:29:42 +0100 Subject: [PATCH 2/4] Mobile table fix --- .../show/content/sections/memo_details/table.html.twig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/admin/credit_memo/show/content/sections/memo_details/table.html.twig b/templates/admin/credit_memo/show/content/sections/memo_details/table.html.twig index 33dc94ad8..6eb21cca5 100644 --- a/templates/admin/credit_memo/show/content/sections/memo_details/table.html.twig +++ b/templates/admin/credit_memo/show/content/sections/memo_details/table.html.twig @@ -1,3 +1,5 @@ - - {% hook 'table' %} -
+
+ + {% hook 'table' %} +
+
From fec4a55ac9085519e1f27922fbc7c7e1d45702d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20S=C4=99k?= Date: Tue, 7 Jan 2025 15:28:29 +0100 Subject: [PATCH 3/4] Change refund form fields style --- assets/entrypoint.js | 2 ++ assets/styles/main.scss | 1 + assets/styles/refund.scss | 4 ++++ config/twig_hooks/admin/order/refund/show.yaml | 4 ++-- .../refund/content/sections/form/fields/comment.html.twig | 4 ++-- .../content/sections/form/fields/payment_method.html.twig | 2 +- tests/Application/config/packages/_sylius.yaml | 4 ++++ tests/Application/templates/admin/stylesheets.html.twig | 1 + 8 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 assets/styles/main.scss create mode 100644 assets/styles/refund.scss create mode 100644 tests/Application/templates/admin/stylesheets.html.twig diff --git a/assets/entrypoint.js b/assets/entrypoint.js index c5e8cf094..866791ec5 100644 --- a/assets/entrypoint.js +++ b/assets/entrypoint.js @@ -1 +1,3 @@ import './js/refund-button'; + +import './styles/main.scss'; diff --git a/assets/styles/main.scss b/assets/styles/main.scss new file mode 100644 index 000000000..86d0c649f --- /dev/null +++ b/assets/styles/main.scss @@ -0,0 +1 @@ +@import 'refund'; diff --git a/assets/styles/refund.scss b/assets/styles/refund.scss new file mode 100644 index 000000000..bba7f4b1d --- /dev/null +++ b/assets/styles/refund.scss @@ -0,0 +1,4 @@ +textarea.refund-comment { + min-height: 4rem; + height: 4rem; +} diff --git a/config/twig_hooks/admin/order/refund/show.yaml b/config/twig_hooks/admin/order/refund/show.yaml index 51a83fc87..190ae2d60 100644 --- a/config/twig_hooks/admin/order/refund/show.yaml +++ b/config/twig_hooks/admin/order/refund/show.yaml @@ -117,7 +117,7 @@ sylius_twig_hooks: 'sylius_refund.admin.order.refund.content.sections.form.fields': payment_method: template: '@SyliusRefundPlugin/admin/order/refund/content/sections/form/fields/payment_method.html.twig' - priority: 100 + priority: 0 comment: template: '@SyliusRefundPlugin/admin/order/refund/content/sections/form/fields/comment.html.twig' - priority: 0 + priority: 100 diff --git a/templates/admin/order/refund/content/sections/form/fields/comment.html.twig b/templates/admin/order/refund/content/sections/form/fields/comment.html.twig index 87eebf585..327bbba00 100644 --- a/templates/admin/order/refund/content/sections/form/fields/comment.html.twig +++ b/templates/admin/order/refund/content/sections/form/fields/comment.html.twig @@ -1,6 +1,6 @@ -
+
- +
diff --git a/templates/admin/order/refund/content/sections/form/fields/payment_method.html.twig b/templates/admin/order/refund/content/sections/form/fields/payment_method.html.twig index fa2293254..452cff0d2 100644 --- a/templates/admin/order/refund/content/sections/form/fields/payment_method.html.twig +++ b/templates/admin/order/refund/content/sections/form/fields/payment_method.html.twig @@ -3,7 +3,7 @@ {% set payment_methods = hookable_metadata.context.payment_methods %} {% set original_payment_method = order.lastPayment(completed).method %} -
+