From 40118089ae02b470c7889f65be67fe33415d3176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20S=C4=99k?= Date: Mon, 9 Dec 2024 16:10:14 +0100 Subject: [PATCH] Implement twig hooks in credit_memos partials --- config/app/twig_hooks/admin/order/show.yaml | 26 ++++++++++++-- .../twig_hooks/shop/account/order/show.yaml | 27 ++++++++++++-- .../admin/credit_memo/show/list.html.twig | 32 ----------------- .../admin/order/credit_memo/list.html.twig | 36 +++++++------------ .../order/credit_memo/list/actions.html.twig | 3 ++ .../order/credit_memo/list/channel.html.twig | 5 +++ .../order/credit_memo/list/details.html.twig | 5 +++ .../credit_memo/list/details/date.html.twig | 3 ++ .../credit_memo/list/details/number.html.twig | 3 ++ .../order/credit_memo/list/total.html.twig | 5 +++ templates/shop/order/credit_memos.html.twig | 22 +----------- .../shop/order/credit_memos/header.html.twig | 1 + .../shop/order/credit_memos/list.html.twig | 13 +++++++ .../order/credit_memos/list/details.html.twig | 5 +++ .../credit_memos/list/details/date.html.twig | 3 ++ .../list/details/number.html.twig | 3 ++ .../credit_memos/list/download.html.twig | 5 +++ .../order/credit_memos/list/total.html.twig | 3 ++ .../shop/order/download_button.html.twig | 17 --------- 19 files changed, 119 insertions(+), 98 deletions(-) delete mode 100644 templates/admin/credit_memo/show/list.html.twig create mode 100644 templates/admin/order/credit_memo/list/actions.html.twig create mode 100644 templates/admin/order/credit_memo/list/channel.html.twig create mode 100644 templates/admin/order/credit_memo/list/details.html.twig create mode 100644 templates/admin/order/credit_memo/list/details/date.html.twig create mode 100644 templates/admin/order/credit_memo/list/details/number.html.twig create mode 100644 templates/admin/order/credit_memo/list/total.html.twig create mode 100644 templates/shop/order/credit_memos/header.html.twig create mode 100644 templates/shop/order/credit_memos/list.html.twig create mode 100644 templates/shop/order/credit_memos/list/details.html.twig create mode 100644 templates/shop/order/credit_memos/list/details/date.html.twig create mode 100644 templates/shop/order/credit_memos/list/details/number.html.twig create mode 100644 templates/shop/order/credit_memos/list/download.html.twig create mode 100644 templates/shop/order/credit_memos/list/total.html.twig delete mode 100644 templates/shop/order/download_button.html.twig diff --git a/config/app/twig_hooks/admin/order/show.yaml b/config/app/twig_hooks/admin/order/show.yaml index 92a778efe..d5256e70e 100644 --- a/config/app/twig_hooks/admin/order/show.yaml +++ b/config/app/twig_hooks/admin/order/show.yaml @@ -50,7 +50,7 @@ sylius_twig_hooks: header: template: '@SyliusRefundPlugin/admin/order/content/sections/credit_memos/header.html.twig' priority: 100 - items: + list: component: 'sylius_refund:admin:credit_memos' props: order: '@=_context.order' @@ -62,7 +62,29 @@ sylius_twig_hooks: template: '@SyliusRefundPlugin/admin/order/content/sections/credit_memos/header/title.html.twig' priority: 0 - 'sylius_admin.order.show.content.sections.credit_memos.credit_memos.items.actions': + 'sylius_admin.order.show.content.sections.credit_memos.list': + details: + template: '@SyliusRefundPlugin/admin/order/credit_memo/list/details.html.twig' + priority: 300 + channel: + template: '@SyliusRefundPlugin/admin/order/credit_memo/list/channel.html.twig' + priority: 200 + total: + template: '@SyliusRefundPlugin/admin/order/credit_memo/list/total.html.twig' + priority: 100 + actions: + template: '@SyliusRefundPlugin/admin/order/credit_memo/list/actions.html.twig' + priority: 0 + + 'sylius_admin.order.show.content.sections.credit_memos.list.details': + date: + template: '@SyliusRefundPlugin/admin/order/credit_memo/list/details/date.html.twig' + priority: 100 + number: + template: '@SyliusRefundPlugin/admin/order/credit_memo/list/details/number.html.twig' + priority: 0 + + 'sylius_admin.order.show.content.sections.credit_memos.list.actions': download: template: '@SyliusRefundPlugin/admin/order/content/sections/credit_memos/items/actions/download.html.twig' enabled: '%sylius_refund.pdf_generator.enabled%' diff --git a/config/app/twig_hooks/shop/account/order/show.yaml b/config/app/twig_hooks/shop/account/order/show.yaml index d7470f194..eec4cad7b 100644 --- a/config/app/twig_hooks/shop/account/order/show.yaml +++ b/config/app/twig_hooks/shop/account/order/show.yaml @@ -9,7 +9,30 @@ sylius_twig_hooks: priority: -100 'sylius_shop.account.order.show.content.main.credit_memos': - list_action_buttons: - template: '@SyliusRefundPlugin/shop/order/download_button.html.twig' + header: + template: '@SyliusRefundPlugin/shop/order/credit_memos/header.html.twig' + priority: 100 + list: + template: '@SyliusRefundPlugin/shop/order/credit_memos/list.html.twig' + priority: 0 + + 'sylius_shop.account.order.show.content.main.credit_memos.list': + details: + template: '@SyliusRefundPlugin/shop/order/credit_memos/list/details.html.twig' + priority: 300 + total: + template: '@SyliusRefundPlugin/shop/order/credit_memos/list/total.html.twig' + priority: 100 + download: + template: '@SyliusRefundPlugin/shop/order/credit_memos/list/download.html.twig' enabled: '%sylius_refund.pdf_generator.enabled%' priority: 0 + + 'sylius_shop.account.order.show.content.main.credit_memos.list.details': + date: + template: '@SyliusRefundPlugin/shop/order/credit_memos/list/details/date.html.twig' + priority: 100 + number: + template: '@SyliusRefundPlugin/shop/order/credit_memos/list/details/number.html.twig' + priority: 0 + diff --git a/templates/admin/credit_memo/show/list.html.twig b/templates/admin/credit_memo/show/list.html.twig deleted file mode 100644 index 55e6ad130..000000000 --- a/templates/admin/credit_memo/show/list.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{% import '@SyliusAdmin/shared/helper/money.html.twig' as money %} - -{% if credit_memos|length > 0 %} -
- - - - - - - - - - - - {% for credit_memo in credit_memos %} - - - - - - - - {% endfor %} - -
{{ 'sylius.ui.number'|trans }}{{ 'sylius.ui.channel'|trans }}{{ 'sylius.ui.total'|trans }}{{ 'sylius_refund.ui.issued_at'|trans }}{{ 'sylius.ui.actions'|trans }}
{{ credit_memo.number }}{% include '@SyliusAdmin/shared/grid/field/channel.html.twig' with {'data': credit_memo.channel} %}{{ money.format(credit_memo.total, credit_memo.currencyCode) }}{{ credit_memo.issuedAt|date('d-m-Y') }} -
- {% hook 'sylius_admin.order.show.content.sections.credit_memos.credit_memos.items.actions' %} -
-
-
-{% endif %} diff --git a/templates/admin/order/credit_memo/list.html.twig b/templates/admin/order/credit_memo/list.html.twig index 29ded7aea..55dbb6621 100644 --- a/templates/admin/order/credit_memo/list.html.twig +++ b/templates/admin/order/credit_memo/list.html.twig @@ -1,27 +1,15 @@ -{% import '@SyliusAdmin/shared/helper/money.html.twig' as money %} - {% if credit_memos|length > 0 %} -
-
- - - {% for credit_memo in credit_memos %} - - - - - - - {% endfor %} - -
-
- {{ credit_memo.issuedAt|date('d-m-Y') }} -
{{ credit_memo.number }}
-
-
{% include '@SyliusAdmin/shared/grid/field/channel.html.twig' with {'data': credit_memo.channel} %}{{ money.format(credit_memo.total, credit_memo.currencyCode) }} - {% hook 'sylius_admin.order.show.content.sections.credit_memos.credit_memos.items.actions' %} -
+
+
+ + + {% for credit_memo in credit_memos %} + + {% hook 'sylius_admin.order.show.content.sections.credit_memos.list' %} + + {% endfor %} + +
+
-
{% endif %} diff --git a/templates/admin/order/credit_memo/list/actions.html.twig b/templates/admin/order/credit_memo/list/actions.html.twig new file mode 100644 index 000000000..58915e99e --- /dev/null +++ b/templates/admin/order/credit_memo/list/actions.html.twig @@ -0,0 +1,3 @@ + + {% hook 'actions' %} + diff --git a/templates/admin/order/credit_memo/list/channel.html.twig b/templates/admin/order/credit_memo/list/channel.html.twig new file mode 100644 index 000000000..1f8af1671 --- /dev/null +++ b/templates/admin/order/credit_memo/list/channel.html.twig @@ -0,0 +1,5 @@ +{% set credit_memo = hookable_metadata.context.credit_memo %} + + + {% include '@SyliusAdmin/shared/grid/field/channel.html.twig' with {'data': credit_memo.channel} %} + diff --git a/templates/admin/order/credit_memo/list/details.html.twig b/templates/admin/order/credit_memo/list/details.html.twig new file mode 100644 index 000000000..b121999d9 --- /dev/null +++ b/templates/admin/order/credit_memo/list/details.html.twig @@ -0,0 +1,5 @@ + +
+ {% hook 'details' %} +
+ diff --git a/templates/admin/order/credit_memo/list/details/date.html.twig b/templates/admin/order/credit_memo/list/details/date.html.twig new file mode 100644 index 000000000..ac683aa51 --- /dev/null +++ b/templates/admin/order/credit_memo/list/details/date.html.twig @@ -0,0 +1,3 @@ +{% set credit_memo = hookable_metadata.context.credit_memo %} + +{{ credit_memo.issuedAt|date('d-m-Y') }} diff --git a/templates/admin/order/credit_memo/list/details/number.html.twig b/templates/admin/order/credit_memo/list/details/number.html.twig new file mode 100644 index 000000000..a9fac012a --- /dev/null +++ b/templates/admin/order/credit_memo/list/details/number.html.twig @@ -0,0 +1,3 @@ +{% set credit_memo = hookable_metadata.context.credit_memo %} + +
{{ credit_memo.number }}
diff --git a/templates/admin/order/credit_memo/list/total.html.twig b/templates/admin/order/credit_memo/list/total.html.twig new file mode 100644 index 000000000..598975ffc --- /dev/null +++ b/templates/admin/order/credit_memo/list/total.html.twig @@ -0,0 +1,5 @@ +{% import '@SyliusAdmin/shared/helper/money.html.twig' as money %} + +{% set credit_memo = hookable_metadata.context.credit_memo %} + +{{ money.format(credit_memo.total, credit_memo.currencyCode) }} diff --git a/templates/shop/order/credit_memos.html.twig b/templates/shop/order/credit_memos.html.twig index 3bb4c5398..fcebff408 100644 --- a/templates/shop/order/credit_memos.html.twig +++ b/templates/shop/order/credit_memos.html.twig @@ -1,25 +1,5 @@ {% if credit_memos|length > 0 %}
-
{{ 'sylius_refund.ui.credit_memos'|trans }}
-
- - - {% for credit_memo in credit_memos %} - - - - - - {% endfor %} - -
-
- {{ credit_memo.issuedAt|date('d-m-Y') }} - {{ credit_memo.number }} -
-
{{ credit_memo.total|sylius_format_money(credit_memo.currencyCode, credit_memo.localeCode) }} - {% hook 'sylius_shop.account.order.show.content.main.credit_memos' %} -
-
+ {% hook 'sylius_shop.account.order.show.content.main.credit_memos' with { credit_memos } %}
{% endif %} diff --git a/templates/shop/order/credit_memos/header.html.twig b/templates/shop/order/credit_memos/header.html.twig new file mode 100644 index 000000000..452935c52 --- /dev/null +++ b/templates/shop/order/credit_memos/header.html.twig @@ -0,0 +1 @@ +
{{ 'sylius_refund.ui.credit_memos'|trans }}
diff --git a/templates/shop/order/credit_memos/list.html.twig b/templates/shop/order/credit_memos/list.html.twig new file mode 100644 index 000000000..71b8ef770 --- /dev/null +++ b/templates/shop/order/credit_memos/list.html.twig @@ -0,0 +1,13 @@ +{% set credit_memos = hookable_metadata.context.credit_memos %} + +
+ + + {% for credit_memo in credit_memos %} + + {% hook 'list' %} + + {% endfor %} + +
+
diff --git a/templates/shop/order/credit_memos/list/details.html.twig b/templates/shop/order/credit_memos/list/details.html.twig new file mode 100644 index 000000000..f661269b0 --- /dev/null +++ b/templates/shop/order/credit_memos/list/details.html.twig @@ -0,0 +1,5 @@ + +
+ {% hook 'details' %} +
+ diff --git a/templates/shop/order/credit_memos/list/details/date.html.twig b/templates/shop/order/credit_memos/list/details/date.html.twig new file mode 100644 index 000000000..ac683aa51 --- /dev/null +++ b/templates/shop/order/credit_memos/list/details/date.html.twig @@ -0,0 +1,3 @@ +{% set credit_memo = hookable_metadata.context.credit_memo %} + +{{ credit_memo.issuedAt|date('d-m-Y') }} diff --git a/templates/shop/order/credit_memos/list/details/number.html.twig b/templates/shop/order/credit_memos/list/details/number.html.twig new file mode 100644 index 000000000..29f5acf54 --- /dev/null +++ b/templates/shop/order/credit_memos/list/details/number.html.twig @@ -0,0 +1,3 @@ +{% set credit_memo = hookable_metadata.context.credit_memo %} + +{{ credit_memo.number }} diff --git a/templates/shop/order/credit_memos/list/download.html.twig b/templates/shop/order/credit_memos/list/download.html.twig new file mode 100644 index 000000000..d43fc052e --- /dev/null +++ b/templates/shop/order/credit_memos/list/download.html.twig @@ -0,0 +1,5 @@ + + + {{ ux_icon('tabler:download') }} + + diff --git a/templates/shop/order/credit_memos/list/total.html.twig b/templates/shop/order/credit_memos/list/total.html.twig new file mode 100644 index 000000000..7bfaca5b4 --- /dev/null +++ b/templates/shop/order/credit_memos/list/total.html.twig @@ -0,0 +1,3 @@ +{% set credit_memo = hookable_metadata.context.credit_memo %} + +{{ credit_memo.total|sylius_format_money(credit_memo.currencyCode, credit_memo.localeCode) }} diff --git a/templates/shop/order/download_button.html.twig b/templates/shop/order/download_button.html.twig deleted file mode 100644 index 4999a1679..000000000 --- a/templates/shop/order/download_button.html.twig +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - -