fix(xod-client): attach an implementation when adding not-implemented-in-xod node

Closes #998
This commit is contained in:
Evgeny Kochetkov
2018-01-17 13:26:52 +03:00
parent c404de255b
commit 9027601944

View File

@@ -5,6 +5,7 @@ import { getLibName } from 'xod-pm';
import * as AT from './actionTypes';
import { PASTE_ENTITIES, INSTALL_LIBRARIES_COMPLETE } from '../editor/actionTypes';
import { IMPL_TEMPLATE } from '../editor/constants';
import {
addPoints,
@@ -278,7 +279,16 @@ export default (state = {}, action) => {
return R.over(
XP.lensPatch(patchPath), // TODO: can we have a situation where patch does not exist?
XP.assocNode(newNode),
R.compose(
XP.assocNode(newNode),
R.when(
R.both(
() => typeId === XP.NOT_IMPLEMENTED_IN_XOD_PATH,
R.complement(XP.hasImpl)
),
XP.setImpl(IMPL_TEMPLATE)
)
),
state
);
}