Commit edd951c2 authored by Karen Konou's avatar Karen Konou

[Folder view] Merge duplicate functions

parent 4ccd62ec
......@@ -92,13 +92,13 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
, reload
, session
, setPopoverRef } _ = do
let foldersS = A.sortBy sortFolders children
let folders' = A.sortBy sortFolders children
let parent = makeParentFolder parentNode session
let childrenEl = makeFolderElements foldersS { boxes, nodeId, reload, session, setPopoverRef }
let childrenEl = makeFolderElements folders' { boxes, nodeId, reload, session, setPopoverRef }
pure $ H.div {className: "fv folders"} $ parent <> childrenEl
makeFolderElements foldersS props = makeFolderElementsMap <$> foldersS where
makeFolderElements folders' props = makeFolderElementsMap <$> folders' where
makeFolderElementsMap :: TreeNode -> R.Element
makeFolderElementsMap node = folder { boxes: props.boxes
, nodeId: node.id
......@@ -115,7 +115,6 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
[ folderSimple {style: FolderUp, text: "..", nodeId: parent.id, nodeType: parent.node_type, session: session} [] ]
makeParentFolder Nothing _ = []
sortFolders :: TreeNode-> TreeNode -> Ordering
sortFolders a b = compare a.id b.id
......@@ -128,6 +127,13 @@ type FolderSimpleProps =
, session :: Session
)
getFolderPath :: GT.NodeType -> GT.SessionId -> Int -> AppRoute
getFolderPath nodeType sid nodeId = fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId
icon :: FolderStyle -> GT.NodeType -> String
icon FolderUp _ = "fa fa-folder-open"
icon _ nodeType = GT.fldr nodeType false
folderSimple :: R2.Component FolderSimpleProps
folderSimple = R.createElement folderSimpleCpt
......@@ -147,14 +153,6 @@ folderSimpleCpt = here.component "folderSimpleCpt" cpt where
route nId rootId nType sid
| rootId == nodeId = Home
| otherwise = getFolderPath nType sid nId
icon :: FolderStyle -> GT.NodeType -> String
icon FolderUp _ = "fa fa-folder-open"
icon _ nodeType = GT.fldr nodeType false
getFolderPath :: GT.NodeType -> GT.SessionId -> Int -> AppRoute
getFolderPath nodeType sid nodeId = fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId
type FolderProps =
( boxes :: Boxes
......@@ -202,14 +200,6 @@ folderCpt = here.component "folderCpt" cpt where
, H.br {}
, H.text text]]
icon :: FolderStyle -> GT.NodeType -> String
icon FolderUp _ = "fa fa-folder-open"
icon _ nodeType = GT.fldr nodeType false
getFolderPath :: GT.NodeType -> GT.SessionId -> Int -> AppRoute
getFolderPath nodeType sid nodeId = fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId
onPopoverClose popoverRef _ = Popover.setOpen popoverRef false
popOverIcon = H.span { className: "fv action" } [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment