Skip to content

Commit 87c137c

Browse files
committed
MAGETWO-92697: Add vertical alignment to column configuration
- return empty string if path is optional - do not read data if path is optional
1 parent 3c34b95 commit 87c137c

File tree

3 files changed

+72
-57
lines changed

3 files changed

+72
-57
lines changed

app/code/Magento/PageBuilder/Model/Config/ContentType/Converter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private function convertDataMapping(\DOMElement $childNode): array
204204
$elementData = [];
205205
foreach ($childNode->getElementsByTagName('element') as $elementNode) {
206206
$elementName = $elementNode->attributes->getNamedItem('name')->nodeValue;
207-
$elementPath = $elementNode->attributes->getNamedItem('path')->nodeValue;
207+
$elementPath = ($elementNode->attributes->getNamedItem('path') ? $elementNode->attributes->getNamedItem('path')->nodeValue : '');
208208
$elementData[$elementName] = [
209209
'path' => $elementPath,
210210
'style' => $this->convertProperties($elementNode),

app/code/Magento/PageBuilder/view/adminhtml/web/js/master-format/read/configurable.js

Lines changed: 28 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/master-format/read/configurable.ts

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,43 +36,50 @@ export default class Configurable implements ReadInterface {
3636
let data = {};
3737
for (const elementName of Object.keys(config.elements)) {
3838
const elementConfig = config.elements[elementName];
39-
const xpathResult = document.evaluate(
40-
elementConfig.path,
41-
element,
42-
null,
43-
XPathResult.FIRST_ORDERED_NODE_TYPE,
44-
null,
45-
);
46-
const currentElement = xpathResult.singleNodeValue;
47-
if (currentElement === null || currentElement === undefined) {
48-
continue;
49-
}
50-
if (elementConfig.style.length) {
51-
data = this.readStyle(
52-
elementConfig.style,
53-
currentElement,
54-
data,
55-
propertyReaderPool,
56-
converterPool,
57-
);
58-
}
59-
if (elementConfig.attributes.length) {
60-
data = this.readAttributes(
61-
elementConfig.attributes,
62-
currentElement,
63-
data,
64-
propertyReaderPool,
65-
converterPool,
39+
// Do not read if path is optional
40+
console.log(elementConfig);
41+
if (elementConfig.path !== "") {
42+
console.log("path");
43+
const xpathResult = document.evaluate(
44+
elementConfig.path,
45+
element,
46+
null,
47+
XPathResult.FIRST_ORDERED_NODE_TYPE,
48+
null,
6649
);
67-
}
68-
if (undefined !== elementConfig.html.var) {
69-
data = this.readHtml(elementConfig, currentElement, data, converterPool);
70-
}
71-
if (undefined !== elementConfig.tag.var) {
72-
data = this.readHtmlTag(elementConfig, currentElement, data);
73-
}
74-
if (undefined !== elementConfig.css.var) {
75-
data = this.readCss(elementConfig, currentElement, data);
50+
const currentElement = xpathResult.singleNodeValue;
51+
if (currentElement === null || currentElement === undefined) {
52+
continue;
53+
}
54+
if (elementConfig.style.length) {
55+
data = this.readStyle(
56+
elementConfig.style,
57+
currentElement,
58+
data,
59+
propertyReaderPool,
60+
converterPool,
61+
);
62+
}
63+
if (elementConfig.attributes.length) {
64+
data = this.readAttributes(
65+
elementConfig.attributes,
66+
currentElement,
67+
data,
68+
propertyReaderPool,
69+
converterPool,
70+
);
71+
}
72+
if (undefined !== elementConfig.html.var) {
73+
data = this.readHtml(elementConfig, currentElement, data, converterPool);
74+
}
75+
if (undefined !== elementConfig.tag.var) {
76+
data = this.readHtmlTag(elementConfig, currentElement, data);
77+
}
78+
if (undefined !== elementConfig.css.var) {
79+
data = this.readCss(elementConfig, currentElement, data);
80+
}
81+
} else {
82+
console.log("no path");
7683
}
7784
}
7885
data = this.convertData(config, data, massConverterPool);

0 commit comments

Comments
 (0)