Commit b01a7fe6 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FOREST][REFACT] buttonClick.

parent 6104d122
module Gargantext.Components.Forest.Tree.Node where
import Prelude
import Data.Array (foldl)
import Gargantext.Types
import Effect.Uncurried (mkEffectFn1)
-- import Data.Set
......@@ -39,6 +40,31 @@ instance eqNodeAction :: Eq NodeAction where
eq (Add x) (Add y) = true && (x == y)
eq _ _ = false
instance showNodeAction :: Show NodeAction where
show (Documentation x) = "Documentation of " <> show x
show SearchBox = "SearchBox"
show Download = "Download"
show Upload = "Upload"
show Refresh = "Refresh"
show Move = "Move"
show Clone = "Clone"
show Delete = "Delete"
show Share = "Share"
show (Link x) = "Link to " <> show x
show (Add xs) = foldl (\a b -> a <> show b) "Add " xs
glyphiconNodeAction :: NodeAction -> String
glyphiconNodeAction (Documentation _) = "question-sign"
glyphiconNodeAction Delete = "trash"
glyphiconNodeAction (Add _) = "plus"
glyphiconNodeAction SearchBox = "search"
glyphiconNodeAction Upload = "upload"
glyphiconNodeAction (Link _) = "transfer"
glyphiconNodeAction Download = "download"
glyphiconNodeAction _ = ""
------------------------------------------------------------------------
------------------------------------------------------------------------
......@@ -74,17 +100,17 @@ settingsBox FolderPrivate = SettingsBox { show: true
}
settingsBox FolderShared = SettingsBox { show: true
, edit : false
, buttons : [Documentation FolderShared
, edit : false
, buttons : [Documentation FolderShared
-- , Add [Folder, Team]
, Delete
]
}
}
settingsBox FolderPublic = SettingsBox { show: true
, edit : false
, buttons : [Documentation FolderPublic
, edit : false
, buttons : [Documentation FolderPublic
{-, SearchBox
, Add [ Corpus
, Folder
......@@ -147,8 +173,8 @@ settingsBox NodeList = SettingsBox { show : true
}
settingsBox Dashboard = SettingsBox { show : true
, edit : false
, buttons : [ Documentation Dashboard
, edit : false
, buttons : [ Documentation Dashboard
]
}
......
......@@ -58,3 +58,5 @@ renameBox _ p (false /\ _) = R.createElement el p []
-- END Rename Box
......@@ -263,90 +263,29 @@ nodePopupView _ p _ = R.createElement el p []
-- buttonAction :: NodeAction -> R.Element
buttonClick (node@{action} /\ setNodePopup) _ todo@(Documentation x) = H.div {className: "col-md-2"}
buttonClick (node@{action} /\ setNodePopup) _ todo = H.div {className: "col-md-2"}
[ H.a { style: iconAStyle
, className: glyphiconActive "question-sign" (action == (Just todo))
, id: "doc"
, title: "Documentation of " <> show x
, onClick : mkEffectFn1 $ \_ -> setNodePopup $ const (node { action = Just todo })
, className: glyphiconActive (glyphiconNodeAction todo)
(action == (Just todo) )
, id: show todo
, title: show todo
, onClick : mkEffectFn1
$ \_ -> setNodePopup
$ const (node { action = action' })
}
[]
]
where
action' = if action == (Just todo)
then Nothing
else (Just todo)
buttonClick (node@{action} /\ setNodePopup) d Delete = H.div {className: "col-md-2"}
[ H.a { style: iconAStyle
, className: glyphiconActive "trash" (action == (Just Delete))
, id: "delete"
, title: "Delete"
, onClick: mkEffectFn1 $ \_ -> setNodePopup $ const $ node { action = Just Delete }
}
[]
]
buttonClick (node@{action} /\ setNodePopup) d (Add xs) = H.div {className: "col-md-2"}
[ H.a { style: iconAStyle
, className: glyphiconActive "plus" (action == (Just $ Add xs))
, id: "add"
, title: "add"
, onClick: mkEffectFn1 $ \_ -> setNodePopup $ const $ node { action = Just $ Add xs}
}
[]
]
--{-
buttonClick (node@{nodeType,action} /\ setNodePopup) d SearchBox = H.div {className: "col-md-2"}
[ H.a { style: iconAStyle
, className: glyphiconActive "search" (action == (Just SearchBox))
, id: "search"
, title: "Search and create " <> show nodeType
, onClick: mkEffectFn1 $ \_ -> setNodePopup $ const $ node {action = Just SearchBox}
}
[]
]
buttonClick (node@{action} /\ setNodePopup) _ Upload = H.div {className: "col-md-2"}
[ H.a { style: iconAStyle
, className: glyphiconActive "upload" (action == (Just Upload))
, id: "upload"
, title: "Upload [WIP]"
, onClick: mkEffectFn1 $ \_ -> setNodePopup $ const $ node {action = Just Upload}
}
[]
]
buttonClick (node@{action} /\ setNodePopup) _ (Link n) = H.div {className: "col-md-2"}
[ H.a { style: iconAStyle
, className: glyphiconActive "transfer" (action == (Just $ Link n))
, id: "link"
, title: "Link [WIP]"
, onClick: mkEffectFn1 $ \_ -> setNodePopup $ const $ node {action = Just (Link n)}
}
[]
]
buttonClick _ _ _ = H.div {} []
buttonClick (node@{action} /\ setNodePopup) _ Download = H.div {className: "col-md-2"}
[ H.a {style: iconAStyle
, className: glyphiconActive "download" (action == (Just Download))
, id: "download"
, title: "Download [WIP]"
, onClick: mkEffectFn1 $ \_ -> setNodePopup $ const $ node {action = Just Download}
}
[]
]
buttonClick _ _ _ = H.div {} []
buttonPop f = H.div {className: "col-md-4"}
[ H.a { style: iconAStyle
, className: (glyphicon "plus")
, id: "create"
, title: "Create"
, onClick: mkEffectFn1 $ \_ -> f $ const $ Just CreatePopup
}
[]
]
-- END Popup View
......@@ -403,3 +342,5 @@ reallyDelete d = H.div {className: "panel-footer"}
]
......@@ -223,8 +223,6 @@ fldr _ true = "fa fa-folder-o"
{-
------------------------------------------------------------
instance ordNodeType :: Ord NodeType where
......
......@@ -57,3 +57,5 @@ glyphicon t = "btn glyphitem glyphicon glyphicon-" <> t
glyphiconActive :: String -> Boolean -> String
glyphiconActive icon b = glyphicon icon <> if b then " active" else ""
......@@ -5,8 +5,8 @@
<title>CNRS GarganText</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--<link href="https://use.fontawesome.com/releases/v5.0.8/styles/all.css" rel="stylesheet">-->
<!--<link rel="stylesheet" href="icons/fork-awesome/css/fork-awesome.css">-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fork-awesome@1.1.7/css/fork-awesome.min.css" integrity="sha256-gsmEoJAws/Kd3CjuOQzLie5Q3yshhvmo7YNtBG7aaEY=" crossorigin="anonymous">
<link rel="stylesheet" href="icons/fork-awesome/css/fork-awesome.css">
<!--<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fork-awesome@1.1.7/css/fork-awesome.min.css" integrity="sha256-gsmEoJAws/Kd3CjuOQzLie5Q3yshhvmo7YNtBG7aaEY=" crossorigin="anonymous">-->
<link href="styles/login.min.css" rel="stylesheet">
<link href="styles/bootstrap.min.css" rel="stylesheet">
<!-- <link href="styles/lavish-bootstrap.css" rel="stylesheet"> -->
......
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