diff --git a/assets/admin/js/test_payment_method_connection.js b/assets/admin/js/test_payment_method_connection.js index 86fd1091..65fe1f30 100644 --- a/assets/admin/js/test_payment_method_connection.js +++ b/assets/admin/js/test_payment_method_connection.js @@ -59,12 +59,20 @@ function convertTpayChannelIdInputIntoSelect(channels) { select.name = tpayChannelIdFormType.name; select.id = tpayChannelIdFormType.id; select.className = tpayChannelIdFormType.className; + select.dataset.displayAllLabel = tpayChannelIdFormType.dataset.displayAllLabel; tpayChannelIdFormType.replaceWith(select); tpayChannelIdFormType = select; } tpayChannelIdFormType.innerHTML = ''; + const displayAllOption = document.createElement('option'); + displayAllOption.value = ''; + console.log(tpayChannelIdFormType.dataset); + displayAllOption.text = tpayChannelIdFormType.dataset.displayAllLabel; + + tpayChannelIdFormType.appendChild(displayAllOption); + for (const [id, name] of Object.entries(channels)) { const option = document.createElement('option'); option.value = id; diff --git a/config/services/pay_by_link_payment/form/type.php b/config/services/pay_by_link_payment/form/type.php index 41645abd..ee5ac4fc 100644 --- a/config/services/pay_by_link_payment/form/type.php +++ b/config/services/pay_by_link_payment/form/type.php @@ -12,6 +12,9 @@ $services = $container->services(); $services->set('commerce_weavers_sylius_tpay.pay_by_link_payment.form.type.gateway_configuration', GatewayConfigurationType::class) + ->args([ + service('translator'), + ]) ->parent('commerce_weavers_sylius_tpay.form.type.abstract_tpay_gateway_configuration') ->tag('sylius.gateway_configuration_type', ['label' => 'commerce_weavers_sylius_tpay.admin.gateway_name.tpay_pbl', 'type' => GatewayFactory::NAME]) ->tag('form.type') diff --git a/src/PayByLinkPayment/Form/Type/GatewayConfigurationType.php b/src/PayByLinkPayment/Form/Type/GatewayConfigurationType.php index 07c99c63..b7d315b5 100644 --- a/src/PayByLinkPayment/Form/Type/GatewayConfigurationType.php +++ b/src/PayByLinkPayment/Form/Type/GatewayConfigurationType.php @@ -4,12 +4,23 @@ namespace CommerceWeavers\SyliusTpayPlugin\PayByLinkPayment\Form\Type; +use CommerceWeavers\SyliusTpayPlugin\Form\EventListener\DecryptGatewayConfigListenerInterface; +use CommerceWeavers\SyliusTpayPlugin\Form\EventListener\EncryptGatewayConfigListenerInterface; use CommerceWeavers\SyliusTpayPlugin\Form\Type\AbstractTpayGatewayConfigurationType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Contracts\Translation\TranslatorInterface; final class GatewayConfigurationType extends AbstractTpayGatewayConfigurationType { + public function __construct( + DecryptGatewayConfigListenerInterface $decryptGatewayConfigListener, + EncryptGatewayConfigListenerInterface $encryptGatewayConfigListener, + private readonly TranslatorInterface $translator, + ) { + parent::__construct($decryptGatewayConfigListener, $encryptGatewayConfigListener); + } + public function buildForm(FormBuilderInterface $builder, array $options): void { parent::buildForm($builder, $options); @@ -23,6 +34,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'commerce_weavers_sylius_tpay.admin.gateway_configuration.tpay_channel_id', 'help' => 'commerce_weavers_sylius_tpay.admin.gateway_configuration.tpay_channel_id_help', 'required' => false, + 'attr' => [ + 'placeholder' => $this->translator->trans('commerce_weavers_sylius_tpay.admin.gateway_configuration.tpay_display_all_channels', domain: 'messages'), + 'data-display-all-label' => $this->translator->trans('commerce_weavers_sylius_tpay.admin.gateway_configuration.tpay_display_all_channels', domain: 'messages'), + ], ], ) ; diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index cb69acea..45c50300 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -17,6 +17,7 @@ commerce_weavers_sylius_tpay: apple_pay_merchant_id: 'Apple Merchant ID' tpay_channel_id: 'Tpay Channel ID' tpay_channel_id_help: 'Click the "Test connection" button to retrieve the list of available channels.' + tpay_display_all_channels: 'Display all channels' production_mode: 'Production mode' merchant_id: 'Merchant ID' notification_security_code: 'Security code (Notification)' diff --git a/translations/messages.pl.yaml b/translations/messages.pl.yaml index 462f8e8a..9840eb52 100644 --- a/translations/messages.pl.yaml +++ b/translations/messages.pl.yaml @@ -17,6 +17,7 @@ commerce_weavers_sylius_tpay: apple_pay_merchant_id: 'Identyfikator sprzedawcy Apple Pay' tpay_channel_id: 'ID kanału Tpay' tpay_channel_id_help: 'Kliknij przycisk "Testuj połączenie", aby pobrać listę dostępnych kanałów.' + tpay_display_all_channels: 'Wyswietl wszystkie kanały' production_mode: 'Tryb produkcyjny' merchant_id: 'Merchant ID' notification_security_code: 'Kod bezpieczeństwa (Powiadomienia)'