From a9691f5fe78af32c474754f841a71a68e2d2a484 Mon Sep 17 00:00:00 2001 From: Koren Lev Date: Mon, 2 Oct 2017 11:37:03 +0300 Subject: ui move to docker Change-Id: Iff31ebb3fff782e848704801b7800fdf480264a1 Signed-off-by: Koren Lev --- ui/imports/ui/actions/navigation.js | 76 ------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 ui/imports/ui/actions/navigation.js (limited to 'ui/imports/ui/actions/navigation.js') 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 -}; -- cgit 1.2.3-korg