Skip to content

Commit 79d8e9a

Browse files
authored
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #12945: Naming collision in Javascript ui registry (backend) to 2.2 (by @VladimirZaets) - #12902: Fix #12900: Braintree "Place Order" button is disabled after failed validation (by @joni-jones) - #12755: #12294: Bug: Adding Custom Attribute - The value of A… (by @virtual97) Fixed GitHub Issues: - #12555: Naming collision in Javascript ui registry (backend) (reported by @EliasZ) has been fixed in #12945 by @VladimirZaets in 2.2-develop branch Related commits: 1. 64a1689 - #12900: Braintree "Place Order" button is disabled after failed validation (reported by @ifekaj) has been fixed in #12902 by @joni-jones in 2.2-develop branch Related commits: 1. 0c5cb6a - #12294: Bug: Adding Custom Attribute - The value of Admin scope can't be empty (reported by @webscot) has been fixed in #12755 by @virtual97 in 2.2-develop branch Related commits: 1. 2ccb374 2. 288d0d4 3. e78ea61
2 parents 7d47591 + 79c6a80 commit 79d8e9a

File tree

5 files changed

+38
-12
lines changed
  • app/code/Magento
  • dev/tests/js/jasmine/tests/app/code/Magento/Braintree/frontend/js/view/payment/method-renderer

5 files changed

+38
-12
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ define(
7979
*/
8080
onError: function (response) {
8181
braintree.showError($t('Payment ' + this.getTitle() + ' can\'t be initialized'));
82+
this.isPlaceOrderActionAllowed(true);
8283
throw response.message;
8384
},
8485

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/options.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ $stores = $block->getStoresSortedBySortOrder();
5757
<input type="hidden" id="option-count-check" value="" />
5858
</div>
5959
<script id="row-template" type="text/x-magento-template">
60-
<tr>
60+
<tr <% if (data.rowClasses) { %>class="<%- data.rowClasses %>"<% } %>>
6161
<td class="col-draggable">
6262
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()): ?>
6363
<div data-role="draggable-handle" class="draggable-handle"

app/code/Magento/Catalog/view/adminhtml/web/js/options.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ define([
2424
totalItems: 0,
2525
rendered: 0,
2626
template: mageTemplate('#row-template'),
27+
newOptionClass: 'new-option',
2728
isReadOnly: config.isReadOnly,
2829
add: function (data, render) {
2930
var isNewOption = false,
@@ -32,7 +33,8 @@ define([
3233
if (typeof data.id == 'undefined') {
3334
data = {
3435
'id': 'option_' + this.itemCount,
35-
'sort_order': this.itemCount + 1
36+
'sort_order': this.itemCount + 1,
37+
'rowClasses': this.newOptionClass
3638
};
3739
isNewOption = true;
3840
}
@@ -84,6 +86,10 @@ define([
8486
this.totalItems--;
8587
this.updateItemsCountField();
8688
}
89+
90+
if (element.hasClassName(this.newOptionClass)) {
91+
element.remove();
92+
}
8793
},
8894
updateItemsCountField: function () {
8995
$('option-count-check').value = this.totalItems > 0 ? '1' : '';

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,12 @@ define([
357357
var element;
358358

359359
_.each(this.disabledAttributes, function (attribute) {
360-
registry.get('index = ' + attribute).disabled(false);
360+
registry.get('code = ' + attribute, 'index = ' + attribute).disabled(false);
361361
});
362362
this.disabledAttributes = [];
363363

364364
_.each(attributes, function (attribute) {
365-
element = registry.get('index = ' + attribute.code);
365+
element = registry.get('code = ' + attribute.code, 'index = ' + attribute.code);
366366

367367
if (!_.isUndefined(element)) {
368368
element.disabled(true);

dev/tests/js/jasmine/tests/app/code/Magento/Braintree/frontend/js/view/payment/method-renderer/cc-form.test.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ define([
2727
),
2828
'Magento_Braintree/js/view/payment/adapter': jasmine.createSpyObj(
2929
'adapter',
30-
['setup', 'setConfig']
30+
['setup', 'setConfig', 'showError']
3131
)
3232
},
3333
braintreeCcForm;
@@ -43,14 +43,17 @@ define([
4343
};
4444
injector.mock(mocks);
4545
injector.require(['Magento_Braintree/js/view/payment/method-renderer/cc-form'], function (Constr) {
46-
braintreeCcForm = new Constr({
47-
provider: 'provName',
48-
name: 'test',
49-
index: 'test'
50-
});
51-
52-
done();
46+
braintreeCcForm = new Constr({
47+
provider: 'provName',
48+
name: 'test',
49+
index: 'test',
50+
item: {
51+
title: 'Braintree'
52+
}
5353
});
54+
55+
done();
56+
});
5457
});
5558

5659
it('Check if payment code and message container are restored after onActiveChange call.', function () {
@@ -65,5 +68,21 @@ define([
6568
expect(braintreeCcForm.getCode()).toEqual(expectedCode);
6669
expect(braintreeCcForm.messageContainer).toEqual(expectedMessageContainer);
6770
});
71+
72+
it('Check if form validation fails when "Place Order" button should be active.', function () {
73+
var errorMessage = 'Something went wrong.',
74+
75+
/**
76+
* Anonymous wrapper
77+
*/
78+
func = function () {
79+
braintreeCcForm.clientConfig.onError({
80+
'message': errorMessage
81+
});
82+
};
83+
84+
expect(func).toThrow(errorMessage);
85+
expect(braintreeCcForm.isPlaceOrderActionAllowed()).toBeTruthy();
86+
});
6887
});
6988
});

0 commit comments

Comments
 (0)