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: neos#99
  • Loading branch information
erkenes committed Mar 5, 2024
1 parent 9b68aaf commit d7a67b4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
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
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/PlaceholderInsert/Plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d7a67b4

Please sign in to comment.