Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert RefundPayment state values to lowercase #197

Merged
merged 1 commit into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### UPGRADE FROM 1.0.0-RC.2 TO 1.0.0-RC.3

1. `Sylius\RefundPlugin\Entity\RefundPaymentInterface` state constants values were changed to lowercase. Backward compatibility provided by migration.

### UPGRADE FROM 1.0.0-RC.1 TO 1.0.0-RC.2

1. `Sylius\RefundPlugin\Entity\CreditMemoUnit` was changed to `Sylius\RefundPlugin\Entity\LineItem` which is a resource entity now.
Expand All @@ -10,7 +14,7 @@

5. `Sylius\RefundPlugin\Entity\TaxItem` became a resource entity.

There are no migrations that provide backward compatibility, save current credit memos before upgrading the version of plugin.
There are no migrations that provide backward compatibility, save current credit memos before upgrading the version of plugin.

### UPGRADE FROM 0.10.1 TO 1.0.0-RC.1

Expand Down
32 changes: 32 additions & 0 deletions migrations/Version20200304172851.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20200304172851 extends AbstractMigration
{
public function getDescription(): string
{
return 'Updates sylius_refund_payment state values to new schema';
}

public function up(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"');
}

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"');
}
}
4 changes: 2 additions & 2 deletions src/Entity/RefundPaymentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions src/Resources/config/app/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions src/Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ sylius_refund:
ui:
buyer: Buyer
clear_refunds: Clear all
new: New
completed: Completed
credit_memo: Credit memo
credit_memos: Credit memos
Expand Down Expand Up @@ -31,5 +32,5 @@ sylius_refund:

sylius:
ui:
original_payment_method: "Original Payment Method"
partially_refunded: 'Partially refunded'
original_payment_method: Original Payment Method
partially_refunded: Partially refunded
4 changes: 2 additions & 2 deletions src/Resources/translations/messages.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ sylius_refund:

sylius:
ui:
original_payment_method: "Moyen de paiement d'origine"
partially_refunded: 'Partiellement remboursé'
original_payment_method: Moyen de paiement d'origine
partially_refunded: Partiellement remboursé
13 changes: 13 additions & 0 deletions src/Resources/views/Common/Label/refundPaymentState.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{%
set viewOptions = {
completed: { icon: 'adjust', color: 'green' },
Copy link
Member Author

@diimpp diimpp Mar 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colors and icons are re-used from regular payment label. To me it looks better balanced.

new: { icon: 'clock', color: 'olive' },
}
%}

{% set value = 'sylius_refund.ui.' ~ data %}

<span class="ui {{ viewOptions[data]['color'] }} label">
<i class="{{ viewOptions[data]['icon'] }} icon"></i>
{{ value|trans }}
</span>
12 changes: 4 additions & 8 deletions src/Resources/views/Order/Admin/RefundPayment/list.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% 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 %}

{% if refund_payments|length > 0 %}
<div class="ui segment" id="refund-payments">
Expand All @@ -17,15 +16,12 @@
<tr>
<td>{{ money.format(refund_payment.amount, refund_payment.currencyCode) }}</td>
<td>
{% 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} %}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include is redesigned in fashion of SyliusAdmin/SyliusShop paymentState label.

</td>
<td class="aligned collapsing">
{% if refund_payment.state != 'sylius_refund.ui.completed'|trans %}
{% if sm_can(refund_payment, 'complete', 'sylius_refund_refund_payment') %}
<form action="{{ path('sylius_refund_complete_refund_payment', {'orderNumber': refund_payment.orderNumber, 'id': refund_payment.id}) }}" method="POST">
<button class="button ui labeled icon yellow">
<i class="icon check"></i>
{{ 'sylius.ui.complete'|trans }}
</button>
<button class="ui icon labeled yellow loadable button"><i class="check icon"></i> {{ 'sylius.ui.complete'|trans }}</button>
</form>
{% endif %}
</td>
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions src/Resources/views/RefundPayment/Label/State/new.html.twig

This file was deleted.