Commit 0add6647 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Tree] file-dropped style to highlight the folder

parent 37febcb1
...@@ -204,6 +204,9 @@ text-align: center; ...@@ -204,6 +204,9 @@ text-align: center;
.tree { .tree {
margin-top: 10px; margin-top: 10px;
} }
.tree .file-dropped {
background-color: aliceblue;
}
#graph-tree .tree { #graph-tree .tree {
margin-top: 27px; margin-top: 27px;
} }
......
...@@ -538,26 +538,28 @@ toHtml d s@(NTree (LNode {id, name, nodeType}) ary) n = R.createElement el {} [] ...@@ -538,26 +538,28 @@ toHtml d s@(NTree (LNode {id, name, nodeType}) ary) n = R.createElement el {} []
folderIcon folderOpen@(open /\ _) = folderIcon folderOpen@(open /\ _) =
H.a {onClick: R2.effToggler folderOpen} H.a {onClick: R2.effToggler folderOpen}
[ H.i {className: fldr open} [] ] [ H.i {className: fldr open} [] ]
dropProps (_ /\ setDroppedFile) = { dropProps (droppedFile /\ setDroppedFile) = {
onDrop: dropHandler className: dropClass droppedFile
, onDrop: dropHandler setDroppedFile
, onDragOver: onDragOverHandler , onDragOver: onDragOverHandler
} }
where dropClass (Just _) = "file-dropped"
dropHandler = mkEffectFn1 $ \e -> unsafePartial $ do dropClass Nothing = ""
let ff = fromJust $ item 0 $ ((e .. "dataTransfer" .. "files") :: FileList) dropHandler setDroppedFile = mkEffectFn1 $ \e -> unsafePartial $ do
liftEffect $ log2 "drop:" ff let ff = fromJust $ item 0 $ ((e .. "dataTransfer" .. "files") :: FileList)
-- prevent redirection when file is dropped liftEffect $ log2 "drop:" ff
E.preventDefault e -- prevent redirection when file is dropped
E.stopPropagation e E.preventDefault e
let blob = toBlob $ ff E.stopPropagation e
void $ runAff (\_ -> pure unit) do let blob = toBlob $ ff
contents <- readAsText blob void $ runAff (\_ -> pure unit) do
liftEffect $ setDroppedFile $ Just $ DroppedFile {contents: (UploadFileContents contents), fileType: Just CSV} contents <- readAsText blob
onDragOverHandler = mkEffectFn1 $ \e -> do liftEffect $ setDroppedFile $ Just $ DroppedFile {contents: (UploadFileContents contents), fileType: Just CSV}
-- prevent redirection when file is dropped onDragOverHandler = mkEffectFn1 $ \e -> do
-- https://stackoverflow.com/a/6756680/941471 -- prevent redirection when file is dropped
E.preventDefault e -- https://stackoverflow.com/a/6756680/941471
E.stopPropagation e E.preventDefault e
E.stopPropagation e
childNodes :: forall s. (Action -> Effect Unit) -> Maybe ID -> (Array (NTree LNode)) -> Tuple Boolean (Boolean -> Effect s) -> Array R.Element childNodes :: forall s. (Action -> Effect Unit) -> Maybe ID -> (Array (NTree LNode)) -> Tuple Boolean (Boolean -> Effect s) -> Array R.Element
......
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