Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
9e975cf6
Commit
9e975cf6
authored
Mar 13, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tree] popover close works now
parent
66ad76db
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
15 deletions
+45
-15
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+21
-15
Popover.js
src/Gargantext/Utils/Popover.js
+3
-0
Popover.purs
src/Gargantext/Utils/Popover.purs
+21
-0
No files found.
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
9e975cf6
...
...
@@ -3,14 +3,16 @@ module Gargantext.Components.Forest.Tree.Node.Box where
import Gargantext.Prelude
import Data.Maybe (Maybe(..))
import Data.Nullable (null)
import Data.Nullable (null
, toMaybe
)
import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple.Nested ((/\))
import DOM.Simple as DOM
import DOM.Simple.Console (log2)
import Effect (Effect)
import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
import Effect.Uncurried (mkEffectFn1)
import FFI.Simple ((..))
import React.SyntheticEvent as E
import Reactix as R
import Reactix.DOM.HTML as H
...
...
@@ -69,9 +71,8 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
-- only 1 popup at a time is allowed to be opened
droppedFile <- R.useState' (Nothing :: Maybe DroppedFile)
isDragOver <- R.useState' false
popoverOpen <- R.useState' false
pop
p
erRef <- R.useRef null
pop
ov
erRef <- R.useRef null
pure $ H.span (dropProps droppedFile isDragOver) $
[ folderIcon nodeType folderOpen
...
...
@@ -83,12 +84,15 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
}
[ nodeText { isSelected: (mCorpusId mCurrentRoute) == (Just id)
, name: name' props} ]
, Popover.popover { open: fst popoverOpen
, onClose: \_ -> snd popoverOpen $ const false
, onOpen: \_ -> snd popoverOpen $ const true } [
popOverIcon true
, mNodePopupView props showBox
, if showBox then
Popover.popover { open: false
, onClose: \_ -> pure unit
, onOpen: \_ -> pure unit
, ref: popoverRef } [
popOverIcon
, mNodePopupView props (onPopoverClose popoverRef)
]
else H.div {} []
, fileTypeView {dispatch, droppedFile, id, isDragOver, nodeType}
, H.div {} (map (\t -> asyncProgressBar { asyncTask: t
, corpusId: id
...
...
@@ -97,6 +101,8 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
]
where
SettingsBox {show: showBox} = settingsBox nodeType
onPopoverClose popoverRef _ = do
Popover.setOpen popoverRef false
name' {name, nodeType} = if nodeType == GT.NodeUser then show session else name
...
...
@@ -104,18 +110,17 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
H.a {onClick: R2.effToggler folderOpen'}
[ H.i {className: GT.fldr nodeType open} [] ]
popOverIcon false = H.div {} []
popOverIcon true =
popOverIcon =
H.a { className: "glyphicon glyphicon-cog"
, id: "rename-leaf"
} []
mNodePopupView _ false = H.div {} []
mNodePopupView props@{asyncTasks, id, nodeType} true =
mNodePopupView props@{asyncTasks, id, nodeType} onPopoverClose =
nodePopupView { id
, dispatch
, name: name' props
, nodeType
, onPopoverClose
, session
}
...
...
@@ -190,6 +195,7 @@ type NodePopupProps =
( id :: ID
, name :: Name
, nodeType :: GT.NodeType
, onPopoverClose :: DOM.Element -> Effect Unit
| CommonProps
)
...
...
@@ -260,6 +266,7 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
, H.div {className: "col-md-1"}
[ H.a { "type" : "button"
, className: glyphicon "remove-circle"
, on: { click: \e -> p.onPopoverClose $ R2.unsafeEventTarget e }
, title : "Close"} []
]
]
...
...
@@ -274,8 +281,7 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
[ H.a { className: glyphicon "pencil"
, id : "rename1"
, title : "Rename"
, onClick : mkEffectFn1
$ \_ -> setRenameBoxOpen $ const true
, on: { click: \_ -> setRenameBoxOpen $ const true }
}
[]
]
...
...
src/Gargantext/Utils/Popover.js
View file @
9e975cf6
...
...
@@ -7,3 +7,6 @@ if (typeof window !== 'undefined') {
}
exports
.
popoverCpt
=
popover
;
exports
.
_setState
=
function
(
el
,
open
)
{
el
.
setState
({
open
:
open
});
}
src/Gargantext/Utils/Popover.purs
View file @
9e975cf6
module Gargantext.Utils.Popover where
import Data.Maybe (Maybe(..))
import Data.Nullable (Nullable, toMaybe)
import DOM.Simple as DOM
import DOM.Simple.Console (log2)
import Effect (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2)
import FFI.Simple ((..), (...))
import Reactix as R
import Gargantext.Prelude
type PopoverRef = R.Ref (Nullable DOM.Element)
type Props =
(
open :: Boolean
, onClose :: Unit -> Effect Unit
, onOpen :: Unit -> Effect Unit
, ref :: PopoverRef
)
foreign import popoverCpt :: R.Component Props
popover :: Record Props -> Array R.Element -> R.Element
popover = R.rawCreateElement popoverCpt
foreign import _setState :: EffectFn2 DOM.Element Boolean Unit
setState :: DOM.Element -> Boolean -> Effect Unit
setState = runEffectFn2 _setState
setOpen :: PopoverRef -> Boolean -> Effect Unit
setOpen ref val =
case toMaybe $ R.readRef ref of
Nothing -> pure unit
Just p -> do
setState p val
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment