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
58f378f4
Commit
58f378f4
authored
Jun 09, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACT|DESIGN] refactoring Node Box (start)
parent
63991233
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
33 deletions
+90
-33
Action.purs
src/Gargantext/Components/Forest/Tree/Node/Action.purs
+29
-0
Add.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
+5
-5
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+56
-28
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action.purs
View file @
58f378f4
...
...
@@ -24,12 +24,40 @@ data Action = AddNode String GT.NodeType
| RefreshTree
| ShareNode String
instance showShow :: Show Action where
show DeleteNode = "DeleteNode"
show (AddNode _ _) = "AddNode"
show (UpdateNode _) = "UpdateNode"
show (RenameNode _) = "RenameNode"
show (SearchQuery _) = "SearchQuery"
show (UploadFile _ _ _ _)= "UploadFile"
show RefreshTree = "RefreshTree"
show (ShareNode _) = "ShareNode"
-----------------------------------------------------
-- TODO Delete with asyncTaskWithType
deleteNode :: Session -> GT.ID -> Aff GT.ID
deleteNode session nodeId = delete session $ NodeAPI GT.Node (Just nodeId) ""
-----------------------------------------------------------------------
icon :: Action -> String
icon DeleteNode = "trash"
icon (AddNode _ _) = "plus"
icon _ = "hand-o-right"
text :: Action -> String
text DeleteNode = "Delete !"
text (AddNode _ _) = "Add !"
text (UpdateNode _) = "Update !"
text (RenameNode _) = "Rename !"
text (SearchQuery _) = "Launch search !"
text (UploadFile _ _ _ _)= "Upload File !"
text RefreshTree = "Refresh Tree !"
text (ShareNode _) = "Share !"
-----------------------------------------------------------------------
type Props =
( dispatch :: Action -> Aff Unit
, id :: Int
...
...
@@ -50,4 +78,5 @@ instance showFileType :: Show FileType where
show = genericShow
newtype UploadFileContents = UploadFileContents String
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
View file @
58f378f4
...
...
@@ -106,7 +106,7 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
-- , showConfig nt
]
else
H.button { className : "btn btn-primary
flex-
center"
H.button { className : "btn btn-primary center"
, type : "button"
, onClick : mkEffectFn1 $ \_ -> setNodeType ( const
$ fromMaybe nt
...
...
@@ -121,14 +121,14 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
panelFooter (name' /\ _) (nt /\ _) =
H.div { className: "panel-footer"}
[ H.div {} []
, H.div {className: "
flex-
center"}
, H.div {className: "center"}
[ H.button {className: "btn btn-primary"
, type: "button"
, style
: { width: "10
0%" }
, type
: "button"
, style
: { width: "5
0%" }
, onClick: mkEffectFn1 $ \_ -> do
-- TODO
--setPopupOpen $ const Nothing
launchAff
$ dispatch $ AddNode name' nt
launchAff $ dispatch $ AddNode name' nt
} [H.text "Add"]
]
]
...
...
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
58f378f4
...
...
@@ -7,14 +7,13 @@ import Data.Nullable (Nullable, null)
import Data.Tuple (fst, Tuple(..))
import Data.Tuple.Nested ((/\))
import DOM.Simple as DOM
import DOM.Simple.Event
import DOM.Simple.EventListener
import DOM.Simple.
Types
import D
OM.Simple.Window
import DOM.Simple.Event
(MessageEvent)
import DOM.Simple.EventListener
(Callback, addEventListener, callback)
import DOM.Simple.
Window (window)
import D
ata.String as S
import Effect (Effect)
import Effect.Aff (Aff, launchAff, launchAff_)
import Effect.Class (liftEffect)
import Effect.Console
import Effect.Uncurried (mkEffectFn1)
import React.SyntheticEvent as E
import Reactix as R
...
...
@@ -25,12 +24,11 @@ import Web.File.FileReader.Aff (readAsText)
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Forest.Tree.Node (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), FileType(..), UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), FileType(..), UploadFileContents(..)
, icon, text
)
import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), addNodeView)
import Gargantext.Components.Forest.Tree.Node.Action.CopyFrom (copyFromCorpusView)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (textInputBox, renameAction)
import Gargantext.Components.Forest.Tree.Node.Action.Share as Share
import Gargantext.Components.Forest.Tree.Node.Action.Update
import Gargantext.Components.Forest.Tree.Node.Action.Upload (DroppedFile(..), uploadFileView, fileTypeView, uploadTermListView)
import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar, BarType(..))
import Gargantext.Components.GraphExplorer.API as GraphAPI
...
...
@@ -42,9 +40,9 @@ import Gargantext.Components.Search.SearchField (Search, defaultSearch, isIsTex_
import Gargantext.Components.Search.Types (DataField(..))
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Prelude
(Unit, bind, const, discard, identity, map, pure, show, unit, void, ($), (+), (<>), (==))
import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId
, post
)
import Gargantext.Sessions (Session, sessionId)
import Gargantext.Types (NodeType(..), ID, Name, Reload)
import Gargantext.Types as GT
import Gargantext.Utils (glyphicon, glyphiconActive)
...
...
@@ -219,10 +217,10 @@ nodeTextCpt = R.hooksComponent "G.C.F.T.N.B.nodeText" cpt
-- START nodeActions
type NodeActionsProps =
( id :: ID
, nodeType :: GT.NodeType
( id
:: ID
, nodeType
:: GT.NodeType
, refreshTree :: Unit -> Aff Unit
, session :: Session
, session
:: Session
)
nodeActions :: Record NodeActionsProps -> R.Element
...
...
@@ -416,7 +414,11 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
[ H.div { className: "panel panel-default" }
[ H.div {className: ""}
[ H.div { className : "col-md-10 flex-between"}
[ H.h3 { className: GT.fldr p.nodeType true} [H.text $ show p.nodeType]
[ H.h3 { className: GT.fldr p.nodeType true} []
-- TODO fix names
, H.text $ S.replace (S.Pattern "Node") (S.Replacement " ")
$ S.replace (S.Pattern "Folder") (S.Replacement " ")
$ show p.nodeType
, H.p {className: "text-primary center"} [H.text p.name]
]
]
...
...
@@ -442,8 +444,9 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
panelHeading isOpen@(open /\ _) {dispatch, id, name, nodeType} =
H.div {className: "panel-heading"}
[ R2.row
[ H.div {className: "col-md-8"}
[ textInputBox { boxAction: renameAction, boxName: "Rename", dispatch, id, text:name, isOpen } ]
[ H.div {className: "col-md-8 flex-end"}
[ textInputBox { boxAction: renameAction
, boxName: "Rename", dispatch, id, text:name, isOpen } ]
, H.div {className: "flex-end"}
[ if edit then editIcon isOpen else H.div {} []
...
...
@@ -451,7 +454,8 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
[ H.a { "type" : "button"
, className: glyphicon "window-close"
, on: { click: \e -> p.onPopoverClose $ R2.unsafeEventTarget e }
, title : "Close"} []
, title : "Close"
} []
]
]
]
...
...
@@ -647,20 +651,43 @@ actionDelete _ dispatch = do
, "If yes, click again below."
]
)
,
really
Delete dispatch
,
submitButton DeleteNode dispatch -- button
Delete dispatch
]
where
reallyDelete :: (Action -> Aff Unit) -> R.Element
reallyDelete d = H.div {className: "panel-footer"}
[ H.a { type: "button"
, className: "btn glyphicon glyphicon-trash"
, id: "delete"
, title: "Delete"
, on: {click: \_ -> launchAff $ d $ DeleteNode}
}
[H.text " Yes, delete!"]
]
buttonDelete :: (Action -> Aff Unit) -> R.Element
buttonDelete d =
H.div {className: "panel-footer"}
[ H.div {} []
, H.div { className: "center"}
[ H.button { className : "btn btn-primary glyphicon glyphicon-trash"
, type: "button"
, style : { width: "50%" }
, id: "delete"
, title: "Delete"
, on: {click: \_ -> launchAff $ d $ DeleteNode}
}
[ H.text "Delete!"]
]
]
type ButtonTitle = String
type ButtonIcon = String
submitButton :: Action -> (Action -> Aff Unit) -> R.Element
submitButton action dispatch =
H.div {className: "panel-footer"}
[ H.div {} []
, H.div { className: "center"}
[ H.button { className : "btn btn-primary fa fa-" <> icon action
, type: "button"
, style : { width: "50%" }
, id: S.toLower $ show action
, title: show action
, on: {click: \_ -> launchAff $ dispatch action}
}
[ H.text $ " " <> text action]
]
]
-- | Action : Upload
...
...
@@ -718,7 +745,8 @@ downloadButton href label info = do
[ H.div { className: "panel-footer"}
[ H.div { className: "col-md-3"} []
, H.div { className: "col-md-3 flex-center"}
[ H.a { className: "btn btn-default"
[ H.a { className: "btn btn-primary"
, style : { width: "50%" }
, href
, target: "_blank" }
[ H.text label ]
...
...
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