Skip to content

Commit d7a67b4

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: neos#99
1 parent 9b68aaf commit d7a67b4

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

Resources/Private/PlaceholderInsert/src/PlaceholderInsertDropdown.js

+33-1
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,38 @@ export default class PlaceholderInsertDropdown extends PureComponent {
4040
};
4141

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

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

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

5576
if (options.length === 0) {
5677
return null;
@@ -71,6 +92,17 @@ export default class PlaceholderInsertDropdown extends PureComponent {
7192
);
7293
}
7394

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

Resources/Public/JavaScript/PlaceholderInsert/Plugin.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)