Skip to content

Commit c7144cd

Browse files
author
Ievgen Sentiabov
committed
Merge branch 'MAGETWO-44098' into MAGETWO-44446
2 parents 48c6305 + 32d81c2 commit c7144cd

31 files changed

+298
-153
lines changed

app/code/Magento/Paypal/Model/Config/Rules/Converter.php

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public function convert($source)
5858
protected function createEvents(\DOMElement $node)
5959
{
6060
$result = [];
61-
/** @var \DOMElement $child */
6261
foreach ($node->childNodes as $child) {
62+
/** @var \DOMElement $child */
6363
if ($this->hasNodeElement($child)) {
6464
$result[$child->getAttribute('name')] = [
6565
'value' => $child->getAttribute('value'),
@@ -80,8 +80,8 @@ protected function createEvents(\DOMElement $node)
8080
protected function createPredicate(\DOMElement $node)
8181
{
8282
$result = [];
83-
/** @var \DOMElement $child */
8483
foreach ($node->childNodes as $child) {
84+
/** @var \DOMElement $child */
8585
if ($this->hasNodeElement($child)) {
8686
$result = [
8787
'name' => $child->getAttribute('name'),
@@ -105,33 +105,18 @@ protected function createRelation(\DOMElement $node)
105105
{
106106
$result = [];
107107
foreach ($node->childNodes as $child) {
108+
/** @var \DOMElement $child */
108109
if ($this->hasNodeElement($child)) {
109-
$result = array_merge($result, $this->createRule($child));
110+
$result[$child->getAttribute('type')][] = [
111+
'event' => $child->getAttribute('event'),
112+
'argument' => $this->createArgument($child),
113+
];
110114
}
111115
}
112116

113117
return [$node->getAttribute('target') => $result];
114118
}
115119

116-
/**
117-
* Creating rules
118-
*
119-
* @param \DOMElement $node
120-
* @return array
121-
*/
122-
protected function createRule(\DOMElement $node)
123-
{
124-
$result = [];
125-
$type = $node->getAttribute('type');
126-
/** @var \DOMElement $node */
127-
$result[$type] = [
128-
'event' => $node->getAttribute('event'),
129-
];
130-
$result[$type]['argument'] = $this->createArgument($node);
131-
132-
return $result;
133-
}
134-
135120
/**
136121
* Create argument
137122
*
@@ -141,8 +126,8 @@ protected function createRule(\DOMElement $node)
141126
protected function createArgument(\DOMElement $node)
142127
{
143128
$result = [];
144-
/** @var \DOMElement $child */
145129
foreach ($node->childNodes as $child) {
130+
/** @var \DOMElement $child */
146131
if ($this->hasNodeElement($child)) {
147132
$result[$child->getAttribute('name')] = $child->textContent;
148133
}

app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/ConverterTest.php

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,27 @@ public function dataProviderExpectedData()
7878
'relations' => [
7979
'payment_test_1' => [
8080
'test' => [
81-
'event' => 'event0',
82-
'argument' => [],
81+
[
82+
'event' => 'event0',
83+
'argument' => [],
84+
]
8385
],
8486
],
8587
'payment_test_2' => [
8688
'test' => [
87-
'event' => 'event1',
88-
'argument' => [
89-
],
89+
[
90+
'event' => 'event1',
91+
'argument' => [],
92+
]
9093
],
9194
'test-two' => [
92-
'event' => 'event1',
93-
'argument' => [
94-
'argument1' => 'argument1',
95-
'argument2' => 'argument2',
96-
],
95+
[
96+
'event' => 'event1',
97+
'argument' => [
98+
'argument1' => 'argument1',
99+
'argument2' => 'argument2',
100+
],
101+
]
97102
],
98103
],
99104
],
@@ -122,21 +127,34 @@ public function dataProviderExpectedData()
122127
'relations' => [
123128
'payment_test_1' => [
124129
'test' => [
125-
'event' => 'event0',
126-
'argument' => [],
130+
[
131+
'event' => 'event0',
132+
'argument' => [],
133+
]
127134
],
128135
],
129136
'payment_test_2' => [
130137
'test' => [
131-
'event' => 'event1',
132-
'argument' => [],
138+
[
139+
'event' => 'event1',
140+
'argument' => [],
141+
]
133142
],
134143
'test-two' => [
135-
'event' => 'event1',
136-
'argument' => [
137-
'argument1' => 'argument1',
138-
'argument2' => 'argument2',
144+
[
145+
'event' => 'event1',
146+
'argument' => [
147+
'argument1' => 'argument1',
148+
'argument2' => 'argument2',
149+
],
139150
],
151+
[
152+
'event' => 'event2',
153+
'argument' => [
154+
'argument1' => 'argument1',
155+
'argument2' => 'argument2',
156+
],
157+
]
140158
],
141159
],
142160
],

app/code/Magento/Paypal/Test/Unit/Model/Config/Rules/ConvertibleContent/rules.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
<argument name="argument1">argument1</argument>
5353
<argument name="argument2">argument2</argument>
5454
</rule>
55+
<rule type="test-two" event="event2">
56+
<argument name="argument1">argument1</argument>
57+
<argument name="argument2">argument2</argument>
58+
</rule>
5559
</relation>
5660
</payment>
5761
</rules>

app/code/Magento/Paypal/etc/adminhtml/rules/payment_us.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,10 @@
329329
<argument name="wpp_usuk">wpp_usuk</argument>
330330
<argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument>
331331
</rule>
332+
332333
<rule type="payflow/bml/disable-conditional-express" event="deactivate-express"/>
334+
<rule type="payflow/bml/disable-conditional-express" event=":load"/>
335+
333336
<rule type="payflow/bml/enable" event="activate-express"/>
334337
<rule type="payflow/express/lock-conditional" event=":load"/>
335338
<rule type="payflow/bml/lock-conditional" event=":load"/>

app/code/Magento/Paypal/view/adminhtml/web/js/predicate/confirm.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@
22
* Copyright © 2015 Magento. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5-
define([], function () {
6-
"use strict";
5+
define(['underscore'], function (_) {
6+
'use strict';
7+
78
return function (solution, message, argument) {
89
var isConfirm = false;
910

1011
_.every(argument, function (name) {
11-
if (solution.solutionsElements[name]
12-
&& solution.solutionsElements[name].find(solution.enableButton).val() == 1
12+
if (solution.solutionsElements[name] &&
13+
solution.solutionsElements[name].find(solution.enableButton).val() == 1
1314
) {
1415
isConfirm = true;
16+
1517
return !isConfirm;
1618
}
19+
1720
return !isConfirm;
1821
}, this);
1922

2023
if (isConfirm) {
2124
return confirm(message);
22-
} else {
23-
return true;
2425
}
26+
27+
return true;
2528
};
2629
});

app/code/Magento/Paypal/view/adminhtml/web/js/rule.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@
33
* See COPYING.txt for license details.
44
*/
55
define([
6-
"uiClass",
7-
"underscore"
8-
], function (Class, _) {
9-
"use strict";
6+
'uiClass'
7+
], function (Class) {
8+
'use strict';
9+
1010
return Class.extend({
11+
1112
/**
1213
* Constructor
14+
*
15+
* @param {Object} config
16+
* @returns {exports.initialize}
1317
*/
1418
initialize: function (config) {
1519
this.initConfig(config);
20+
1621
return this;
1722
},
23+
1824
/**
1925
* To apply the rule
2026
*/

app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,42 @@
22
* Copyright © 2015 Magento. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5-
(function() {
5+
(function () {
6+
'use strict';
7+
68
var executed = false;
9+
710
define([
8-
'Magento_Ui/js/modal/alert'
9-
], function (alert) {
10-
"use strict";
11+
'Magento_Ui/js/modal/alert',
12+
'underscore'
13+
], function (alert, _) {
14+
1115
return function ($target, $owner, data) {
12-
if ($owner.find(data.enableButton).val() == 1) {
13-
var isDisabled = true;
1416

17+
var isDisabled = true,
18+
newLine = String.fromCharCode(10, 13);
19+
20+
if ($owner.find(data.enableButton).val() === '1') {
1521
_.every(data.argument, function (name) {
16-
if (data.solutionsElements[name]
17-
&& data.solutionsElements[name].find(data.enableButton).val() == 1
22+
if (data.solutionsElements[name] &&
23+
data.solutionsElements[name].find(data.enableButton).val() === '1'
1824
) {
1925
isDisabled = false;
26+
2027
return isDisabled;
2128
}
29+
2230
return isDisabled;
2331
}, this);
2432

2533
if (!isDisabled && !executed) {
2634
executed = true;
2735
alert({
28-
content: "The following error(s) occured:\n\r"
29-
+"Some PayPal solutions conflict.\n\r"
30-
+"Please re-enable the previously enabled payment solutions."
36+
content: 'The following error(s) occurred:' +
37+
newLine +
38+
'Some PayPal solutions conflict.' +
39+
newLine +
40+
'Please re-enable the previously enabled payment solutions.'
3141
});
3242
}
3343
}

app/code/Magento/Paypal/view/adminhtml/web/js/rules/disable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
define([
66
'Magento_Paypal/js/rules/simple/disable'
77
], function (disable) {
8-
"use strict";
8+
'use strict';
9+
910
return function ($target, $owner, data) {
1011
disable($target, $owner, data);
1112
$target.find(data.enableButton).change();

app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional-express.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
define([
66
'Magento_Paypal/js/rules/payflow/bml/disable'
77
], function (disable) {
8-
"use strict";
8+
'use strict';
9+
910
return function ($target, $owner, data) {
10-
if ($target.find(data.enableExpress).val() == "0") {
11+
if ($target.find(data.enableExpress).val() === '0') {
1112
disable($target, $owner, data);
1213
}
1314
};

app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
define([
66
'Magento_Paypal/js/rules/payflow/bml/disable'
77
], function (disable) {
8-
"use strict";
8+
'use strict';
9+
910
return function ($target, $owner, data) {
10-
if ($target.find(data.enableButton).val() == "0") {
11+
if ($target.find(data.enableButton).val() === '0') {
1112
disable($target, $owner, data);
1213
}
1314
};

0 commit comments

Comments
 (0)