Skip to content

Commit 6c2c4fa

Browse files
committed
FEATURE: Show fields of further pages in Placeholder-Insert
fields of further pages were not available in the placeholder-insert Related to: #99
1 parent d2e917a commit 6c2c4fa

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

Resources/Private/PlaceholderInsert/src/PlaceholderInsertDropdown.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,38 @@ export default class PlaceholderInsertDropdown extends PureComponent {
3939
};
4040

4141
render() {
42+
let options = [];
43+
4244
const [formPath, workspace] = parentNodeContextPath(
4345
parentNodeContextPath(this.props.focusedNode.contextPath)
4446
).split("@");
4547

48+
// get options of first page
4649
const elementsPath = `${formPath}/elements@${workspace}`;
4750

4851
const elementsNode = this.props.nodesByContextPath[elementsPath];
4952
if (!elementsNode) {
5053
return null;
5154
}
52-
const options = this.getOptionsRecursively(elementsNode.children);
55+
const firstPageOptions = this.getOptionsRecursively(elementsNode.children);
56+
if (firstPageOptions && firstPageOptions.length > 0) {
57+
options = options.concat(firstPageOptions);
58+
}
59+
60+
// get options of further pages
61+
const furtherPagesPath = `${formPath}/furtherpages@${workspace}`;
62+
const furtherPagesNode = this.props.nodesByContextPath[furtherPagesPath];
63+
if (furtherPagesNode && furtherPagesNode.children && furtherPagesNode.children.length > 0) {
64+
furtherPagesNode.children.forEach(furtherPageChildren => {
65+
if (furtherPageChildren) {
66+
const pageOptions = this.getOptionsOfPage(furtherPageChildren);
67+
68+
if (pageOptions && pageOptions.length > 0) {
69+
options = options.concat(pageOptions);
70+
}
71+
}
72+
});
73+
}
5374

5475
if (options.length === 0) {
5576
return null;
@@ -70,6 +91,17 @@ export default class PlaceholderInsertDropdown extends PureComponent {
7091
);
7192
}
7293

94+
getOptionsOfPage(page) {
95+
const [path, workspace] = page.contextPath.split("@");
96+
const elementsPath = `${path}/elements@${workspace}`;
97+
const elementsNode = this.props.nodesByContextPath[elementsPath];
98+
if (!elementsNode) {
99+
return null;
100+
}
101+
102+
return this.getOptionsRecursively(elementsNode.children);
103+
}
104+
73105
getOptionsRecursively(elements) {
74106
const {frontendConfiguration} = this.props;
75107
const ignoreNodeTypeInDropdown = frontendConfiguration.get('Neos.Form.Builder:PlaceholderInsert').ignoreNodeTypeInDropdown;

Resources/Public/JavaScript/PlaceholderInsert/Plugin.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)