Skip to content

Commit

Permalink
FEATURE: Show fields of further pages in Placeholder-Insert
Browse files Browse the repository at this point in the history
fields of further pages were not available in the
placeholder-insert

Related to: #99
  • Loading branch information
erkenes committed Mar 5, 2024
1 parent 2ba0811 commit 9603b8e
Showing 1 changed file with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,38 @@ export default class PlaceholderInsertDropdown extends PureComponent {
};

render() {
let options = [];

const [formPath, workspace] = parentNodeContextPath(
parentNodeContextPath(this.props.focusedNode.contextPath)
).split("@");

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

const elementsNode = this.props.nodesByContextPath[elementsPath];
if (!elementsNode) {
return null;
}
const options = this.getOptionsRecursively(elementsNode.children);
const firstPageOptions = this.getOptionsRecursively(elementsNode.children);
if (firstPageOptions && firstPageOptions.length > 0) {
options = options.concat(firstPageOptions);
}

// get options of further pages
const furtherPagesPath = `${formPath}/furtherpages@${workspace}`;
const furtherPagesNode = this.props.nodesByContextPath[furtherPagesPath];
if (furtherPagesNode && furtherPagesNode.children && furtherPagesNode.children.length > 0) {
furtherPagesNode.children.forEach(furtherPageChildren => {
if (furtherPageChildren) {
const pageOptions = this.getOptionsOfPage(furtherPageChildren);

if (pageOptions && pageOptions.length > 0) {
options = options.concat(pageOptions);
}
}
});
}

if (options.length === 0) {
return null;
Expand All @@ -71,6 +92,17 @@ export default class PlaceholderInsertDropdown extends PureComponent {
);
}

getOptionsOfPage(page) {
const [path, workspace] = page.contextPath.split("@");
const elementsPath = `${path}/elements@${workspace}`;
const elementsNode = this.props.nodesByContextPath[elementsPath];
if (!elementsNode) {
return null;
}

return this.getOptionsRecursively(elementsNode.children);
}

getOptionsRecursively(elements) {
const {frontendConfiguration} = this.props;
const ignoreNodeTypeInDropdown = frontendConfiguration.get('Neos.Form.Builder:PlaceholderInsert').ignoreNodeTypeInDropdown;
Expand Down

0 comments on commit 9603b8e

Please sign in to comment.