From 54b3b565fa526cf2be2fe2d6082b004261837acd Mon Sep 17 00:00:00 2001 From: Mateusz Zalewski Date: Tue, 14 Feb 2017 12:01:28 +0100 Subject: [PATCH] [Admin] Adjust channel form for new functionality --- .../managing_channels/adding_channel.feature | 1 + .../Context/Ui/Admin/ManagingChannelsContext.php | 8 ++++++++ src/Sylius/Behat/Page/Admin/Channel/CreatePage.php | 5 +++++ .../Page/Admin/Channel/CreatePageInterface.php | 2 ++ .../Resources/views/Channel/_form.html.twig | 1 + .../Form/Extension/ChannelTypeExtension.php | 5 +++++ .../Resources/translations/messages.en.yml | 13 +++++++------ 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/features/channel/managing_channels/adding_channel.feature b/features/channel/managing_channels/adding_channel.feature index cdba99424a..f0f3d79f85 100644 --- a/features/channel/managing_channels/adding_channel.feature +++ b/features/channel/managing_channels/adding_channel.feature @@ -31,6 +31,7 @@ Feature: Adding a new channel And I define its color as "blue" And I choose "Euro" as the base currency And I choose "English (United States)" as a default locale + And I allow to skip shipping step if only one shipping method is available And I add it Then I should be notified that it has been successfully created And the channel "Mobile channel" should appear in the registry diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php index 15e70128cd..3c1e394b58 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php @@ -119,6 +119,14 @@ final class ManagingChannelsContext implements Context $this->createPage->chooseDefaultLocale($locale); } + /** + * @When I allow to skip shipping step if only one shipping method is available + */ + public function iAllowToSkipShippingStepIfOnlyOneShippingMethodIsAvailable() + { + $this->createPage->allowToSkipShippingStep(); + } + /** * @When I add it * @When I try to add it diff --git a/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php b/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php index 0d986d848c..812c375e53 100644 --- a/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/Channel/CreatePage.php @@ -105,6 +105,11 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface $this->getDocument()->selectFieldOption('Tax calculation strategy', $taxZone); } + public function allowToSkipShippingStep() + { + $this->getDocument()->checkField('Skip shipping step if only one shipping method is available?'); + } + /** * {@inheritdoc} */ diff --git a/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php b/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php index 3f872a131b..10d8a9421b 100644 --- a/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php @@ -81,4 +81,6 @@ interface CreatePageInterface extends BaseCreatePageInterface * @param string $taxCalculationStrategy */ public function chooseTaxCalculationStrategy($taxCalculationStrategy); + + public function allowToSkipShippingStep(); } diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Channel/_form.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Channel/_form.html.twig index c0f487ff5f..0ca31578ba 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Channel/_form.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Channel/_form.html.twig @@ -34,6 +34,7 @@ {{ form_row(form.baseCurrency) }} {{ form_row(form.defaultTaxZone) }} {{ form_row(form.taxCalculationStrategy) }} + {{ form_row(form.skippingShippingStepAllowed) }} diff --git a/src/Sylius/Bundle/CoreBundle/Form/Extension/ChannelTypeExtension.php b/src/Sylius/Bundle/CoreBundle/Form/Extension/ChannelTypeExtension.php index 97f986243b..c96a274f22 100644 --- a/src/Sylius/Bundle/CoreBundle/Form/Extension/ChannelTypeExtension.php +++ b/src/Sylius/Bundle/CoreBundle/Form/Extension/ChannelTypeExtension.php @@ -20,6 +20,7 @@ use Sylius\Bundle\CurrencyBundle\Form\Type\CurrencyChoiceType; use Sylius\Bundle\LocaleBundle\Form\Type\LocaleChoiceType; use Sylius\Bundle\ThemeBundle\Form\Type\ThemeNameChoiceType; use Symfony\Component\Form\AbstractTypeExtension; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\FormBuilderInterface; @@ -68,6 +69,10 @@ final class ChannelTypeExtension extends AbstractTypeExtension 'label' => 'sylius.form.channel.contact_email', 'required' => false, ]) + ->add('skippingShippingStepAllowed', CheckboxType::class, [ + 'label' => 'sylius.form.channel.skipping_shipping_step_allowed', + 'required' => false, + ]) ->addEventSubscriber(new AddBaseCurrencySubscriber()) ->addEventSubscriber(new ChannelFormSubscriber()) ; diff --git a/src/Sylius/Bundle/CoreBundle/Resources/translations/messages.en.yml b/src/Sylius/Bundle/CoreBundle/Resources/translations/messages.en.yml index 6bd175a6e4..f2f76e8171 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Sylius/Bundle/CoreBundle/Resources/translations/messages.en.yml @@ -22,18 +22,19 @@ sylius: name: Name roles: Roles channel: - taxonomies: Taxonomies + contact_email: Contact email + currencies: Currencies + currency_base: Base currency + hostname: Hostname locale_default: Default locale locales: Locales - contact_email: Contact email - currency_base: Base currency - currencies: Currencies - shipping_methods: Shipping Methods payment_methods: Payment Methods + shipping_methods: Shipping Methods + skipping_shipping_step_allowed: Skip shipping step if only one shipping method is available? tax_calculation_strategy: Tax calculation strategy tax_zone_default: Default tax zone + taxonomies: Taxonomies theme: Theme - hostname: Hostname image: type: Type file: Image