Skip to content

Commit

Permalink
Merge pull request #15 from AdelanteFinancialHoldings/wolf_validation…
Browse files Browse the repository at this point in the history
…_fix

Class and validation fix. Display of plug-in settings in the Adobe da…
  • Loading branch information
arsanchez-addi committed May 27, 2022
2 parents b45779c + 07a8250 commit 11e8b22
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 58 deletions.
78 changes: 21 additions & 57 deletions Block/Adminhtml/System/Config/Fieldset/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,34 @@
use Magento\Config\Model\Config;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\Js;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

class Payment extends Fieldset
{
/**
* @var Config
*/
protected $_config;
private $config;

/**
* @var SecureHtmlRenderer
*/
private $secureRenderer;

/**
* @param Context $context
* @param Session $authSession
* @param Js $jsHelper
* @param Config $config
* @param SecureHtmlRenderer $secureRenderer
* @param array $data
*/
public function __construct(
Context $context,
Session $authSession,
Js $jsHelper,
Config $config,
SecureHtmlRenderer $secureRenderer,
array $data = array()
) {
parent::__construct(
Expand All @@ -36,7 +44,9 @@ public function __construct(
$jsHelper,
$data
);
$this->_config = $config;

$this->config = $config;
$this->secureRenderer = $secureRenderer;
}

/**
Expand All @@ -59,43 +69,22 @@ protected function _getFrontendClass($element)
protected function _getHeaderTitleHtml($element)
{
$html = '<div class="config-heading" >';

$groupConfig = $element->getGroup();

$disabledAttributeString = $this->_isPaymentEnabled($element) ? '' : ' disabled="disabled"';
$disabledClassString = $this->_isPaymentEnabled($element) ? '' : ' disabled';
$htmlId = $element->getHtmlId();
$html .= '<div class="button-container"><button type="button"' .
$disabledAttributeString .
' class="button action-configure' .
(empty($groupConfig['paypal_ec_separate']) ? '' : ' paypal-ec-separate') .
$disabledClassString .
'" id="' .
$htmlId .
'-head" onclick="paypalToggleSolution.call(this, \'' .
$htmlId .
"', '" .
$this->getUrl(
'adminhtml/*/state'
) . '\'); return false;"><span class="state-closed">' . __(
'" id="' . $htmlId . '-head" >' .
'<span class="state-closed">' . __(
'Configure'
) . '</span><span class="state-opened">' . __(
'Close'
) . '</span></button>';

if (!empty($groupConfig['more_url'])) {
$html .= '<a class="link-more" href="' . $groupConfig['more_url'] . '" target="_blank">'
. __(
'Learn More'
) . '</a>';
}

if (!empty($groupConfig['demo_url'])) {
$html .= '<a class="link-demo" href="' . $groupConfig['demo_url'] . '" target="_blank">'
. __(
'View Demo'
) . '</a>';
}
$html .= /* @noEscape */ $this->secureRenderer->renderEventListenerAsTag(
'onclick',
"addiToggleSolution.call(this, '" . $htmlId . "', '" . $this->getUrl('adminhtml/*/state') .
"');event.preventDefault();",
'button#' . $htmlId . '-head'
);

$html .= '</div>';
$html .= '<div class="heading"><strong>' . $element->getLegend() . '</strong>';
Expand Down Expand Up @@ -143,9 +132,8 @@ protected function _isCollapseState($element)
*/
protected function _getExtraJs($element)
{
$element = '';
$script = "require(['jquery', 'prototype'], function(jQuery){
window.AddiToggleSolution = function (id, url) {
window.addiToggleSolution = function (id, url) {
var doScroll = false;
Fieldset.toggleCollapse(id, url);
if ($(this).hasClassName(\"open\")) {
Expand All @@ -165,28 +153,4 @@ protected function _getExtraJs($element)

return $this->_jsHelper->getScript($script);
}

/**
* Check whether current payment method is enabled
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return bool
*/
protected function _isPaymentEnabled($element)
{
$groupConfig = $element->getGroup();
$activityPaths = isset($groupConfig['activity_path']) ? $groupConfig['activity_path'] : array();

if (!is_array($activityPaths)) {
$activityPaths = array($activityPaths);
}

$isPaymentEnabled = false;
foreach ($activityPaths as $activityPath) {
$isPaymentEnabled = $isPaymentEnabled
|| (bool)(string)$this->_backendConfig->getConfigDataValue($activityPath);
}

return $isPaymentEnabled;
}
}
Empty file modified Model/Source/Countries.php
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Magento 2 Payment Module",
"type": "magento2-module",
"license": "proprietary",
"version": "1.0.10",
"version": "1.0.11",
"minimum-stability": "stable",
"prefer-stable": true,
"autoload": {
Expand Down
Empty file modified etc/config.xml
100755 → 100644
Empty file.
Empty file modified etc/db_schema.xml
100755 → 100644
Empty file.
Empty file modified etc/frontend/di.xml
100755 → 100644
Empty file.
Empty file modified etc/frontend/routes.xml
100755 → 100644
Empty file.
Empty file modified etc/module.xml
100755 → 100644
Empty file.
Empty file modified etc/payment.xml
100755 → 100644
Empty file.
Empty file modified view/adminhtml/layout/sales_order_view.xml
100755 → 100644
Empty file.
Empty file modified view/adminhtml/ui_component/sales_order_grid.xml
100755 → 100644
Empty file.
Empty file modified view/adminhtml/web/images/addi-logo.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified view/frontend/layout/catalog_product_view.xml
100755 → 100644
Empty file.
Empty file modified view/frontend/requirejs-config.js
100755 → 100644
Empty file.
Empty file modified view/frontend/web/images/addi-logo.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified view/frontend/web/js/validationNumber.js
100755 → 100644
Empty file.
Empty file modified view/frontend/web/js/view/payment/addi.js
100755 → 100644
Empty file.

0 comments on commit 11e8b22

Please sign in to comment.