diff --git a/.gitignore b/.gitignore index 546db1f143..93df252add 100644 --- a/.gitignore +++ b/.gitignore @@ -36,8 +36,14 @@ Resources/Public/Styles/Font* lerna-debug.log npm-debug.log +# +# System Files +# +.DS_Store + # # editors / IDEs # .vscode/ .idea/ +*.iml diff --git a/packages/neos-ui/src/Containers/Modals/NodeCreationDialog/index.js b/packages/neos-ui/src/Containers/Modals/NodeCreationDialog/index.js index cab1f9e87a..8a627121d4 100644 --- a/packages/neos-ui/src/Containers/Modals/NodeCreationDialog/index.js +++ b/packages/neos-ui/src/Containers/Modals/NodeCreationDialog/index.js @@ -6,8 +6,9 @@ import memoize from 'lodash.memoize'; import cx from 'classnames'; import {neos} from '@neos-project/neos-ui-decorators'; -import {actions} from '@neos-project/neos-ui-redux-store'; +import {actions, selectors} from '@neos-project/neos-ui-redux-store'; import validate from '@neos-project/neos-ui-validators'; +import preprocessNodeConfiguration from '../../../preprocessNodeConfiguration'; import Icon from '@neos-project/react-ui-components/src/Icon/'; import Button from '@neos-project/react-ui-components/src/Button/'; @@ -24,8 +25,12 @@ import style from './style.css'; const isOpen = $get('ui.nodeCreationDialog.isOpen', state); const label = $get('ui.nodeCreationDialog.label', state); const configuration = $get('ui.nodeCreationDialog.configuration', state); + const parentNodeContextPath = $get('ui.nodeCreationDialog.parentNodeContextPath', state); + const nodeType = $get('ui.nodeCreationDialog.nodeType', state); - return {isOpen, label, configuration}; + const parentNode = selectors.CR.Nodes.makeGetNodeByContextPathSelector(parentNodeContextPath)(state); + + return {isOpen, label, configuration, parentNode, nodeType }, { cancel: actions.UI.NodeCreationDialog.cancel, back: actions.UI.NodeCreationDialog.back, @@ -36,6 +41,8 @@ export default class NodeCreationDialog extends PureComponent { isOpen: PropTypes.bool.isRequired, label: PropTypes.string, configuration: PropTypes.object, + parentNode: PropTypes.object, + nodeType: PropTypes.string, validatorRegistry: PropTypes.object.isRequired, cancel: PropTypes.func.isRequired, back: PropTypes.func.isRequired, @@ -225,11 +232,9 @@ export default class NodeCreationDialog extends PureComponent { ); } - renderElement(elementName, isFirst) { - const {configuration} = this.props; + renderElement(elementName, element, isFirst) { const {validationErrors, isDirty} = this.state; const validationErrorsForElement = isDirty ? $get(elementName, validationErrors) : []; - const element = configuration.elements[elementName]; const options = $set('autoFocus', isFirst, Object.assign({}, $get('ui.editorOptions', element))); return ( @@ -254,13 +259,32 @@ export default class NodeCreationDialog extends PureComponent { } renderAllElements() { - const {configuration} = this.props; + const transientValues = this.getValuesMapFromTransientValues(this.state.transient); + const {parentNode} = this.props; + + /** + * Transient Node used in CreationDialog for ClientEval. + * NOTE: This transient Node does not have all the attributes of a real Node + * because the Node does not exist yet. + */ + const transientNode = { + nodeType: this.props.nodeType, + parent: parentNode.contextPath, + properties: { + _nodeType: this.props.nodeType, + ...transientValues + } + } + + // evaluate ClientEval in configuration with transientNode and parentNode + const configuration = preprocessNodeConfiguration({node: transientNode, parentNode}, this.props.configuration) return Object.keys(configuration.elements).reduce( (result, elementName, index) => { - if (configuration.elements[elementName]) { + const element = configuration.elements[elementName] + if (element) { result.push( - this.renderElement(elementName, index === 0) + this.renderElement(elementName, element, index === 0) ); }