Skip to content

Commit

Permalink
Implement twig hooks in credit_memos partials
Browse files Browse the repository at this point in the history
  • Loading branch information
bartek-sek committed Dec 10, 2024
1 parent 6c4512f commit 4011808
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 98 deletions.
26 changes: 24 additions & 2 deletions config/app/twig_hooks/admin/order/show.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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%'
Expand Down
27 changes: 25 additions & 2 deletions config/app/twig_hooks/shop/account/order/show.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

32 changes: 0 additions & 32 deletions templates/admin/credit_memo/show/list.html.twig

This file was deleted.

36 changes: 12 additions & 24 deletions templates/admin/order/credit_memo/list.html.twig
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
{% import '@SyliusAdmin/shared/helper/money.html.twig' as money %}

{% if credit_memos|length > 0 %}
<div class="py-3">
<div class="table-responsive">
<table class="table table-vcenter table-borderless table-sm card-table" id="credit-memos">
<tbody>
{% for credit_memo in credit_memos %}
<tr>
<td class="w-1 py-2">
<div class="d-flex flex-column">
<strong>{{ credit_memo.issuedAt|date('d-m-Y') }}</strong>
<div class="text-secondary">{{ credit_memo.number }}</div>
</div>
</td>
<td class="text-center">{% include '@SyliusAdmin/shared/grid/field/channel.html.twig' with {'data': credit_memo.channel} %}</td>
<td class="text-end"><strong>{{ money.format(credit_memo.total, credit_memo.currencyCode) }}</strong></td>
<td class="w-1">
{% hook 'sylius_admin.order.show.content.sections.credit_memos.credit_memos.items.actions' %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="py-3">
<div class="table-responsive">
<table class="table table-vcenter table-borderless table-sm card-table" id="credit-memos">
<tbody>
{% for credit_memo in credit_memos %}
<tr>
{% hook 'sylius_admin.order.show.content.sections.credit_memos.list' %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
3 changes: 3 additions & 0 deletions templates/admin/order/credit_memo/list/actions.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<td class="w-1">
{% hook 'actions' %}
</td>
5 changes: 5 additions & 0 deletions templates/admin/order/credit_memo/list/channel.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% set credit_memo = hookable_metadata.context.credit_memo %}

<td class="text-center">
{% include '@SyliusAdmin/shared/grid/field/channel.html.twig' with {'data': credit_memo.channel} %}
</td>
5 changes: 5 additions & 0 deletions templates/admin/order/credit_memo/list/details.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<td class="w-1 py-2">
<div class="d-flex flex-column">
{% hook 'details' %}
</div>
</td>
3 changes: 3 additions & 0 deletions templates/admin/order/credit_memo/list/details/date.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% set credit_memo = hookable_metadata.context.credit_memo %}

<strong>{{ credit_memo.issuedAt|date('d-m-Y') }}</strong>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% set credit_memo = hookable_metadata.context.credit_memo %}

<div class="text-secondary">{{ credit_memo.number }}</div>
5 changes: 5 additions & 0 deletions templates/admin/order/credit_memo/list/total.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% import '@SyliusAdmin/shared/helper/money.html.twig' as money %}

{% set credit_memo = hookable_metadata.context.credit_memo %}

<td class="text-end"><strong>{{ money.format(credit_memo.total, credit_memo.currencyCode) }}</strong></td>
22 changes: 1 addition & 21 deletions templates/shop/order/credit_memos.html.twig
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
{% if credit_memos|length > 0 %}
<div class="card border-0 bg-body-tertiary mb-3" id="credit-memos">
<div class="card-header">{{ 'sylius_refund.ui.credit_memos'|trans }}</div>
<div class="card-body">
<table class="table align-middle mb-0">
<tbody>
{% for credit_memo in credit_memos %}
<tr>
<td>
<div class="d-flex flex-column">
<strong>{{ credit_memo.issuedAt|date('d-m-Y') }}</strong>
<span class="text-body-tertiary">{{ credit_memo.number }}</span>
</div>
</td>
<td class="text-end">{{ credit_memo.total|sylius_format_money(credit_memo.currencyCode, credit_memo.localeCode) }}</td>
<td class="w-1">
{% hook 'sylius_shop.account.order.show.content.main.credit_memos' %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% hook 'sylius_shop.account.order.show.content.main.credit_memos' with { credit_memos } %}
</div>
{% endif %}
1 change: 1 addition & 0 deletions templates/shop/order/credit_memos/header.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="card-header">{{ 'sylius_refund.ui.credit_memos'|trans }}</div>
13 changes: 13 additions & 0 deletions templates/shop/order/credit_memos/list.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% set credit_memos = hookable_metadata.context.credit_memos %}

<div class="card-body">
<table class="table align-middle mb-0">
<tbody>
{% for credit_memo in credit_memos %}
<tr>
{% hook 'list' %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
5 changes: 5 additions & 0 deletions templates/shop/order/credit_memos/list/details.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<td>
<div class="d-flex flex-column">
{% hook 'details' %}
</div>
</td>
3 changes: 3 additions & 0 deletions templates/shop/order/credit_memos/list/details/date.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% set credit_memo = hookable_metadata.context.credit_memo %}

<strong>{{ credit_memo.issuedAt|date('d-m-Y') }}</strong>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% set credit_memo = hookable_metadata.context.credit_memo %}

<span class="text-body-tertiary">{{ credit_memo.number }}</span>
5 changes: 5 additions & 0 deletions templates/shop/order/credit_memos/list/download.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<td class="w-1">
<a href="{{ path('sylius_refund_shop_credit_memo_download', {'id': hookable_metadata.context.credit_memo.id}) }}" {{ sylius_test_html_attribute('download-button') }}>
{{ ux_icon('tabler:download') }}
</a>
</td>
3 changes: 3 additions & 0 deletions templates/shop/order/credit_memos/list/total.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% set credit_memo = hookable_metadata.context.credit_memo %}

<td class="text-end">{{ credit_memo.total|sylius_format_money(credit_memo.currencyCode, credit_memo.localeCode) }}</td>
17 changes: 0 additions & 17 deletions templates/shop/order/download_button.html.twig

This file was deleted.

0 comments on commit 4011808

Please sign in to comment.