From 7bd9ed7ee0881ef62841ef8cc48dac4f4afe20e4 Mon Sep 17 00:00:00 2001 From: Adam Kasperczak Date: Fri, 10 Jan 2020 13:44:34 +0100 Subject: [PATCH] Add breadcrumb for credit memo, fix refund breadcrumb --- src/Resources/config/admin_routing.yml | 10 ---- src/Resources/config/app/config.yml | 2 +- .../config/doctrine/CreditMemo.orm.xml | 2 +- src/Resources/config/services.xml | 5 -- .../Admin/CreditMemo/_breadcrumb.html.twig | 12 +++++ .../Order/Admin/CreditMemo/details.html.twig | 1 + .../views/Order/Grid/Field/number.html.twig | 2 +- src/Resources/views/_breadcrumb.html.twig | 11 ++++ src/Resources/views/orderRefunds.html.twig | 2 +- src/Ui/RedirectToOrderShowAction.php | 51 ------------------- .../Application/config/packages/doctrine.yaml | 3 -- 11 files changed, 28 insertions(+), 73 deletions(-) create mode 100644 src/Resources/views/Order/Admin/CreditMemo/_breadcrumb.html.twig create mode 100644 src/Resources/views/_breadcrumb.html.twig delete mode 100644 src/Ui/RedirectToOrderShowAction.php diff --git a/src/Resources/config/admin_routing.yml b/src/Resources/config/admin_routing.yml index 9cf60302f..c64f75b77 100644 --- a/src/Resources/config/admin_routing.yml +++ b/src/Resources/config/admin_routing.yml @@ -73,13 +73,3 @@ sylius_refund_admin_credit_memo_send: methods: [GET] defaults: _controller: Sylius\RefundPlugin\Action\Admin\SendCreditMemoAction - -sylius_refund_admin_order_show_by_number: - path: /orders/by-number/{number} - methods: [GET] - defaults: - _controller: Sylius\RefundPlugin\Ui\RedirectToOrderShowAction - _sylius: - section: admin - permission: true - alias: refund_plugin diff --git a/src/Resources/config/app/config.yml b/src/Resources/config/app/config.yml index ee36ac4c3..6dc0a5094 100644 --- a/src/Resources/config/app/config.yml +++ b/src/Resources/config/app/config.yml @@ -65,7 +65,7 @@ sylius_grid: orderNumber: type: twig label: sylius.ui.order - path: order.number + path: . sortable: ~ options: template: "@SyliusRefundPlugin/Order/Grid/Field/number.html.twig" diff --git a/src/Resources/config/doctrine/CreditMemo.orm.xml b/src/Resources/config/doctrine/CreditMemo.orm.xml index 3043842f1..c1becf540 100644 --- a/src/Resources/config/doctrine/CreditMemo.orm.xml +++ b/src/Resources/config/doctrine/CreditMemo.orm.xml @@ -21,7 +21,7 @@ - + diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 259d75537..c153aa916 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -75,11 +75,6 @@ - - - - - diff --git a/src/Resources/views/Order/Admin/CreditMemo/_breadcrumb.html.twig b/src/Resources/views/Order/Admin/CreditMemo/_breadcrumb.html.twig new file mode 100644 index 000000000..dd06c042c --- /dev/null +++ b/src/Resources/views/Order/Admin/CreditMemo/_breadcrumb.html.twig @@ -0,0 +1,12 @@ +{% import '@SyliusAdmin/Macro/breadcrumb.html.twig' as breadcrumb %} + +{% set breadcrumbs = [ + { label: 'sylius.ui.administration'|trans, url: path('sylius_admin_dashboard') }, + { label: 'sylius.ui.orders'|trans, url: path('sylius_admin_order_index') }, + { label: '#' ~ credit_memo.order.number, url: path('sylius_admin_order_show', {'id': credit_memo.order.id}) }, + { label: 'sylius_refund.ui.credit_memo'|trans }, + { label: credit_memo.number }, +] +%} + +{{ breadcrumb.crumble(breadcrumbs) }} diff --git a/src/Resources/views/Order/Admin/CreditMemo/details.html.twig b/src/Resources/views/Order/Admin/CreditMemo/details.html.twig index 9f5201271..f6fbce797 100644 --- a/src/Resources/views/Order/Admin/CreditMemo/details.html.twig +++ b/src/Resources/views/Order/Admin/CreditMemo/details.html.twig @@ -10,6 +10,7 @@
{% include '@SyliusRefundPlugin/Order/Admin/CreditMemo/_header.html.twig' %} + {% include '@SyliusRefundPlugin/Order/Admin/CreditMemo/_breadcrumb.html.twig' %}
{{ buttons.default( diff --git a/src/Resources/views/Order/Grid/Field/number.html.twig b/src/Resources/views/Order/Grid/Field/number.html.twig index dc337e388..4be075695 100644 --- a/src/Resources/views/Order/Grid/Field/number.html.twig +++ b/src/Resources/views/Order/Grid/Field/number.html.twig @@ -1 +1 @@ -#{{ data }} +#{{ data.order.number }} diff --git a/src/Resources/views/_breadcrumb.html.twig b/src/Resources/views/_breadcrumb.html.twig new file mode 100644 index 000000000..eba1a52c3 --- /dev/null +++ b/src/Resources/views/_breadcrumb.html.twig @@ -0,0 +1,11 @@ +{% import '@SyliusAdmin/Macro/breadcrumb.html.twig' as breadcrumb %} + +{% set breadcrumbs = [ + { label: 'sylius.ui.administration'|trans, url: path('sylius_admin_dashboard') }, + { label: 'sylius.ui.orders'|trans, url: path('sylius_admin_order_index') }, + { label: '#' ~ order.number, url: path('sylius_admin_order_show', {'id': order.id}) }, + { label: 'sylius_refund.ui.refund'|trans }, +] +%} + +{{ breadcrumb.crumble(breadcrumbs) }} diff --git a/src/Resources/views/orderRefunds.html.twig b/src/Resources/views/orderRefunds.html.twig index 7ab6f343e..f557ca6ed 100644 --- a/src/Resources/views/orderRefunds.html.twig +++ b/src/Resources/views/orderRefunds.html.twig @@ -7,7 +7,7 @@ {% block content %} {% include '@SyliusRefundPlugin/_header.html.twig' %} - {% include '@SyliusAdmin/Order/Show/_breadcrumb.html.twig' %} + {% include '@SyliusRefundPlugin/_breadcrumb.html.twig' %}
diff --git a/src/Ui/RedirectToOrderShowAction.php b/src/Ui/RedirectToOrderShowAction.php deleted file mode 100644 index 6767617ba..000000000 --- a/src/Ui/RedirectToOrderShowAction.php +++ /dev/null @@ -1,51 +0,0 @@ -router = $router; - $this->orderRepository = $orderRepository; - } - - public function __invoke(Request $request): Response - { - $number = $request->attributes->get('number'); - - $order = $this->orderRepository->findOneByNumber($number); - Assert::notNull($order); - - /** @var OrderInterface $order */ - return RedirectResponse::create($this->router->generate( - 'sylius_admin_order_show', - ['id' => $order->getId()] - )); - } -} diff --git a/tests/Application/config/packages/doctrine.yaml b/tests/Application/config/packages/doctrine.yaml index eaae1f64b..f51ba5a22 100644 --- a/tests/Application/config/packages/doctrine.yaml +++ b/tests/Application/config/packages/doctrine.yaml @@ -12,6 +12,3 @@ doctrine: charset: UTF8 url: '%env(resolve:DATABASE_URL)%' - orm: - resolve_target_entities: - Sylius\Component\Core\Model\OrderInterface: Sylius\Component\Core\Model\Order