Skip to content

Commit 05b2748

Browse files
authored
Merge pull request #6328 from magento-tsg/2.4-develop-pr103
[Arrows] Fixes for 2.4 (pr103) (2.4-develop)
2 parents d4600b9 + 36fbf33 commit 05b2748

File tree

4 files changed

+72
-14
lines changed
  • app/code/Magento
  • dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element
  • lib/internal/Magento/Framework/DB/Adapter/Pdo

4 files changed

+72
-14
lines changed

app/code/Magento/Shipping/view/adminhtml/templates/order/packaging/popup_content.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@
227227
<div class="grid_prepare admin__page-subsection"></div>
228228
</div>
229229
</section>
230-
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag('display:none', '#package_template') ?>
231230
<div id="packages_content"></div>
231+
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag('display:none', '#package_template') ?>
232232
<?php $scriptString = <<<script
233233
require(['jquery'], function($){
234234
$("div#packages_content").on('click', "button[data-action='package-save-items']",

app/code/Magento/Ui/view/base/web/js/form/element/region.js

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ define([
2323
}
2424
},
2525

26+
/**
27+
* {@inheritdoc}
28+
*/
29+
initialize: function () {
30+
var option;
31+
32+
this._super();
33+
34+
option = _.find(this.countryOptions, function (row) {
35+
return row['is_default'] === true;
36+
});
37+
this.hideRegion(option);
38+
39+
return this;
40+
},
41+
2642
/**
2743
* Method called every time country selector's value gets changed.
2844
* Updates all validations and requirements for certain country.
@@ -42,16 +58,9 @@ define([
4258
return;
4359
}
4460

45-
defaultPostCodeResolver.setUseDefaultPostCode(!option['is_zipcode_optional']);
46-
47-
if (option['is_region_visible'] === false) {
48-
// Hide select and corresponding text input field if region must not be shown for selected country.
49-
this.setVisible(false);
61+
this.hideRegion(option);
5062

51-
if (this.customEntry) { // eslint-disable-line max-depth
52-
this.toggleInput(false);
53-
}
54-
}
63+
defaultPostCodeResolver.setUseDefaultPostCode(!option['is_zipcode_optional']);
5564

5665
isRegionRequired = !this.skipValidation && !!option['is_region_required'];
5766

@@ -67,7 +76,24 @@ define([
6776
input.validation['required-entry'] = isRegionRequired;
6877
input.validation['validate-not-number-first'] = !this.options().length;
6978
}.bind(this));
79+
},
80+
81+
/**
82+
* Hide select and corresponding text input field if region must not be shown for selected country.
83+
*
84+
* @private
85+
* @param {Object}option
86+
*/
87+
hideRegion: function (option) {
88+
if (!option || option['is_region_visible'] !== false) {
89+
return;
90+
}
91+
92+
this.setVisible(false);
93+
94+
if (this.customEntry) {
95+
this.toggleInput(false);
96+
}
7097
}
7198
});
7299
});
73-

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/region.test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,40 @@ define([
4747
});
4848
});
4949

50+
describe('initialize method', function () {
51+
it('Hides region field when it should be hidden for default country', function () {
52+
model.countryOptions = {
53+
'DefaultCountryCode': {
54+
'is_default': true,
55+
'is_region_visible': false
56+
},
57+
'NonDefaultCountryCode': {
58+
'is_region_visible': true
59+
}
60+
};
61+
62+
model.initialize();
63+
64+
expect(model.visible()).toEqual(false);
65+
});
66+
67+
it('Shows region field when it should be visible for default country', function () {
68+
model.countryOptions = {
69+
'CountryCode': {
70+
'is_default': true,
71+
'is_region_visible': true
72+
},
73+
'NonDefaultCountryCode': {
74+
'is_region_visible': false
75+
}
76+
};
77+
78+
model.initialize();
79+
80+
expect(model.visible()).toEqual(true);
81+
});
82+
});
83+
5084
describe('update method', function () {
5185
it('makes field optional when there is no corresponding country', function () {
5286
var value = 'Value';

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface
5656
public const DDL_CREATE = 2;
5757
public const DDL_INDEX = 3;
5858
public const DDL_FOREIGN_KEY = 4;
59-
public const DDL_EXISTS = 5;
59+
private const DDL_EXISTS = 5;
6060
public const DDL_CACHE_PREFIX = 'DB_PDO_MYSQL_DDL';
6161
public const DDL_CACHE_TAG = 'DB_PDO_MYSQL_DDL';
6262

@@ -665,11 +665,9 @@ protected function _prepareQuery(&$sql, &$bind = [])
665665
}
666666

667667
// Mixed bind is not supported - so remember whether it is named bind, to normalize later if required
668-
$isNamedBind = false;
669668
if ($bind) {
670669
foreach ($bind as $k => $v) {
671670
if (!is_int($k)) {
672-
$isNamedBind = true;
673671
if ($k[0] != ':') {
674672
$bind[":{$k}"] = $v;
675673
unset($bind[$k]);

0 commit comments

Comments
 (0)