From 00c6a357073e6385bcbe55664525c1703bf7d5e8 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 --- migrations/Version20191230121402.php | 4 +- spec/Entity/CreditMemoSpec.php | 2 +- src/Resources/config/admin_routing.yml | 10 ---- src/Resources/config/app/config.yml | 3 +- .../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 -- tests/Behat/Resources/suites.yml | 1 - 14 files changed, 31 insertions(+), 78 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/migrations/Version20191230121402.php b/migrations/Version20191230121402.php index e935a500..17c6d6a0 100644 --- a/migrations/Version20191230121402.php +++ b/migrations/Version20191230121402.php @@ -9,7 +9,7 @@ final class Version20191230121402 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); @@ -29,7 +29,7 @@ public function up(Schema $schema) : void $this->addSql('CREATE INDEX IDX_5C4F33318D9F6D38 ON sylius_refund_credit_memo (order_id)'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); diff --git a/spec/Entity/CreditMemoSpec.php b/spec/Entity/CreditMemoSpec.php index 31660f3d..3323933e 100644 --- a/spec/Entity/CreditMemoSpec.php +++ b/spec/Entity/CreditMemoSpec.php @@ -49,7 +49,7 @@ function it_has_number(): void $this->getNumber()->shouldReturn('2018/07/00003333'); } - function it_has_order(OrderInterface $order): void + function it_has_an_order(OrderInterface $order): void { $this->getOrder()->shouldReturn($order); } diff --git a/src/Resources/config/admin_routing.yml b/src/Resources/config/admin_routing.yml index 9cf60302..c64f75b7 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 ee36ac4c..e6828a90 100644 --- a/src/Resources/config/app/config.yml +++ b/src/Resources/config/app/config.yml @@ -62,10 +62,9 @@ sylius_grid: type: string label: sylius.ui.number sortable: ~ - orderNumber: + order: type: twig label: sylius.ui.order - path: order.number 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 3043842f..c1becf54 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 259d7553..c153aa91 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 00000000..ad0d2704 --- /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 9f520127..f6fbce79 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 dc337e38..a60c3584 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.number }} diff --git a/src/Resources/views/_breadcrumb.html.twig b/src/Resources/views/_breadcrumb.html.twig new file mode 100644 index 00000000..3461528f --- /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 7ab6f343..f557ca6e 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 6767617b..00000000 --- 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 eaae1f64..f51ba5a2 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 diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml index 8b772032..318c8eae 100644 --- a/tests/Behat/Resources/suites.yml +++ b/tests/Behat/Resources/suites.yml @@ -12,7 +12,6 @@ default: - sylius.behat.context.transform.lexical - sylius.behat.context.transform.order - sylius.behat.context.transform.payment - - sylius.behat.context.transform.payment - sylius.behat.context.transform.product - sylius.behat.context.transform.promotion - sylius.behat.context.transform.shared_storage