Skip to content

Commit

Permalink
Convert RefundPayment state values to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
diimpp committed Mar 4, 2020
1 parent d05447c commit 3c61308
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 17 deletions.
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
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' },
new: { icon: 'clock', color: 'olive' },
}
%}

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

<span class="ui {{ viewOptions[data]['color'] }} label">
<i class="{{ viewOptions[data]['icon'] }} icon"></i>
{{ value|trans }}
</span>
6 changes: 3 additions & 3 deletions src/Resources/views/Order/Admin/RefundPayment/list.html.twig
Original file line number Diff line number Diff line change
@@ -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 %}
<div class="ui segment" id="refund-payments">
Expand All @@ -17,7 +17,7 @@
<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} %}
</td>
<td class="aligned collapsing">
{% if refund_payment.state != 'sylius_refund.ui.completed'|trans %}
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.

0 comments on commit 3c61308

Please sign in to comment.