Commit 9f93eb2b authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[forest] refactor node popup view

parent 1aaa37f8
...@@ -22,6 +22,7 @@ data NodeAction = Documentation NodeType ...@@ -22,6 +22,7 @@ data NodeAction = Documentation NodeType
| Move | Clone | Delete | Move | Clone | Delete
| Share | Link NodeType | Share | Link NodeType
| Add (Array NodeType) | Add (Array NodeType)
| CopyFromCorpus
instance eqNodeAction :: Eq NodeAction where instance eqNodeAction :: Eq NodeAction where
...@@ -36,6 +37,7 @@ instance eqNodeAction :: Eq NodeAction where ...@@ -36,6 +37,7 @@ instance eqNodeAction :: Eq NodeAction where
eq Share Share = true eq Share Share = true
eq (Link x) (Link y) = true && (x == y) eq (Link x) (Link y) = true && (x == y)
eq (Add x) (Add y) = true && (x == y) eq (Add x) (Add y) = true && (x == y)
eq CopyFromCorpus CopyFromCorpus = true
eq _ _ = false eq _ _ = false
instance showNodeAction :: Show NodeAction where instance showNodeAction :: Show NodeAction where
...@@ -50,6 +52,7 @@ instance showNodeAction :: Show NodeAction where ...@@ -50,6 +52,7 @@ instance showNodeAction :: Show NodeAction where
show Share = "Share" show Share = "Share"
show (Link x) = "Link to " <> show x show (Link x) = "Link to " <> show x
show (Add xs) = foldl (\a b -> a <> show b) "Add " xs show (Add xs) = foldl (\a b -> a <> show b) "Add " xs
show CopyFromCorpus = "Copy from corpus"
glyphiconNodeAction :: NodeAction -> String glyphiconNodeAction :: NodeAction -> String
...@@ -60,6 +63,7 @@ glyphiconNodeAction SearchBox = "search" ...@@ -60,6 +63,7 @@ glyphiconNodeAction SearchBox = "search"
glyphiconNodeAction Upload = "upload" glyphiconNodeAction Upload = "upload"
glyphiconNodeAction (Link _) = "transfer" glyphiconNodeAction (Link _) = "transfer"
glyphiconNodeAction Download = "download" glyphiconNodeAction Download = "download"
glyphiconNodeAction CopyFromCorpus = "random"
glyphiconNodeAction _ = "" glyphiconNodeAction _ = ""
...@@ -183,6 +187,7 @@ settingsBox NodeList = SettingsBox { ...@@ -183,6 +187,7 @@ settingsBox NodeList = SettingsBox {
, edit : false , edit : false
, doc : Documentation NodeList , doc : Documentation NodeList
, buttons : [ Upload , buttons : [ Upload
, CopyFromCorpus
, Download , Download
, Delete , Delete
] ]
......
...@@ -33,7 +33,7 @@ uploadFileView :: (Action -> Aff Unit) -> Record Props -> R.Element ...@@ -33,7 +33,7 @@ uploadFileView :: (Action -> Aff Unit) -> Record Props -> R.Element
uploadFileView d props = R.createElement (uploadFileViewCpt d) props [] uploadFileView d props = R.createElement (uploadFileViewCpt d) props []
uploadFileViewCpt :: (Action -> Aff Unit) -> R.Component Props uploadFileViewCpt :: (Action -> Aff Unit) -> R.Component Props
uploadFileViewCpt d = R.hooksComponent "UploadFileView" cpt uploadFileViewCpt d = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
where where
cpt {id, nodeType} _ = do cpt {id, nodeType} _ = do
mContents :: R.State (Maybe UploadFileContents) <- R.useState' Nothing mContents :: R.State (Maybe UploadFileContents) <- R.useState' Nothing
...@@ -234,3 +234,12 @@ uploadFile session nodeType id fileType (UploadFileContents fileContents) = do ...@@ -234,3 +234,12 @@ uploadFile session nodeType id fileType (UploadFileContents fileContents) = do
Tuple "_wf_data" (Just fileContents) Tuple "_wf_data" (Just fileContents)
, Tuple "_wf_filetype" (Just $ show fileType) , Tuple "_wf_filetype" (Just $ show fileType)
] ]
uploadTermListView :: (Action -> Aff Unit) -> Record Props -> R.Element
uploadTermListView d props = R.createElement (uploadFileViewCpt d) props []
uploadTermListViewCpt :: (Action -> Aff Unit) -> R.Component Props
uploadTermListViewCpt d = R.hooksComponent "G.C.F.T.N.A.U.UploadTermListView" cpt
where
cpt {id, nodeType} _ = do
pure $ H.div {} [ H.text "Upload term list" ]
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