From 3c61308f24886198b2453f6179101fde95a9071e Mon Sep 17 00:00:00 2001 From: Dmitri Perunov Date: Thu, 5 Mar 2020 00:39:54 +0700 Subject: [PATCH] Convert RefundPayment state values to lowercase --- migrations/Version20200304172851.php | 32 +++++++++++++++++++ src/Entity/RefundPaymentInterface.php | 4 +-- src/Resources/config/app/config.yml | 8 ++--- .../Common/Label/refundPaymentState.html.twig | 13 ++++++++ .../Order/Admin/RefundPayment/list.html.twig | 6 ++-- .../Label/State/completed.html.twig | 4 --- .../RefundPayment/Label/State/new.html.twig | 4 --- 7 files changed, 54 insertions(+), 17 deletions(-) create mode 100644 migrations/Version20200304172851.php create mode 100644 src/Resources/views/Common/Label/refundPaymentState.html.twig delete mode 100644 src/Resources/views/RefundPayment/Label/State/completed.html.twig delete mode 100644 src/Resources/views/RefundPayment/Label/State/new.html.twig diff --git a/migrations/Version20200304172851.php b/migrations/Version20200304172851.php new file mode 100644 index 000000000..1cef5a32c --- /dev/null +++ b/migrations/Version20200304172851.php @@ -0,0 +1,32 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('UPDATE sylius_refund_payment SET state = "new" WHERE state = "New"'); + $this->addSql('UPDATE sylius_refund_payment SET state = "completed" WHERE state = "Completed"'); + } + + public function down(Schema $schema): void + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('UPDATE sylius_refund_payment SET state = "New" WHERE state = "new"'); + $this->addSql('UPDATE sylius_refund_payment SET state = "Completed" WHERE state = "completed"'); + } +} diff --git a/src/Entity/RefundPaymentInterface.php b/src/Entity/RefundPaymentInterface.php index a95ddd603..65226b53e 100644 --- a/src/Entity/RefundPaymentInterface.php +++ b/src/Entity/RefundPaymentInterface.php @@ -9,9 +9,9 @@ interface RefundPaymentInterface extends ResourceInterface { - public const STATE_NEW = 'New'; + public const STATE_NEW = 'new'; - public const STATE_COMPLETED = 'Completed'; + public const STATE_COMPLETED = 'completed'; public function getOrderNumber(): string; diff --git a/src/Resources/config/app/config.yml b/src/Resources/config/app/config.yml index d34706522..61a7babf1 100644 --- a/src/Resources/config/app/config.yml +++ b/src/Resources/config/app/config.yml @@ -46,12 +46,12 @@ winzou_state_machine: graph: sylius_refund_refund_payment state_machine_class: "%sylius.state_machine.class%" states: - New: ~ - Completed: ~ + new: ~ + completed: ~ transitions: complete: - from: [New] - to: Completed + from: [new] + to: completed sylius_grid: templates: diff --git a/src/Resources/views/Common/Label/refundPaymentState.html.twig b/src/Resources/views/Common/Label/refundPaymentState.html.twig new file mode 100644 index 000000000..249489238 --- /dev/null +++ b/src/Resources/views/Common/Label/refundPaymentState.html.twig @@ -0,0 +1,13 @@ +{% + set viewOptions = { + completed: { icon: 'adjust', color: 'green' }, + new: { icon: 'clock', color: 'olive' }, + } +%} + +{% set value = 'sylius.ui.' ~ data %} + + + + {{ value|trans }} + diff --git a/src/Resources/views/Order/Admin/RefundPayment/list.html.twig b/src/Resources/views/Order/Admin/RefundPayment/list.html.twig index e0e01fba0..2e83e63a8 100644 --- a/src/Resources/views/Order/Admin/RefundPayment/list.html.twig +++ b/src/Resources/views/Order/Admin/RefundPayment/list.html.twig @@ -1,5 +1,5 @@ -{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} -{% import "@SyliusUi/Macro/buttons.html.twig" as buttons %} +{% import '@SyliusAdmin/Common/Macro/money.html.twig' as money %} +{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %} {% if refund_payments|length > 0 %}
@@ -17,7 +17,7 @@ {{ money.format(refund_payment.amount, refund_payment.currencyCode) }} - {% include [('@SyliusRefundPlugin/RefundPayment/Label/State/' ~ refund_payment.state ~ '.html.twig'), '@SyliusUi/Label/_default.html.twig'] with {'value': refund_payment.state} %} + {% include '@SyliusRefundPlugin/Common/Label/refundPaymentState.html.twig' with {'data': refund_payment.state} %} {% if refund_payment.state != 'sylius_refund.ui.completed'|trans %} diff --git a/src/Resources/views/RefundPayment/Label/State/completed.html.twig b/src/Resources/views/RefundPayment/Label/State/completed.html.twig deleted file mode 100644 index 895532a77..000000000 --- a/src/Resources/views/RefundPayment/Label/State/completed.html.twig +++ /dev/null @@ -1,4 +0,0 @@ - - - {{ value|trans }} - diff --git a/src/Resources/views/RefundPayment/Label/State/new.html.twig b/src/Resources/views/RefundPayment/Label/State/new.html.twig deleted file mode 100644 index 253989898..000000000 --- a/src/Resources/views/RefundPayment/Label/State/new.html.twig +++ /dev/null @@ -1,4 +0,0 @@ - - - {{ value|trans }} -