Skip to content

Commit 83a9b9c

Browse files
authored
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #13208: #12714 - pass parameter for export button url (by @sanjay-wagento) - magento-engcom/magento2ce#1163: GitHub 12322: Bug with CDATA in XML layout update (by @serhii-balko) Fixed GitHub Issues: - #12714: Extra records are in exported CSV file for order (reported by @alena-marchenko) has been fixed in #13208 by @sanjay-wagento in 2.2-develop branch Related commits: 1. f7baf29 - #12322: Bug with CDATA in XML layout update (reported by @alexvandervegt) has been fixed in magento-engcom/magento2ce#1163 by @serhii-balko in 2.2-develop branch Related commits: 1. 6b22445
2 parents 11fd8ce + afd02d7 commit 83a9b9c

File tree

6 files changed

+143
-5
lines changed

6 files changed

+143
-5
lines changed

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
<listingToolbar name="listing_top">
3636
<bookmark name="bookmarks"/>
3737
<columnsControls name="columns_controls"/>
38-
<exportButton name="export_button"/>
38+
<exportButton name="export_button">
39+
<settings>
40+
<additionalParams>
41+
<param xsi:type="string" active="true" name="order_id">*</param>
42+
</additionalParams>
43+
</settings>
44+
</exportButton>
3945
<filterSearch name="fulltext"/>
4046
<filters name="listing_filters">
4147
<filterSelect name="store_id" provider="${ $.parentName }">

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
<listingToolbar name="listing_top">
3636
<bookmark name="bookmarks"/>
3737
<columnsControls name="columns_controls"/>
38-
<exportButton name="export_button"/>
38+
<exportButton name="export_button">
39+
<settings>
40+
<additionalParams>
41+
<param xsi:type="string" active="true" name="order_id">*</param>
42+
</additionalParams>
43+
</settings>
44+
</exportButton>
3945
<filterSearch name="fulltext"/>
4046
<filters name="listing_filters">
4147
<filterSelect name="store_id" provider="${ $.parentName }">

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
<listingToolbar name="listing_top">
3636
<bookmark name="bookmarks"/>
3737
<columnsControls name="columns_controls"/>
38-
<exportButton name="export_button"/>
38+
<exportButton name="export_button">
39+
<settings>
40+
<additionalParams>
41+
<param xsi:type="string" active="true" name="order_id">*</param>
42+
</additionalParams>
43+
</settings>
44+
</exportButton>
3945
<filterSearch name="fulltext"/>
4046
<filters name="listing_filters">
4147
<filterSelect name="store_id" provider="${ $.parentName }">

app/code/Magento/Ui/Component/ExportButton.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,39 @@ public function getComponentName()
5454
*/
5555
public function prepare()
5656
{
57+
$context = $this->getContext();
5758
$config = $this->getData('config');
5859
if (isset($config['options'])) {
5960
$options = [];
6061
foreach ($config['options'] as $option) {
61-
$option['url'] = $this->urlBuilder->getUrl($option['url']);
62+
$additionalParams = $this->getAdditionalParams($config, $context);
63+
$option['url'] = $this->urlBuilder->getUrl($option['url'], $additionalParams);
6264
$options[] = $option;
6365
}
6466
$config['options'] = $options;
6567
$this->setData('config', $config);
6668
}
6769
parent::prepare();
6870
}
71+
72+
/**
73+
* Get export button additional parameters
74+
*
75+
* @param array $config
76+
* @param ContextInterface $context
77+
* @return array
78+
*/
79+
protected function getAdditionalParams($config, $context)
80+
{
81+
$additionalParams = [];
82+
if (isset($config['additionalParams'])) {
83+
foreach ($config['additionalParams'] as $paramName => $paramValue) {
84+
if ('*' == $paramValue) {
85+
$paramValue = $context->getRequestParam($paramName);
86+
}
87+
$additionalParams[$paramName] = $paramValue;
88+
}
89+
}
90+
return $additionalParams;
91+
}
6992
}

app/code/Magento/Ui/TemplateEngine/Xhtml/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function __toString()
119119
protected function wrapContent($content)
120120
{
121121
return '<script type="text/x-magento-init"><![CDATA['
122-
. '{"*": {"Magento_Ui/js/core/app": ' . str_replace(['<![CDATA[', ']]>'], '', $content) . '}}'
122+
. '{"*": {"Magento_Ui/js/core/app": ' . str_replace(']]>', ']]]]><![CDATA[>', $content) . '}}'
123123
. ']]></script>';
124124
}
125125
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Ui\Test\Unit\TemplateEngine\Xhtml;
8+
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
use Magento\Framework\View\Layout\Generator\Structure;
11+
use Magento\Framework\View\Element\UiComponentInterface;
12+
use Magento\Framework\View\TemplateEngine\Xhtml\CompilerInterface;
13+
use Magento\Framework\View\TemplateEngine\Xhtml\Template;
14+
use Magento\Ui\TemplateEngine\Xhtml\Result;
15+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
16+
use Psr\Log\LoggerInterface;
17+
18+
/**
19+
* Test Class for Class Result.
20+
* @see \Magento\Ui\TemplateEngine\Xhtml\Result
21+
*
22+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
23+
*/
24+
class ResultTest extends \PHPUnit\Framework\TestCase
25+
{
26+
/**
27+
* @var Template|MockObject
28+
*/
29+
private $template;
30+
31+
/**
32+
* @var CompilerInterface|MockObject
33+
*/
34+
private $compiler;
35+
36+
/**
37+
* @var UiComponentInterface|MockObject
38+
*/
39+
private $component;
40+
41+
/**
42+
* @var Structure|MockObject
43+
*/
44+
private $structure;
45+
46+
/**
47+
* @var LoggerInterface|MockObject
48+
*/
49+
private $logger;
50+
51+
/**
52+
* @var Result
53+
*/
54+
private $testModel;
55+
56+
/**
57+
* @var ObjectManager
58+
*/
59+
private $objectManager;
60+
61+
protected function setUp()
62+
{
63+
$this->template = $this->createPartialMock(Template::class, ['append']);
64+
$this->compiler = $this->createMock(CompilerInterface::class);
65+
$this->component = $this->createMock(UiComponentInterface::class);
66+
$this->structure = $this->createPartialMock(Structure::class, ['generate']);
67+
$this->logger = $this->createMock(LoggerInterface::class);
68+
69+
$this->objectManager = new ObjectManager($this);
70+
$this->testModel = $this->objectManager->getObject(Result::class, [
71+
'template' => $this->template,
72+
'compiler' => $this->compiler,
73+
'component' => $this->component,
74+
'structure' => $this->structure,
75+
'logger' => $this->logger,
76+
]);
77+
}
78+
79+
/**
80+
* Test Append layout configuration method
81+
*/
82+
public function testAppendLayoutConfiguration()
83+
{
84+
$configWithCdata = 'text before <![CDATA[cdata text]]>';
85+
$this->structure->expects($this->once())
86+
->method('generate')
87+
->with($this->component)
88+
->willReturn([$configWithCdata]);
89+
$this->template->expects($this->once())
90+
->method('append')
91+
->with('<script type="text/x-magento-init"><![CDATA[{"*": {"Magento_Ui/js/core/app": '
92+
. '["text before <![CDATA[cdata text]]]]><![CDATA[>"]'
93+
. '}}]]></script>');
94+
95+
$this->testModel->appendLayoutConfiguration();
96+
}
97+
}

0 commit comments

Comments
 (0)