Skip to content
Snippets Groups Projects
Commit cad3b13b authored by Gurzhyi, Andrii's avatar Gurzhyi, Andrii
Browse files

MAGETWO-44098: Enable PayPal Credit dropdown is active when Enable Express...

MAGETWO-44098: Enable PayPal Credit dropdown is active when Enable Express Checkout set to No in PayPal Payflow Link

- Fixed convertor configuration and initialization events
parent 24abff16
Branches
No related merge requests found
Showing
with 133 additions and 86 deletions
...@@ -60,6 +60,7 @@ class Converter implements ConverterInterface ...@@ -60,6 +60,7 @@ class Converter implements ConverterInterface
$result = []; $result = [];
/** @var \DOMElement $child */ /** @var \DOMElement $child */
foreach ($node->childNodes as $child) { foreach ($node->childNodes as $child) {
/** @var \DOMElement $child */
if ($this->hasNodeElement($child)) { if ($this->hasNodeElement($child)) {
$result[$child->getAttribute('name')] = [ $result[$child->getAttribute('name')] = [
'value' => $child->getAttribute('value'), 'value' => $child->getAttribute('value'),
...@@ -80,8 +81,8 @@ class Converter implements ConverterInterface ...@@ -80,8 +81,8 @@ class Converter implements ConverterInterface
protected function createPredicate(\DOMElement $node) protected function createPredicate(\DOMElement $node)
{ {
$result = []; $result = [];
/** @var \DOMElement $child */
foreach ($node->childNodes as $child) { foreach ($node->childNodes as $child) {
/** @var \DOMElement $child */
if ($this->hasNodeElement($child)) { if ($this->hasNodeElement($child)) {
$result = [ $result = [
'name' => $child->getAttribute('name'), 'name' => $child->getAttribute('name'),
...@@ -105,33 +106,18 @@ class Converter implements ConverterInterface ...@@ -105,33 +106,18 @@ class Converter implements ConverterInterface
{ {
$result = []; $result = [];
foreach ($node->childNodes as $child) { foreach ($node->childNodes as $child) {
/** @var \DOMElement $child */
if ($this->hasNodeElement($child)) { if ($this->hasNodeElement($child)) {
$result = array_merge($result, $this->createRule($child)); $result[$child->getAttribute('type')][] = [
'event' => $child->getAttribute('event'),
'argument' => $this->createArgument($child),
];
} }
} }
return [$node->getAttribute('target') => $result]; return [$node->getAttribute('target') => $result];
} }
/**
* Creating rules
*
* @param \DOMElement $node
* @return array
*/
protected function createRule(\DOMElement $node)
{
$result = [];
$type = $node->getAttribute('type');
/** @var \DOMElement $node */
$result[$type] = [
'event' => $node->getAttribute('event'),
];
$result[$type]['argument'] = $this->createArgument($node);
return $result;
}
/** /**
* Create argument * Create argument
* *
...@@ -141,8 +127,8 @@ class Converter implements ConverterInterface ...@@ -141,8 +127,8 @@ class Converter implements ConverterInterface
protected function createArgument(\DOMElement $node) protected function createArgument(\DOMElement $node)
{ {
$result = []; $result = [];
/** @var \DOMElement $child */
foreach ($node->childNodes as $child) { foreach ($node->childNodes as $child) {
/** @var \DOMElement $child */
if ($this->hasNodeElement($child)) { if ($this->hasNodeElement($child)) {
$result[$child->getAttribute('name')] = $child->textContent; $result[$child->getAttribute('name')] = $child->textContent;
} }
......
...@@ -78,22 +78,27 @@ class ConverterTest extends \PHPUnit_Framework_TestCase ...@@ -78,22 +78,27 @@ class ConverterTest extends \PHPUnit_Framework_TestCase
'relations' => [ 'relations' => [
'payment_test_1' => [ 'payment_test_1' => [
'test' => [ 'test' => [
'event' => 'event0', [
'argument' => [], 'event' => 'event0',
'argument' => [],
]
], ],
], ],
'payment_test_2' => [ 'payment_test_2' => [
'test' => [ 'test' => [
'event' => 'event1', [
'argument' => [ 'event' => 'event1',
], 'argument' => [],
]
], ],
'test-two' => [ 'test-two' => [
'event' => 'event1', [
'argument' => [ 'event' => 'event1',
'argument1' => 'argument1', 'argument' => [
'argument2' => 'argument2', 'argument1' => 'argument1',
], 'argument2' => 'argument2',
],
]
], ],
], ],
], ],
...@@ -122,21 +127,34 @@ class ConverterTest extends \PHPUnit_Framework_TestCase ...@@ -122,21 +127,34 @@ class ConverterTest extends \PHPUnit_Framework_TestCase
'relations' => [ 'relations' => [
'payment_test_1' => [ 'payment_test_1' => [
'test' => [ 'test' => [
'event' => 'event0', [
'argument' => [], 'event' => 'event0',
'argument' => [],
]
], ],
], ],
'payment_test_2' => [ 'payment_test_2' => [
'test' => [ 'test' => [
'event' => 'event1', [
'argument' => [], 'event' => 'event1',
'argument' => [],
]
], ],
'test-two' => [ 'test-two' => [
'event' => 'event1', [
'argument' => [ 'event' => 'event1',
'argument1' => 'argument1', 'argument' => [
'argument2' => 'argument2', 'argument1' => 'argument1',
'argument2' => 'argument2',
],
], ],
[
'event' => 'event2',
'argument' => [
'argument1' => 'argument1',
'argument2' => 'argument2',
],
]
], ],
], ],
], ],
......
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
<argument name="argument1">argument1</argument> <argument name="argument1">argument1</argument>
<argument name="argument2">argument2</argument> <argument name="argument2">argument2</argument>
</rule> </rule>
<rule type="test-two" event="event2">
<argument name="argument1">argument1</argument>
<argument name="argument2">argument2</argument>
</rule>
</relation> </relation>
</payment> </payment>
</rules> </rules>
...@@ -329,7 +329,10 @@ ...@@ -329,7 +329,10 @@
<argument name="wpp_usuk">wpp_usuk</argument> <argument name="wpp_usuk">wpp_usuk</argument>
<argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument>
</rule> </rule>
<rule type="payflow/bml/disable-conditional-express" event="deactivate-express"/> <rule type="payflow/bml/disable-conditional-express" event="deactivate-express"/>
<rule type="payflow/bml/disable-conditional-express" event=":load"/>
<rule type="payflow/bml/enable" event="activate-express"/> <rule type="payflow/bml/enable" event="activate-express"/>
<rule type="payflow/express/lock-conditional" event=":load"/> <rule type="payflow/express/lock-conditional" event=":load"/>
<rule type="payflow/bml/lock-conditional" event=":load"/> <rule type="payflow/bml/lock-conditional" event=":load"/>
......
...@@ -2,25 +2,28 @@ ...@@ -2,25 +2,28 @@
* Copyright © 2015 Magento. All rights reserved. * Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
define([], function () { define(['underscore'], function (_) {
"use strict"; 'use strict';
return function (solution, message, argument) { return function (solution, message, argument) {
var isConfirm = false; var isConfirm = false;
_.every(argument, function (name) { _.every(argument, function (name) {
if (solution.solutionsElements[name] if (solution.solutionsElements[name] &&
&& solution.solutionsElements[name].find(solution.enableButton).val() == 1 solution.solutionsElements[name].find(solution.enableButton).val() == 1
) { ) {
isConfirm = true; isConfirm = true;
return !isConfirm; return !isConfirm;
} }
return !isConfirm; return !isConfirm;
}, this); }, this);
if (isConfirm) { if (isConfirm) {
return confirm(message); return confirm(message);
} else {
return true;
} }
return true;
}; };
}); });
...@@ -3,18 +3,24 @@ ...@@ -3,18 +3,24 @@
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
define([ define([
"uiClass", 'uiClass'
"underscore" ], function (Class) {
], function (Class, _) { 'use strict';
"use strict";
return Class.extend({ return Class.extend({
/** /**
* Constructor * Constructor
*
* @param {Object} config
* @returns {exports.initialize}
*/ */
initialize: function (config) { initialize: function (config) {
this.initConfig(config); this.initConfig(config);
return this; return this;
}, },
/** /**
* To apply the rule * To apply the rule
*/ */
......
...@@ -2,32 +2,42 @@ ...@@ -2,32 +2,42 @@
* Copyright © 2015 Magento. All rights reserved. * Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
(function() { (function () {
'use strict';
var executed = false; var executed = false;
define([ define([
'Magento_Ui/js/modal/alert' 'Magento_Ui/js/modal/alert',
], function (alert) { 'underscore'
"use strict"; ], function (alert, _) {
return function ($target, $owner, data) { return function ($target, $owner, data) {
if ($owner.find(data.enableButton).val() == 1) {
var isDisabled = true;
var isDisabled = true,
newLine = String.fromCharCode(10, 13);
if ($owner.find(data.enableButton).val() === '1') {
_.every(data.argument, function (name) { _.every(data.argument, function (name) {
if (data.solutionsElements[name] if (data.solutionsElements[name] &&
&& data.solutionsElements[name].find(data.enableButton).val() == 1 data.solutionsElements[name].find(data.enableButton).val() === '1'
) { ) {
isDisabled = false; isDisabled = false;
return isDisabled; return isDisabled;
} }
return isDisabled; return isDisabled;
}, this); }, this);
if (!isDisabled && !executed) { if (!isDisabled && !executed) {
executed = true; executed = true;
alert({ alert({
content: "The following error(s) occured:\n\r" content: 'The following error(s) occurred:\n\r' +
+"Some PayPal solutions conflict.\n\r" newLine +
+"Please re-enable the previously enabled payment solutions." 'Some PayPal solutions conflict.' +
newLine +
'Please re-enable the previously enabled payment solutions.'
}); });
} }
} }
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
define([ define([
'Magento_Paypal/js/rules/simple/disable' 'Magento_Paypal/js/rules/simple/disable'
], function (disable) { ], function (disable) {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
disable($target, $owner, data); disable($target, $owner, data);
$target.find(data.enableButton).change(); $target.find(data.enableButton).change();
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
define([ define([
'Magento_Paypal/js/rules/payflow/bml/disable' 'Magento_Paypal/js/rules/payflow/bml/disable'
], function (disable) { ], function (disable) {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
if ($target.find(data.enableExpress).val() == "0") { if ($target.find(data.enableExpress).val() === '0') {
disable($target, $owner, data); disable($target, $owner, data);
} }
}; };
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
define([ define([
'Magento_Paypal/js/rules/payflow/bml/disable' 'Magento_Paypal/js/rules/payflow/bml/disable'
], function (disable) { ], function (disable) {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
if ($target.find(data.enableButton).val() == "0") { if ($target.find(data.enableButton).val() === '0') {
disable($target, $owner, data); disable($target, $owner, data);
} }
}; };
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
define([], function () { define([], function () {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
$target.find('label[for="' + $target.find(data.enableBml).attr('id') + '"]').removeClass('enabled'); $target.find('label[for="' + $target.find(data.enableBml).attr('id') + '"]').removeClass('enabled');
$target.find(data.enableBml + ' option[value="0"]').prop('selected', true); $target.find(data.enableBml + ' option[value="0"]').prop('selected', true);
......
...@@ -2,18 +2,21 @@ ...@@ -2,18 +2,21 @@
* Copyright © 2015 Magento. All rights reserved. * Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
define([], function () { define(['underscore'], function (_) {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
var isDisabled = true; var isDisabled = true;
_.every(data.argument, function (name) { _.every(data.argument, function (name) {
if (data.solutionsElements[name] if (data.solutionsElements[name] &&
&& data.solutionsElements[name].find(data.enableButton).val() == 1 data.solutionsElements[name].find(data.enableButton).val() == 1
) { ) {
isDisabled = false; isDisabled = false;
return isDisabled; return isDisabled;
} }
return isDisabled; return isDisabled;
}, this); }, this);
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
define([], function () { define([], function () {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
$target.find(data.enableBml).prop('disabled', false); $target.find(data.enableBml).prop('disabled', false);
$target.find(data.enableBml + ' option[value="1"]').prop('selected', true); $target.find(data.enableBml + ' option[value="1"]').prop('selected', true);
......
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
define([], function () { define([], function () {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
if ($target.find(data.enableButton).val() == "0") { if ($target.find(data.enableButton).val() === '0') {
$target.find(data.enableBml).prop('disabled', true); $target.find(data.enableBml).prop('disabled', true);
} }
}; };
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
define([ define([
'Magento_Paypal/js/rules/payflow/express/disable' 'Magento_Paypal/js/rules/payflow/express/disable'
], function (disableExpress) { ], function (disableExpress) {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
if ($target.find(data.enableButton).val() == "0") { if ($target.find(data.enableButton).val() === '0') {
disableExpress($target, $owner, data); disableExpress($target, $owner, data);
$target.find(data.enableExpress).change(); $target.find(data.enableExpress).change();
} }
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
define([], function () { define([], function () {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
$target.find('label[for="' + $target.find(data.enableExpress).attr('id') + '"]').removeClass('enabled'); $target.find('label[for="' + $target.find(data.enableExpress).attr('id') + '"]').removeClass('enabled');
$target.find(data.enableExpress + ' option[value="0"]').prop('selected', true); $target.find(data.enableExpress + ' option[value="0"]').prop('selected', true);
......
...@@ -2,18 +2,21 @@ ...@@ -2,18 +2,21 @@
* Copyright © 2015 Magento. All rights reserved. * Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
define([], function () { define(['underscore'], function (_) {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
var isDisabled = true; var isDisabled = true;
_.every(data.argument, function (name) { _.every(data.argument, function (name) {
if (data.solutionsElements[name] if (data.solutionsElements[name] &&
&& data.solutionsElements[name].find(data.enableButton).val() == 1 data.solutionsElements[name].find(data.enableButton).val() === '1'
) { ) {
isDisabled = false; isDisabled = false;
return isDisabled; return isDisabled;
} }
return isDisabled; return isDisabled;
}, this); }, this);
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
define([], function () { define([], function () {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
$target.find(data.enableExpress).prop('disabled', false); $target.find(data.enableExpress).prop('disabled', false);
$target.find(data.enableExpress + ' option[value="1"]').prop('selected', true); $target.find(data.enableExpress + ' option[value="1"]').prop('selected', true);
......
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
define([], function () { define([], function () {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
if ($target.find(data.enableButton).val() == "0") { if ($target.find(data.enableButton).val() === '0') {
$target.find(data.enableExpress).prop('disabled', true); $target.find(data.enableExpress).prop('disabled', true);
} }
}; };
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
define([ define([
'Magento_Paypal/js/rules/paypal/bml/disable' 'Magento_Paypal/js/rules/paypal/bml/disable'
], function (disable) { ], function (disable) {
"use strict"; 'use strict';
return function ($target, $owner, data) { return function ($target, $owner, data) {
if ($target.find(data.enableButton).val() == "0") { if ($target.find(data.enableButton).val() === '0') {
disable($target, $owner, data); disable($target, $owner, data);
} }
}; };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment