Skip to content

Commit

Permalink
TASK: fixed the bug
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
#	packages/neos-ui/src/Containers/Modals/NodeCreationDialog/index.js
  • Loading branch information
JamesAlias authored and markusguenther committed Feb 22, 2023
1 parent 7986dc4 commit e7a73d2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ Resources/Public/Styles/Font*
lerna-debug.log
npm-debug.log

#
# System Files
#
.DS_Store

#
# editors / IDEs
#
.vscode/
.idea/
*.iml
40 changes: 32 additions & 8 deletions packages/neos-ui/src/Containers/Modals/NodeCreationDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/';
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 (
Expand All @@ -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)
);
}

Expand Down

0 comments on commit e7a73d2

Please sign in to comment.