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
e8976359
Commit
e8976359
authored
Aug 11, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev-file-upload
parents
6cd7a7d5
c48c056e
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
182 additions
and
67 deletions
+182
-67
Forest.purs
src/Gargantext/Components/Forest.purs
+2
-1
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+20
-4
Node.purs
src/Gargantext/Components/Forest/Tree/Node.purs
+9
-3
Add.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
+1
-1
Status.purs
src/Gargantext/Components/Forest/Tree/Node/Status.purs
+0
-1
Tools.purs
src/Gargantext/Components/Forest/Tree/Node/Tools.purs
+39
-31
InputWithEnter.purs
src/Gargantext/Components/InputWithEnter.purs
+49
-0
Contacts.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contacts.purs
+23
-17
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+16
-8
Types.purs
src/Gargantext/Types.purs
+11
-0
Reactix.js
src/Gargantext/Utils/Reactix.js
+5
-0
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+7
-1
No files found.
src/Gargantext/Components/Forest.purs
View file @
e8976359
...
@@ -15,7 +15,7 @@ import Gargantext.Components.Forest.Tree (treeView)
...
@@ -15,7 +15,7 @@ import Gargantext.Components.Forest.Tree (treeView)
import Gargantext.Ends (Frontends)
import Gargantext.Ends (Frontends)
import Gargantext.Routes (AppRoute)
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session(..), Sessions, OpenNodes, unSessions)
import Gargantext.Sessions (Session(..), Sessions, OpenNodes, unSessions)
import Gargantext.Types (Reload)
import Gargantext.Types (Reload
, Handed(..)
)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
type Props =
type Props =
...
@@ -58,6 +58,7 @@ forestCpt = R.hooksComponent "G.C.Forest.forest" cpt where
...
@@ -58,6 +58,7 @@ forestCpt = R.hooksComponent "G.C.Forest.forest" cpt where
, openNodes
, openNodes
, reload
, reload
, session: s
, session: s
, handed: RightHanded -- TODO enabling user to change it and save locally
}
}
plus :: R2.Setter Boolean -> R.Element
plus :: R2.Setter Boolean -> R.Element
...
...
src/Gargantext/Components/Forest/Tree.purs
View file @
e8976359
...
@@ -31,7 +31,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTr
...
@@ -31,7 +31,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTr
import Gargantext.Components.Forest.Tree.Node.Tools.Task (Tasks, tasksStruct)
import Gargantext.Components.Forest.Tree.Node.Tools.Task (Tasks, tasksStruct)
import Gargantext.Ends (Frontends)
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>))
import Gargantext.Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>)
, (==)
)
import Gargantext.Routes (AppRoute)
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (OpenNodes, Session, mkNodeId, get)
import Gargantext.Sessions (OpenNodes, Session, mkNodeId, get)
import Gargantext.Types (ID, Reload, isPublic, publicize)
import Gargantext.Types (ID, Reload, isPublic, publicize)
...
@@ -45,6 +45,7 @@ type CommonProps =
...
@@ -45,6 +45,7 @@ type CommonProps =
, openNodes :: R.State OpenNodes
, openNodes :: R.State OpenNodes
, reload :: R.State Reload
, reload :: R.State Reload
, session :: Session
, session :: Session
, handed :: GT.Handed
)
)
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -66,6 +67,7 @@ treeView props = R.createElement treeViewCpt props []
...
@@ -66,6 +67,7 @@ treeView props = R.createElement treeViewCpt props []
, openNodes
, openNodes
, reload
, reload
, session
, session
, handed
} _children = pure
} _children = pure
$ treeLoadView { root
$ treeLoadView { root
, asyncTasks
, asyncTasks
...
@@ -74,6 +76,7 @@ treeView props = R.createElement treeViewCpt props []
...
@@ -74,6 +76,7 @@ treeView props = R.createElement treeViewCpt props []
, openNodes
, openNodes
, reload
, reload
, session
, session
, handed
}
}
treeLoadView :: Record Props -> R.Element
treeLoadView :: Record Props -> R.Element
...
@@ -89,6 +92,7 @@ treeLoadView p = R.createElement treeLoadViewCpt p []
...
@@ -89,6 +92,7 @@ treeLoadView p = R.createElement treeLoadViewCpt p []
, openNodes
, openNodes
, reload
, reload
, session
, session
, handed
} _children = do
} _children = do
let fetch _ = getNodeTree session root
let fetch _ = getNodeTree session root
let paint loaded = loadedTreeView { asyncTasks
let paint loaded = loadedTreeView { asyncTasks
...
@@ -99,6 +103,7 @@ treeLoadView p = R.createElement treeLoadViewCpt p []
...
@@ -99,6 +103,7 @@ treeLoadView p = R.createElement treeLoadViewCpt p []
, session
, session
, tasks: tasksStruct root asyncTasks reload
, tasks: tasksStruct root asyncTasks reload
, tree: loaded
, tree: loaded
, handed
}
}
useLoader { root, counter: fst reload } fetch paint
useLoader { root, counter: fst reload } fetch paint
...
@@ -127,7 +132,11 @@ loadedTreeView p = R.createElement loadedTreeViewCpt p []
...
@@ -127,7 +132,11 @@ loadedTreeView p = R.createElement loadedTreeViewCpt p []
, session
, session
, tasks
, tasks
, tree
, tree
} _ = pure $ H.ul { className: "tree"}
, handed
} _ = pure $ H.ul { className: "tree " <> if handed == GT.RightHanded
then "flex-start"
else "flex-end"
}
[ toHtml { asyncTasks
[ toHtml { asyncTasks
, frontends
, frontends
, mCurrentRoute
, mCurrentRoute
...
@@ -136,10 +145,13 @@ loadedTreeView p = R.createElement loadedTreeViewCpt p []
...
@@ -136,10 +145,13 @@ loadedTreeView p = R.createElement loadedTreeViewCpt p []
, session
, session
, tasks
, tasks
, tree
, tree
, handed: GT.RightHanded -- TODO enabling user to change it
}
}
]
]
------------------------------------------------------------------------
------------------------------------------------------------------------
type ToHtmlProps =
type ToHtmlProps =
( asyncTasks :: R.State GAT.Storage
( asyncTasks :: R.State GAT.Storage
, tasks :: Record Tasks
, tasks :: Record Tasks
...
@@ -164,6 +176,7 @@ toHtml p@{ asyncTasks
...
@@ -164,6 +176,7 @@ toHtml p@{ asyncTasks
}
}
) ary
) ary
)
)
, handed
} =
} =
R.createElement el {} []
R.createElement el {} []
where
where
...
@@ -190,6 +203,7 @@ toHtml p@{ asyncTasks
...
@@ -190,6 +203,7 @@ toHtml p@{ asyncTasks
, nodeType
, nodeType
, session
, session
, tasks
, tasks
, handed
} ]
} ]
<> childNodes ( Record.merge commonProps
<> childNodes ( Record.merge commonProps
{ asyncTasks
{ asyncTasks
...
@@ -199,6 +213,7 @@ toHtml p@{ asyncTasks
...
@@ -199,6 +213,7 @@ toHtml p@{ asyncTasks
) t) ary
) t) ary
else ary
else ary
, folderOpen
, folderOpen
, handed
}
}
)
)
...
@@ -212,11 +227,12 @@ type ChildNodesProps =
...
@@ -212,11 +227,12 @@ type ChildNodesProps =
childNodes :: Record ChildNodesProps -> Array R.Element
childNodes :: Record ChildNodesProps -> Array R.Element
childNodes { children: [] } = []
childNodes { children: [] } = []
childNodes { folderOpen: (false /\ _) } = []
childNodes { folderOpen: (false /\ _) } = []
childNodes props@{ asyncTasks, children, reload } =
childNodes props@{ asyncTasks, children, reload
, handed
} =
map (\ctree@(NTree (LNode {id}) _) -> H.ul {} [
map (\ctree@(NTree (LNode {id}) _) -> H.ul {} [
toHtml (Record.merge commonProps { asyncTasks
toHtml (Record.merge commonProps { asyncTasks
, tasks: tasksStruct id asyncTasks reload
, tasks: tasksStruct id asyncTasks reload
, tree: ctree
, tree: ctree
, handed
}
}
)]
)]
) $ sorted children
) $ sorted children
...
...
src/Gargantext/Components/Forest/Tree/Node.purs
View file @
e8976359
module Gargantext.Components.Forest.Tree.Node where
module Gargantext.Components.Forest.Tree.Node where
import Data.Array (reverse)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Nullable (null)
import Data.Nullable (null)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
...
@@ -25,7 +26,7 @@ import Gargantext.Components.Lang (Lang(EN))
...
@@ -25,7 +26,7 @@ import Gargantext.Components.Lang (Lang(EN))
import Gargantext.Components.Nodes.Corpus (loadCorpusWithChild)
import Gargantext.Components.Nodes.Corpus (loadCorpusWithChild)
import Gargantext.Ends (Frontends, url)
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, const, discard, map, pure, show, unit, void, ($), (<>), (==))
import Gargantext.Prelude (Unit, bind, const, discard, map, pure, show, unit, void, ($), (<>), (==)
, identity
)
import Gargantext.Routes as Routes
import Gargantext.Routes as Routes
import Gargantext.Version as GV
import Gargantext.Version as GV
import Gargantext.Sessions (Session, sessionId)
import Gargantext.Sessions (Session, sessionId)
...
@@ -44,12 +45,13 @@ type NodeMainSpanProps =
...
@@ -44,12 +45,13 @@ type NodeMainSpanProps =
, name :: Name
, name :: Name
, nodeType :: GT.NodeType
, nodeType :: GT.NodeType
, tasks :: Record Tasks
, tasks :: Record Tasks
, handed :: GT.Handed
| CommonProps
| CommonProps
)
)
nodeMainSpan :: Record NodeMainSpanProps
nodeMainSpan :: Record NodeMainSpanProps
-> R.Element
-> R.Element
nodeMainSpan p@{ dispatch, folderOpen, frontends, session
} = R.createElement el p []
nodeMainSpan p@{ dispatch, folderOpen, frontends, session
, handed
} = R.createElement el p []
where
where
el = R.hooksComponent "G.C.F.T.N.NodeMainSpan" cpt
el = R.hooksComponent "G.C.F.T.N.NodeMainSpan" cpt
cpt props@{id, mCurrentRoute, name, nodeType, tasks: { onTaskFinish, tasks }} _ = do
cpt props@{id, mCurrentRoute, name, nodeType, tasks: { onTaskFinish, tasks }} _ = do
...
@@ -59,7 +61,11 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
...
@@ -59,7 +61,11 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
popoverRef <- R.useRef null
popoverRef <- R.useRef null
pure $ H.span (dropProps droppedFile isDragOver) $
pure $ H.span (dropProps droppedFile isDragOver)
$ (if handed == GT.LeftHanded
then reverse
else identity)
$
[ chevronIcon nodeType folderOpen
[ chevronIcon nodeType folderOpen
, folderIcon nodeType folderOpen
, folderIcon nodeType folderOpen
, if showBox then
, if showBox then
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
View file @
e8976359
...
@@ -76,7 +76,7 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
...
@@ -76,7 +76,7 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
where
where
defaultNt = (fromMaybe Error $ head nodeTypes)
defaultNt = (fromMaybe Error $ head nodeTypes)
maybeEdit = [ if edit
maybeEdit = [ if edit
then formEdit
"Node Name"
setNodeName
then formEdit
name'
setNodeName
else H.div {} []
else H.div {} []
]
]
...
...
src/Gargantext/Components/Forest/Tree/Node/Status.purs
View file @
e8976359
...
@@ -11,7 +11,6 @@ hasStatus :: NodeType -> NodeAction -> Status
...
@@ -11,7 +11,6 @@ hasStatus :: NodeType -> NodeAction -> Status
hasStatus _ SearchBox = Test
hasStatus _ SearchBox = Test
hasStatus _ Refresh = Dev
hasStatus _ Refresh = Dev
hasStatus _ Config = Dev
hasStatus _ Config = Dev
hasStatus _ (Link _) = Dev
hasStatus _ (Merge _) = Dev
hasStatus _ (Merge _) = Dev
hasStatus _ (Documentation _) = Dev
hasStatus _ (Documentation _) = Dev
hasStatus Annuaire Upload = Dev
hasStatus Annuaire Upload = Dev
...
...
src/Gargantext/Components/Forest/Tree/Node/Tools.purs
View file @
e8976359
...
@@ -6,17 +6,17 @@ import Data.Set (Set)
...
@@ -6,17 +6,17 @@ import Data.Set (Set)
import Data.Set as Set
import Data.Set as Set
import Data.String as S
import Data.String as S
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Gargantext.Types (Name)
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (Aff, launchAff)
import Effect.Aff (Aff, launchAff, launchAff_)
import Effect.Uncurried (mkEffectFn1)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Prelude (Unit, bind, const, discard, pure, show, ($), (<<<), (<>), read, map, class Read, class Show, not, class Ord)
import Gargantext.Prelude (Unit, bind, const, discard, pure, show, ($), (<<<), (<>), read, map, class Read, class Show, not, class Ord)
import Gargantext.Types (ID)
import Gargantext.Types (ID
, Name
)
import Gargantext.Utils (toggleSet)
import Gargantext.Utils (toggleSet)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -67,31 +67,42 @@ textInputBox p@{ boxName, boxAction, dispatch, isOpen: (true /\ setIsOpen) } = R
...
@@ -67,31 +67,42 @@ textInputBox p@{ boxName, boxAction, dispatch, isOpen: (true /\ setIsOpen) } = R
, cancelBtn
, cancelBtn
]
]
where
where
textInput (
_ /\ setRenameNode
Name) =
textInput (
newName /\ setNew
Name) =
H.div {className: "col-md-8"}
H.div {className: "col-md-8"}
[ H.input { type: "text"
[
, placeholder: (boxName <> " Node")
inputWithEnter {
, defaultValue: text
onEnter: submit newName
, onValueChanged: setNewName <<< const
, autoFocus: false
, className: "form-control"
, className: "form-control"
, onInput: mkEffectFn1 $ setRenameNodeName
, defaultValue: text
<<< const
, placeholder: (boxName <> " Node")
<<< R2.unsafeEventValue
, type: "text"
}
}
-- [ H.input { type: "text"
-- , placeholder: (boxName <> " Node")
-- , defaultValue: text
-- , className: "form-control"
-- , on: { input: setRenameNodeName
-- <<< const
-- <<< R2.unsafeEventValue }
-- }
]
]
submitBtn (newName /\ _) =
submitBtn (newName /\ _) =
H.a {className: "btn glyphitem glyphicon glyphicon-ok col-md-2 pull-left"
H.a {className: "btn glyphitem glyphicon glyphicon-ok col-md-2 pull-left"
, type: "button"
, type: "button"
, onClick: mkEffectFn1 $ \_ -> do
, on: { click: submit newName }
setIsOpen $ const false
launchAff $ dispatch ( boxAction newName )
, title: "Submit"
, title: "Submit"
} []
} []
cancelBtn =
cancelBtn =
H.a {className: "btn text-danger glyphitem glyphicon glyphicon-remove col-md-2 pull-left"
H.a {className: "btn text-danger glyphitem glyphicon glyphicon-remove col-md-2 pull-left"
, type: "button"
, type: "button"
, on
Click: mkEffectFn1 $ \_ -> setIsOpen $ const false
, on
: { click: \_ -> setIsOpen $ const false }
, title: "Cancel"
, title: "Cancel"
} []
} []
submit newName _ = do
setIsOpen $ const false
launchAff_ $ dispatch ( boxAction newName )
textInputBox p@{ boxName, isOpen: (false /\ _) } = R.createElement el p []
textInputBox p@{ boxName, isOpen: (false /\ _) } = R.createElement el p []
where
where
el = R.hooksComponent (boxName <> "Box") cpt
el = R.hooksComponent (boxName <> "Box") cpt
...
@@ -119,10 +130,9 @@ formEdit defaultValue setter =
...
@@ -119,10 +130,9 @@ formEdit defaultValue setter =
, placeholder : defaultValue
, placeholder : defaultValue
, defaultValue: "Write" <> defaultValue
, defaultValue: "Write" <> defaultValue
, className : "form-control"
, className : "form-control"
, onInput : mkEffectFn1
, on: { input: setter
$ setter
<<< const
<<< const
<<< R2.unsafeEventValue
<<< R2.unsafeEventValue }
}
}
]
]
...
@@ -154,12 +164,11 @@ formChoice :: forall a b c d
...
@@ -154,12 +164,11 @@ formChoice :: forall a b c d
formChoice nodeTypes defaultNodeType setNodeType =
formChoice nodeTypes defaultNodeType setNodeType =
H.div { className: "form-group"}
H.div { className: "form-group"}
[ R2.select { className: "form-control"
[ R2.select { className: "form-control"
, onChange : mkEffectFn1
, on: { change: \_ -> setNodeType
$ setNodeType
<<< const
<<< const
<<< fromMaybe defaultNodeType
<<< fromMaybe defaultNodeType
<<< read
<<< read
<<< R2.unsafeEventValue
<<< R2.unsafeEventValue }
}
}
(map (\opt -> H.option {} [ H.text $ show opt ]) nodeTypes)
(map (\opt -> H.option {} [ H.text $ show opt ]) nodeTypes)
]
]
...
@@ -180,8 +189,7 @@ formButton nodeType setNodeType =
...
@@ -180,8 +189,7 @@ formButton nodeType setNodeType =
, type : "button"
, type : "button"
, title: "Form Button"
, title: "Form Button"
, style : { width: "100%" }
, style : { width: "100%" }
, onClick : mkEffectFn1
, on: { click: \_ -> setNodeType ( const nodeType ) }
$ \_ -> setNodeType ( const nodeType )
} [H.text $ "Confirmation"]
} [H.text $ "Confirmation"]
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
src/Gargantext/Components/InputWithEnter.purs
0 → 100644
View file @
e8976359
module Gargantext.Components.InputWithEnter where
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect (Effect)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Utils.Reactix as R2
type Props a = (
onEnter :: Unit -> Effect Unit
, onValueChanged :: String -> Effect Unit
, autoFocus :: Boolean
, className :: String
, defaultValue :: String
, placeholder :: String
, type :: String
)
inputWithEnter :: forall a. Record (Props a) -> R.Element
inputWithEnter props = R.createElement inputWithEnterCpt props []
inputWithEnterCpt :: forall a. R.Component (Props a)
inputWithEnterCpt = R.hooksComponent "G.C.IWE.inputWithEnter" cpt
where
cpt props@{ onEnter, onValueChanged
, autoFocus, className, defaultValue, placeholder } _ = do
pure $ H.input { on: { input: onInput
, keyPress: onKeyPress }
, autoFocus
, className
, defaultValue
, placeholder
, type: props.type }
where
onInput e = do
onValueChanged $ R2.unsafeEventValue e
onKeyPress e = do
char <- R2.keyCode e
if char == 13 then
onEnter unit
else
pure unit
src/Gargantext/Components/Nodes/Annuaire/User/Contacts.purs
View file @
e8976359
...
@@ -12,18 +12,19 @@ import Data.Tuple.Nested ((/\))
...
@@ -12,18 +12,19 @@ import Data.Tuple.Nested ((/\))
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 Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
import Gargantext.Ends (Frontends)
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, const, discard, pure, show, unit, ($), (+), (<$>), (<<<), (<>), (==))
import Gargantext.Prelude (Unit, bind, const, discard, pure, show, unit, ($), (+), (<$>), (<<<), (<>), (==))
import Gargantext.Routes as Routes
import Gargantext.Routes as Routes
import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Types (NodeType(..))
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
display :: String -> Array R.Element -> R.Element
display :: String -> Array R.Element -> R.Element
display title elems =
display title elems =
...
@@ -54,16 +55,17 @@ contactInfos h onUpdateHyperdata = item <$> contactInfoItems
...
@@ -54,16 +55,17 @@ contactInfos h onUpdateHyperdata = item <$> contactInfoItems
contactInfoItems :: Array {label:: String, defaultVal:: String, lens:: HyperdataUserLens}
contactInfoItems :: Array {label:: String, defaultVal:: String, lens:: HyperdataUserLens}
contactInfoItems =
contactInfoItems =
[ {label: "Last Name"
, defaultVal: "Empty Last Name", lens: _shared <<< _who <<< _lastName
}
[ {label: "Last Name"
, defaultVal: "Empty Last Name" , lens: _shared <<< _who <<< _lastName
}
, {label: "First Name"
, defaultVal: "Empty First Name", lens: _shared <<< _who <<< _firstName
}
, {label: "First Name"
, defaultVal: "Empty First Name" , lens: _shared <<< _who <<< _firstName
}
, {label: "Organisation"
, defaultVal: "Empty Organisation"
, lens: _shared <<< _ouFirst <<< _organizationJoinComma}
, {label: "Organisation"
, defaultVal: "Empty Organisation"
, lens: _shared <<< _ouFirst <<< _organizationJoinComma}
, {label: "Lab/Team/Dept", defaultVal: "Empty Lab/Team/Dept", lens: _shared <<< _ouFirst <<< _labTeamDeptsJoinComma}
, {label: "Lab/Team/Dept", defaultVal: "Empty Lab/Team/Dept", lens: _shared <<< _ouFirst <<< _labTeamDeptsJoinComma}
, {label: "Office", defaultVal: "Empty Office", lens: _shared <<< _ouFirst <<< _office}
, {label: "Office" , defaultVal: "Empty Office" , lens: _shared <<< _ouFirst <<< _office }
, {label: "City", defaultVal: "Empty City", lens: _shared <<< _ouFirst <<< _city}
, {label: "City" , defaultVal: "Empty City" , lens: _shared <<< _ouFirst <<< _city }
, {label: "Country", defaultVal: "Empty Country", lens: _shared <<< _ouFirst <<< _country}
, {label: "Country" , defaultVal: "Empty Country" , lens: _shared <<< _ouFirst <<< _country }
, {label: "Role", defaultVal: "Empty Role", lens: _shared <<< _ouFirst <<< _role}
, {label: "Role" , defaultVal: "Empty Role" , lens: _shared <<< _ouFirst <<< _role }
, {label: "Phone", defaultVal: "Empty Phone", lens: _shared <<< _ouFirst <<< _touch <<< _phone}
, {label: "Phone" , defaultVal: "Empty Phone" , lens: _shared <<< _ouFirst <<< _touch <<< _phone }
, {label: "Mail", defaultVal: "Empty Mail", lens: _shared <<< _ouFirst <<< _touch <<< _mail} ]
, {label: "Mail" , defaultVal: "Empty Mail" , lens: _shared <<< _ouFirst <<< _touch <<< _mail }
]
type HyperdataUserLens = L.ALens' HyperdataUser String
type HyperdataUserLens = L.ALens' HyperdataUser String
...
@@ -109,11 +111,15 @@ contactInfoItemCpt = R.hooksComponent "G.C.N.A.U.C.contactInfoItem" cpt
...
@@ -109,11 +111,15 @@ contactInfoItemCpt = R.hooksComponent "G.C.N.A.U.C.contactInfoItem" cpt
onClick _ = setIsEditing $ const true
onClick _ = setIsEditing $ const true
item (true /\ setIsEditing) valueRef =
item (true /\ setIsEditing) valueRef =
H.span {} [
H.span {} [
H.input { autoFocus: true
inputWithEnter {
onEnter: onClick
, onValueChanged: R.setRef valueRef
, autoFocus: true
, className: "form-control"
, className: "form-control"
, defaultValue: R.readRef valueRef
, defaultValue: R.readRef valueRef
, on: {change: \e -> R.setRef valueRef $ R2.unsafeEventValue e}
, placeholder
, placeholder }
, type: "text"
}
, H.span { className: "fa fa-floppy-o"
, H.span { className: "fa fa-floppy-o"
, on: {click: onClick} } []
, on: {click: onClick} } []
]
]
...
...
src/Gargantext/Components/Nodes/Corpus.purs
View file @
e8976359
...
@@ -19,6 +19,7 @@ import Reactix.DOM.HTML as H
...
@@ -19,6 +19,7 @@ import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Components.CodeEditor as CE
import Gargantext.Components.CodeEditor as CE
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Node (NodePoly(..), HyperdataList)
import Gargantext.Components.Node (NodePoly(..), HyperdataList)
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, FTField, Field(..), FieldType(..), Hash, Hyperdata(..), defaultField, defaultHaskell', defaultPython', defaultJSON', defaultMarkdown')
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, FTField, Field(..), FieldType(..), Hash, Hyperdata(..), defaultField, defaultHaskell', defaultPython', defaultJSON', defaultMarkdown')
import Gargantext.Data.Array as GDA
import Gargantext.Data.Array as GDA
...
@@ -278,7 +279,7 @@ renameableCpt = R.hooksComponent "G.C.N.C.renameableCpt" cpt
...
@@ -278,7 +279,7 @@ renameableCpt = R.hooksComponent "G.C.N.C.renameableCpt" cpt
snd state $ const text
snd state $ const text
pure $ H.div { className: "renameable" } [
pure $ H.div { className: "renameable" } [
renameableText {
isEditing, onRename, state
}
renameableText {
isEditing, onRename, state
}
]
]
type RenameableTextProps =
type RenameableTextProps =
...
@@ -304,17 +305,24 @@ renameableTextCpt = R.hooksComponent "G.C.N.C.renameableTextCpt" cpt
...
@@ -304,17 +305,24 @@ renameableTextCpt = R.hooksComponent "G.C.N.C.renameableTextCpt" cpt
]
]
cpt {isEditing: (true /\ setIsEditing), onRename, state: (text /\ setText)} _ = do
cpt {isEditing: (true /\ setIsEditing), onRename, state: (text /\ setText)} _ = do
pure $ H.div {} [
pure $ H.div {} [
H.input { defaultValue: text
inputWithEnter {
onEnter: submit
, onValueChanged: setText <<< const
, autoFocus: false
, className: "form-control text"
, className: "form-control text"
, on: { change: \e -> setText $ const $ R2.unsafeEventValue e } }
, defaultValue: text
, placeholder: ""
, type: "text"
}
, H.span { className: "btn btn-default"
, H.span { className: "btn btn-default"
, on: { click: \_ -> do
, on: { click: submit } } [
setIsEditing $ const false
onRename text
} } [
H.span { className: "fa fa-floppy-o" } []
H.span { className: "fa fa-floppy-o" } []
]
]
]
]
where
submit _ = do
setIsEditing $ const false
onRename text
fieldCodeEditor :: Record FieldCodeEditorProps -> R.Element
fieldCodeEditor :: Record FieldCodeEditorProps -> R.Element
fieldCodeEditor props = R.createElement fieldCodeEditorCpt props []
fieldCodeEditor props = R.createElement fieldCodeEditorCpt props []
...
...
src/Gargantext/Types.purs
View file @
e8976359
...
@@ -15,6 +15,17 @@ import Prelude
...
@@ -15,6 +15,17 @@ import Prelude
import Prim.Row (class Union)
import Prim.Row (class Union)
import URI.Query (Query)
import URI.Query (Query)
data Handed = LeftHanded | RightHanded
derive instance genericHanded :: Generic Handed _
instance eqHanded :: Eq Handed where
eq = genericEq
-------------------------------------------------------------------------
type ID = Int
type ID = Int
type Name = String
type Name = String
type Reload = Int
type Reload = Int
...
...
src/Gargantext/Utils/Reactix.js
View file @
e8976359
...
@@ -28,3 +28,8 @@ exports._getSelection = getSelection;
...
@@ -28,3 +28,8 @@ exports._getSelection = getSelection;
exports
.
_stringify
=
stringify
;
exports
.
_stringify
=
stringify
;
exports
.
_postMessage
=
postMessage
;
exports
.
_postMessage
=
postMessage
;
exports
.
_setCookie
=
setCookie
;
exports
.
_setCookie
=
setCookie
;
exports
.
_keyCode
=
function
(
e
)
{
// https://www.w3schools.com/jsref/event_key_keycode.asp
return
e
.
which
||
e
.
keyCode
;
}
src/Gargantext/Utils/Reactix.purs
View file @
e8976359
...
@@ -112,11 +112,17 @@ menu :: ElemFactory
...
@@ -112,11 +112,17 @@ menu :: ElemFactory
menu = createDOM "menu"
menu = createDOM "menu"
effToggler :: forall e. R.State Boolean -> EffectFn1 e Unit
effToggler :: forall e. R.State Boolean -> EffectFn1 e Unit
effToggler (value /\ setValue) = mkEffectFn1 $ \
e
-> setValue $ const $ not value
effToggler (value /\ setValue) = mkEffectFn1 $ \
_
-> setValue $ const $ not value
unsafeEventValue :: forall event. event -> String
unsafeEventValue :: forall event. event -> String
unsafeEventValue e = (unsafeCoerce e).target.value
unsafeEventValue e = (unsafeCoerce e).target.value
keyCode :: forall event. event -> Effect Int
keyCode = runEffectFn1 _keyCode
foreign import _keyCode
:: forall e. EffectFn1 e Int
nullRef :: forall t. R.Hooks (R.Ref (Nullable t))
nullRef :: forall t. R.Hooks (R.Ref (Nullable t))
nullRef = R.useRef null
nullRef = R.useRef null
...
...
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