Skip to content

Commit 4b98cc4

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-88132-add-edit-location-to-map' into cms-team-2-sprint-9
2 parents 5274476 + 4ea6d89 commit 4b98cc4

File tree

59 files changed

+5917
-2785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+5917
-2785
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Block\Adminhtml\ContentType\Edit;
10+
11+
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
12+
13+
class CancelButton implements ButtonProviderInterface
14+
{
15+
/**
16+
* @var string
17+
*/
18+
private $targetName;
19+
20+
/**
21+
* Constructor
22+
*
23+
* @param $targetName
24+
*/
25+
public function __construct(string $targetName)
26+
{
27+
$this->targetName = $targetName;
28+
}
29+
30+
/**
31+
* Retrieve button data
32+
*
33+
* @return array
34+
*/
35+
public function getButtonData(): array
36+
{
37+
return [
38+
'label' => __('Cancel'),
39+
'class' => 'cancel',
40+
'on_click' => '',
41+
'data_attribute' => [
42+
'mage-init' => [
43+
'buttonAdapter' => [
44+
'actions' => [
45+
[
46+
'targetName' => $this->targetName,
47+
'actionName' => 'closeModal',
48+
'params' => [
49+
false,
50+
]
51+
]
52+
]
53+
]
54+
],
55+
'form-role' => 'cancel',
56+
],
57+
'sort_order' => 90
58+
];
59+
}
60+
}

app/code/Magento/PageBuilder/Block/Adminhtml/ContentType/Edit/Close.php renamed to app/code/Magento/PageBuilder/Block/Adminhtml/ContentType/Edit/CloseButton.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
99

10-
class Close implements ButtonProviderInterface
10+
class CloseButton implements ButtonProviderInterface
1111
{
1212
/**
1313
* @var string

app/code/Magento/PageBuilder/Setup/DataConverter/Renderer/Map.php

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class Map implements RendererInterface
2424
*/
2525
private $eavAttributeLoader;
2626

27+
/**
28+
* @var array
29+
*/
30+
private $rootElementAttributes;
31+
2732
public function __construct(
2833
StyleExtractorInterface $styleExtractor,
2934
EavAttributeLoaderInterface $eavAttributeLoader
@@ -42,26 +47,21 @@ public function render(array $itemData, array $additionalData = [])
4247
}
4348
$eavData = $this->eavAttributeLoader->load($itemData['entityId']);
4449

45-
$rootElementAttributes = [
50+
$this->rootElementAttributes = [
4651
'data-role' => 'map',
4752
'data-appearance' => 'default',
4853
'class' => $eavData['css_classes'] ?? '',
4954
'data-show-controls' => 'true',
50-
'data-position' => '{}',
55+
'data-locations' => '[]',
5156
];
5257

53-
if (isset($eavData['map'])) {
54-
$map = explode(',', $eavData['map']);
55-
$rootElementAttributes['data-position'] = '{&quot;lat&quot;:'
56-
. $map[0]
57-
. ',&quot;lng&quot;:'
58-
. $map[1]
59-
. '}';
60-
}
58+
$this->renderMapLocations($eavData);
6159

6260
if (isset($itemData['formData'])) {
6361
$formData = $itemData['formData'];
64-
$formData['height'] = $eavData['map_height'] ?? '300px';
62+
$formData['height'] = $eavData['map_height']
63+
&& strpos($eavData['map_height'], '%') === false
64+
? $eavData['map_height'] : '300px';
6565

6666
$style = $this->styleExtractor->extractStyle($formData);
6767
if ($style) {
@@ -70,16 +70,33 @@ public function render(array $itemData, array $additionalData = [])
7070
} else {
7171
$style .= ' display: none;';
7272
}
73-
$rootElementAttributes['style'] = $style;
73+
$this->rootElementAttributes['style'] = $style;
7474
}
7575
}
7676

7777
$rootElementHtml = '<div';
78-
foreach ($rootElementAttributes as $attributeName => $attributeValue) {
78+
foreach ($this->rootElementAttributes as $attributeName => $attributeValue) {
7979
$rootElementHtml .= $attributeValue !== '' ? " $attributeName=\"$attributeValue\"" : '';
8080
}
8181
$rootElementHtml .= '></div>';
8282

8383
return $rootElementHtml;
8484
}
85+
86+
/**
87+
* Extract and render Map Location data from EAV
88+
*
89+
* @param array $eavData
90+
*/
91+
private function renderMapLocations($eavData)
92+
{
93+
if (isset($eavData['map'])) {
94+
$map = explode(',', $eavData['map']);
95+
$this->rootElementAttributes['data-locations'] = '[{&quot;position&quot;:{&quot;latitude&quot;:'
96+
. $map[0]
97+
. ',&quot;longitude&quot;:'
98+
. $map[1]
99+
. '}}]';
100+
}
101+
}
85102
}

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/ActionGroup.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,12 @@
637637
</actionGroup>
638638
<actionGroup name="saveEditPanelAndValidateFieldErrorGeneralSection">
639639
<arguments>
640+
<argument name="form" defaultValue="PageBuilderActionsSection"/>
640641
<argument name="property"/>
641642
</arguments>
642643
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
643-
<waitForElementVisible time="5" selector="{{PageBuilderActionsSection.editFormSave}}" stepKey="waitForColumnSaveButton" />
644-
<click selector="{{PageBuilderActionsSection.editFormSave}}" stepKey="clickSaveColumn"/>
644+
<waitForElementVisible time="5" selector="{{form.editFormSave}}" stepKey="waitForSaveButton"/>
645+
<click selector="{{form.editFormSave}}" stepKey="clickSaveButton"/>
645646
<waitForElementVisible selector="{{PageBuilderActionsSection.panelFieldValidationError(property.section, property.fieldName)}}" stepKey="waitForErrorField"/>
646647
<waitForElementVisible selector="{{PageBuilderActionsSection.panelFieldValidationErrorMessage(property.section, property.fieldName, property.errorMessage)}}" stepKey="waitForErrorMessage"/>
647648
</actionGroup>

0 commit comments

Comments
 (0)