Skip to content

Commit 40edf5c

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.3-develop
Accepted Community Pull Requests: - #25720: [Customer] Cover Customer Navigation Block by Unit Test (by @edenduong) - #25533: Telephone Widget > Template > Removing this and helper (by @rafaelstz) - #25611: Added keyboard navigation for Adobe Stock image previews (by @drpayyne) - #25671: Added 'clearEvent' to eventBus to prevent multiple attach event on wysiwyg editor (by @Nazar65) - #25648: Resolve Wrong Css at "Minimum Qty Allowed in Shopping Cart" on Google Chrome issue25647 (by @edenduong) - #25328: Correct spelling (by @ravi-chandra3197) Fixed GitHub Issues: - #691: Readonly inputs and after element html in the backend (reported by @tzyganu) has been fixed in #25611 by @drpayyne in 2.3-develop branch Related commits: 1. 0e30366 2. 1298766 3. 41c95a2 - #25647: Wrong Css at "Minimum Qty Allowed in Shopping Cart" on Google Chrome (reported by @edenduong) has been fixed in #25648 by @edenduong in 2.3-develop branch Related commits: 1. 34998b6 2. 20fd591 3. 0a4393c
2 parents e3e85a1 + 067d0af commit 40edf5c

File tree

10 files changed

+207
-23
lines changed

10 files changed

+207
-23
lines changed

app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected function _getGroupRenderer()
3737
'',
3838
['data' => ['is_render_to_js_template' => true]]
3939
);
40-
$this->_groupRenderer->setClass('customer_group_select');
40+
$this->_groupRenderer->setClass('customer_group_select admin__control-select');
4141
}
4242
return $this->_groupRenderer;
4343
}
@@ -57,7 +57,7 @@ protected function _prepareToRender()
5757
'min_sale_qty',
5858
[
5959
'label' => __('Minimum Qty'),
60-
'class' => 'required-entry validate-number validate-greater-than-zero'
60+
'class' => 'required-entry validate-number validate-greater-than-zero admin__control-text'
6161
]
6262
);
6363
$this->_addAfter = false;
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Customer\Test\Unit\Block\Account;
9+
10+
use PHPUnit\Framework\TestCase;
11+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
12+
use Magento\Customer\Block\Account\Navigation;
13+
use Magento\Framework\View\Element\Template\Context;
14+
use Magento\Framework\View\LayoutInterface;
15+
use Magento\Wishlist\Block\Link as WishListLink;
16+
use Magento\Customer\Block\Account\Link as CustomerAccountLink;
17+
18+
class NavigationTest extends TestCase
19+
{
20+
/**
21+
* @var ObjectManagerHelper
22+
*/
23+
private $objectManagerHelper;
24+
25+
/**
26+
* @var Navigation
27+
*/
28+
private $navigation;
29+
30+
/**
31+
* @var Context|\PHPUnit_Framework_MockObject_MockObject
32+
*/
33+
private $contextMock;
34+
35+
/**
36+
* @var LayoutInterface|\PHPUnit_Framework_MockObject_MockObject
37+
*/
38+
private $layoutMock;
39+
40+
/**
41+
* Setup environment for test
42+
*/
43+
protected function setUp()
44+
{
45+
$this->contextMock = $this->createMock(Context::class);
46+
$this->layoutMock = $this->createMock(LayoutInterface::class);
47+
$this->contextMock->expects($this->any())
48+
->method('getLayout')
49+
->willReturn($this->layoutMock);
50+
$this->objectManagerHelper = new ObjectManagerHelper($this);
51+
$this->navigation = $this->objectManagerHelper->getObject(
52+
Navigation::class,
53+
[
54+
'context' => $this->contextMock
55+
]
56+
);
57+
}
58+
59+
/**
60+
* Test get links with block customer account link and wish list link
61+
*
62+
* @return void
63+
*/
64+
public function testGetLinksWithCustomerAndWishList()
65+
{
66+
$wishListLinkMock = $this->getMockBuilder(WishListLink::class)
67+
->disableOriginalConstructor()
68+
->setMethods(['getSortOrder'])
69+
->getMock();
70+
71+
$customerAccountLinkMock = $this->getMockBuilder(CustomerAccountLink::class)
72+
->disableOriginalConstructor()
73+
->setMethods(['getSortOrder'])
74+
->getMock();
75+
76+
$wishListLinkMock->expects($this->any())
77+
->method('getSortOrder')
78+
->willReturn(100);
79+
80+
$customerAccountLinkMock->expects($this->any())
81+
->method('getSortOrder')
82+
->willReturn(20);
83+
84+
$nameInLayout = 'top.links';
85+
86+
$blockChildren = [
87+
'wishListLink' => $wishListLinkMock,
88+
'customerAccountLink' => $customerAccountLinkMock
89+
];
90+
91+
$this->navigation->setNameInLayout($nameInLayout);
92+
$this->layoutMock->expects($this->any())
93+
->method('getChildBlocks')
94+
->with($nameInLayout)
95+
->willReturn($blockChildren);
96+
97+
/* Assertion */
98+
$this->assertEquals(
99+
[
100+
0 => $wishListLinkMock,
101+
1 => $customerAccountLinkMock
102+
],
103+
$this->navigation->getLinks()
104+
);
105+
}
106+
}

app/code/Magento/Customer/view/frontend/templates/widget/telephone.phtml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@
1414
</span>
1515
</label>
1616
<div class="control">
17-
<?php
18-
$_validationClass = $block->escapeHtmlAttr(
19-
$this->helper(\Magento\Customer\Helper\Address::class)
20-
->getAttributeValidationClass('telephone')
21-
);
22-
?>
2317
<input type="text"
2418
name="telephone"
2519
id="telephone"
2620
value="<?= $block->escapeHtmlAttr($block->getTelephone()) ?>"
2721
title="<?= $block->escapeHtmlAttr(__('Phone Number')) ?>"
28-
class="input-text <?= $_validationClass ?: '' ?>"
22+
class="input-text <?= $block->escapeHtmlAttr(
23+
$block->getAttributeValidationClass('telephone')
24+
) ?>"
2925
>
3026
</div>
3127
</div>

app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22
/**
3-
* Oder statuses grid collection
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
86
namespace Magento\Sales\Model\ResourceModel\Status;
97

8+
/**
9+
* Order statuses grid collection.
10+
*/
1011
class Collection extends \Magento\Sales\Model\ResourceModel\Order\Status\Collection
1112
{
1213
/**

app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ define([
7878
}
7979

8080
tinyMCE3.init(this.getSettings(mode));
81+
varienGlobalEvents.clearEventHandlers('open_browser_callback');
82+
varienGlobalEvents.attachEventHandler('open_browser_callback', tinyMceEditors.get(this.id).openFileBrowser);
8183
},
8284

8385
/**

app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55
define([
66
'jquery',
7-
'Magento_Ui/js/grid/columns/column'
8-
], function ($, Column) {
7+
'Magento_Ui/js/grid/columns/column',
8+
'Magento_Ui/js/lib/key-codes'
9+
], function ($, Column, keyCodes) {
910
'use strict';
1011

1112
return Column.extend({
@@ -38,6 +39,18 @@ define([
3839
}
3940
},
4041

42+
/**
43+
* Initialize image preview component
44+
*
45+
* @returns {Object}
46+
*/
47+
initialize: function () {
48+
this._super();
49+
$(document).on('keydown', this.handleKeyDown.bind(this));
50+
51+
return this;
52+
},
53+
4154
/**
4255
* Init observable variables
4356
* @return {Object}
@@ -60,8 +73,13 @@ define([
6073
* @param {Object} record
6174
*/
6275
next: function (record) {
63-
var recordToShow = this.getRecord(record._rowIndex + 1);
76+
var recordToShow;
77+
78+
if (record._rowIndex + 1 === this.masonry().rows().length) {
79+
return;
80+
}
6481

82+
recordToShow = this.getRecord(record._rowIndex + 1);
6583
recordToShow.rowNumber = record.lastInRow ? record.rowNumber + 1 : record.rowNumber;
6684
this.show(recordToShow);
6785
},
@@ -72,7 +90,12 @@ define([
7290
* @param {Object} record
7391
*/
7492
prev: function (record) {
75-
var recordToShow = this.getRecord(record._rowIndex - 1);
93+
var recordToShow;
94+
95+
if (record._rowIndex === 0) {
96+
return;
97+
}
98+
recordToShow = this.getRecord(record._rowIndex - 1);
7699

77100
recordToShow.rowNumber = record.firstInRow ? record.rowNumber - 1 : record.rowNumber;
78101
this.show(recordToShow);
@@ -206,6 +229,23 @@ define([
206229
block: 'center',
207230
inline: 'nearest'
208231
});
232+
},
233+
234+
/**
235+
* Handle keyboard navigation for image preview
236+
*
237+
* @param {Object} e
238+
*/
239+
handleKeyDown: function (e) {
240+
var key = keyCodes[e.keyCode];
241+
242+
if (this.visibleRecord() !== null) {
243+
if (key === 'pageLeftKey') {
244+
this.prev(this.displayedRecord());
245+
} else if (key === 'pageRightKey') {
246+
this.next(this.displayedRecord());
247+
}
248+
}
209249
}
210250
});
211251
});

dev/tests/integration/testsuite/Magento/CatalogInventory/Block/Adminhtml/Form/Field/CustomergroupTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ protected function setUp()
2222

2323
public function testToHtml()
2424
{
25-
$this->_block->setClass('customer_group_select');
25+
$this->_block->setClass('customer_group_select admin__control-select');
2626
$this->_block->setId('123');
2727
$this->_block->setTitle('Customer Group');
2828
$this->_block->setInputName('groups[item_options]');
29-
$expectedResult = '<select name="groups[item_options]" id="123" class="customer_group_select" '
29+
$expectedResult = '<select name="groups[item_options]" id="123" '
30+
. 'class="customer_group_select admin__control-select" '
3031
. 'title="Customer Group" ><option value="32000" >ALL GROUPS</option><option value="0" >NOT LOGGED IN'
3132
. '</option><option value="1" >General</option><option value="2" >Wholesale</option><option value="3" >'
3233
. 'Retailer</option></select>';
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'wysiwygAdapter',
8+
'underscore'
9+
], function (wysiwygAdapter, _) {
10+
'use strict';
11+
12+
var obj;
13+
14+
beforeEach(function () {
15+
16+
/**
17+
* Dummy constructor to use for instantiation
18+
* @constructor
19+
*/
20+
var Constr = function () {};
21+
22+
Constr.prototype = wysiwygAdapter;
23+
24+
obj = new Constr();
25+
obj.eventBus = new window.varienEvents();
26+
obj.initialize(1, {
27+
'store_id': 0,
28+
'tinymce4': {
29+
'content_css': ''
30+
},
31+
'files_browser_window_url': 'url'
32+
});
33+
obj.setup();
34+
});
35+
36+
describe('"openFileBrowser" method', function () {
37+
it('Opens file browser to given instance', function () {
38+
expect(_.size(obj.eventBus.arrEvents['open_browser_callback'])).toBe(1);
39+
});
40+
});
41+
});

lib/internal/Magento/Framework/Data/Form/Element/Editor.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ protected function _getPluginButtonsHtml($visible = true)
310310
if (isset($buttonOptions['style'])) {
311311
$configStyle = $buttonOptions['style'];
312312
}
313-
$buttonOptions = array_merge($buttonOptions, ['style' => 'display:none;' . $configStyle]);
313+
$buttonOptions['style'] = 'display:none; ' . $configStyle;
314314
}
315315
$buttonsHtml .= $this->_getButtonHtml($buttonOptions);
316316
}
@@ -409,7 +409,7 @@ protected function _getButtonHtml($data)
409409
protected function _wrapIntoContainer($html)
410410
{
411411
if (!$this->getConfig('use_container')) {
412-
return '<div class="admin__control-wysiwig">' .$html . '</div>';
412+
return '<div class="admin__control-wysiwig">' . $html . '</div>';
413413
}
414414

415415
$html = '<div id="editor' . $this->getHtmlId() . '"'
@@ -533,10 +533,6 @@ protected function getInlineJs($jsSetupObject, $forceLoad)
533533
$jsSetupObject .
534534
'));
535535
varienGlobalEvents.attachEventHandler("formSubmit", editorFormValidationHandler);
536-
varienGlobalEvents.clearEventHandlers("open_browser_callback");
537-
varienGlobalEvents.attachEventHandler("open_browser_callback", ' .
538-
$jsSetupObject .
539-
'.openFileBrowser);
540536
//]]>
541537
});
542538
</script>';

lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ define([
118118
tinyMCE4.init(settings);
119119
this.getPluginButtons().hide();
120120
varienGlobalEvents.clearEventHandlers('open_browser_callback');
121+
this.eventBus.clearEventHandlers('open_browser_callback');
121122
this.eventBus.attachEventHandler('open_browser_callback', tinyMceEditors.get(self.id).openFileBrowser);
122123
}.bind(this));
123124
},

0 commit comments

Comments
 (0)