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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
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
...
@@ -3,14 +3,16 @@ module Gargantext.Components.Forest.Tree.Node.Box where
import Gargantext.Prelude
import Gargantext.Prelude
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Nullable (null)
import Data.Nullable (null
, toMaybe
)
import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import DOM.Simple as DOM
import DOM.Simple.Console (log2)
import DOM.Simple.Console (log2)
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (Aff, launchAff)
import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect.Uncurried (mkEffectFn1)
import Effect.Uncurried (mkEffectFn1)
import FFI.Simple ((..))
import React.SyntheticEvent as E
import React.SyntheticEvent as E
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
...
@@ -69,9 +71,8 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
...
@@ -69,9 +71,8 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
-- only 1 popup at a time is allowed to be opened
-- only 1 popup at a time is allowed to be opened
droppedFile <- R.useState' (Nothing :: Maybe DroppedFile)
droppedFile <- R.useState' (Nothing :: Maybe DroppedFile)
isDragOver <- R.useState' false
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) $
pure $ H.span (dropProps droppedFile isDragOver) $
[ folderIcon nodeType folderOpen
[ folderIcon nodeType folderOpen
...
@@ -83,12 +84,15 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
...
@@ -83,12 +84,15 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
}
}
[ nodeText { isSelected: (mCorpusId mCurrentRoute) == (Just id)
[ nodeText { isSelected: (mCorpusId mCurrentRoute) == (Just id)
, name: name' props} ]
, name: name' props} ]
, Popover.popover { open: fst popoverOpen
, if showBox then
, onClose: \_ -> snd popoverOpen $ const false
Popover.popover { open: false
, onOpen: \_ -> snd popoverOpen $ const true } [
, onClose: \_ -> pure unit
popOverIcon true
, onOpen: \_ -> pure unit
, mNodePopupView props showBox
, ref: popoverRef } [
popOverIcon
, mNodePopupView props (onPopoverClose popoverRef)
]
]
else H.div {} []
, fileTypeView {dispatch, droppedFile, id, isDragOver, nodeType}
, fileTypeView {dispatch, droppedFile, id, isDragOver, nodeType}
, H.div {} (map (\t -> asyncProgressBar { asyncTask: t
, H.div {} (map (\t -> asyncProgressBar { asyncTask: t
, corpusId: id
, corpusId: id
...
@@ -97,6 +101,8 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
...
@@ -97,6 +101,8 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
]
]
where
where
SettingsBox {show: showBox} = settingsBox nodeType
SettingsBox {show: showBox} = settingsBox nodeType
onPopoverClose popoverRef _ = do
Popover.setOpen popoverRef false
name' {name, nodeType} = if nodeType == GT.NodeUser then show session else name
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
...
@@ -104,18 +110,17 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
H.a {onClick: R2.effToggler folderOpen'}
H.a {onClick: R2.effToggler folderOpen'}
[ H.i {className: GT.fldr nodeType open} [] ]
[ H.i {className: GT.fldr nodeType open} [] ]
popOverIcon false = H.div {} []
popOverIcon =
popOverIcon true =
H.a { className: "glyphicon glyphicon-cog"
H.a { className: "glyphicon glyphicon-cog"
, id: "rename-leaf"
, id: "rename-leaf"
} []
} []
mNodePopupView _ false = H.div {} []
mNodePopupView props@{asyncTasks, id, nodeType} onPopoverClose =
mNodePopupView props@{asyncTasks, id, nodeType} true =
nodePopupView { id
nodePopupView { id
, dispatch
, dispatch
, name: name' props
, name: name' props
, nodeType
, nodeType
, onPopoverClose
, session
, session
}
}
...
@@ -190,6 +195,7 @@ type NodePopupProps =
...
@@ -190,6 +195,7 @@ type NodePopupProps =
( id :: ID
( id :: ID
, name :: Name
, name :: Name
, nodeType :: GT.NodeType
, nodeType :: GT.NodeType
, onPopoverClose :: DOM.Element -> Effect Unit
| CommonProps
| CommonProps
)
)
...
@@ -260,6 +266,7 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
...
@@ -260,6 +266,7 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
, H.div {className: "col-md-1"}
, H.div {className: "col-md-1"}
[ H.a { "type" : "button"
[ H.a { "type" : "button"
, className: glyphicon "remove-circle"
, className: glyphicon "remove-circle"
, on: { click: \e -> p.onPopoverClose $ R2.unsafeEventTarget e }
, title : "Close"} []
, title : "Close"} []
]
]
]
]
...
@@ -274,8 +281,7 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
...
@@ -274,8 +281,7 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
[ H.a { className: glyphicon "pencil"
[ H.a { className: glyphicon "pencil"
, id : "rename1"
, id : "rename1"
, title : "Rename"
, title : "Rename"
, onClick : mkEffectFn1
, on: { click: \_ -> setRenameBoxOpen $ const true }
$ \_ -> setRenameBoxOpen $ const true
}
}
[]
[]
]
]
...
...
src/Gargantext/Utils/Popover.js
View file @
9e975cf6
...
@@ -7,3 +7,6 @@ if (typeof window !== 'undefined') {
...
@@ -7,3 +7,6 @@ if (typeof window !== 'undefined') {
}
}
exports
.
popoverCpt
=
popover
;
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
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 (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2)
import FFI.Simple ((..), (...))
import Reactix as R
import Reactix as R
import Gargantext.Prelude
import Gargantext.Prelude
type PopoverRef = R.Ref (Nullable DOM.Element)
type Props =
type Props =
(
(
open :: Boolean
open :: Boolean
, onClose :: Unit -> Effect Unit
, onClose :: Unit -> Effect Unit
, onOpen :: Unit -> Effect Unit
, onOpen :: Unit -> Effect Unit
, ref :: PopoverRef
)
)
foreign import popoverCpt :: R.Component Props
foreign import popoverCpt :: R.Component Props
popover :: Record Props -> Array R.Element -> R.Element
popover :: Record Props -> Array R.Element -> R.Element
popover = R.rawCreateElement popoverCpt
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