diff options
author | Koren Lev <korenlev@gmail.com> | 2017-10-02 11:37:03 +0300 |
---|---|---|
committer | Koren Lev <korenlev@gmail.com> | 2017-10-02 11:37:03 +0300 |
commit | a9691f5fe78af32c474754f841a71a68e2d2a484 (patch) | |
tree | 6ad620ebc1f9adf6bf9fc671d88ea0adf8e7fe07 /ui/imports/ui/actions/navigation.js | |
parent | 1e1e95ac6560f26fc154fab4c990235da5ba23c6 (diff) |
ui move to docker
Change-Id: Iff31ebb3fff782e848704801b7800fdf480264a1
Signed-off-by: Koren Lev <korenlev@gmail.com>
Diffstat (limited to 'ui/imports/ui/actions/navigation.js')
-rw-r--r-- | ui/imports/ui/actions/navigation.js | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/ui/imports/ui/actions/navigation.js b/ui/imports/ui/actions/navigation.js deleted file mode 100644 index f9c86b5..0000000 --- a/ui/imports/ui/actions/navigation.js +++ /dev/null @@ -1,76 +0,0 @@ -import * as R from 'ramda'; - -const SET_CURRENT_NODE = 'SET_CURRENT_NODE'; -const SET_CURRENT_NODE_FROM_TREE_CONTROL = 'SET_CURRENT_NODE_FROM_TREE_CONTROL'; - -function setCurrentNode(item) { - let nodeChain = convertToNodeChain(item.id_path, item.name_path); - R.last(nodeChain).item = item; - - return { - type: SET_CURRENT_NODE, - payload: { - nodeChain: nodeChain - } - }; -} - -function setCurrentNodeFromTreeControl (item) { - let nodeChain = convertToNodeChain(item.id_path, item.name_path); - R.last(nodeChain).item = item; - - return { - type: SET_CURRENT_NODE_FROM_TREE_CONTROL, - payload: { - nodeChain: nodeChain - } - }; -} - -function convertToNodeChain(idPath, namePath) { - let convert = R.pipe(R.split(), R.slice(1, Infinity)); - let paths = convert('/', idPath); - let names = convert('/', namePath); - let nodesData = R.zip(paths, names); - let nodeChain = R.map((nodeData) => { - return { - id: nodeData[0], - name: nodeData[1] - }; - }, nodesData); - - let parent = null; - - for (let i = 0; i < nodeChain.length; i++) { - let node = nodeChain[i]; - node.parent = parent; - node.fullIdPath = calcFullIdPath(node); - node.fullNamePath = calcFullNamePath(node); - parent = node; - } - - return nodeChain; -} - -function calcFullIdPath (node) { - if (R.isNil(node)) { return null; } - if (R.isNil(node.parent)) { return '/' + node.id; } - - let parentFullPath = calcFullIdPath(node.parent); - return parentFullPath + '/' + node.id; -} - -function calcFullNamePath (node) { - if (R.isNil(node)) { return null; } - if (R.isNil(node.parent)) { return '/' + node.name; } - - let parentFullPath = calcFullNamePath(node.parent); - return parentFullPath + '/' + node.name; -} - -export { - SET_CURRENT_NODE, - SET_CURRENT_NODE_FROM_TREE_CONTROL, - setCurrentNode, - setCurrentNodeFromTreeControl -}; |