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
07d22861
Verified
Commit
07d22861
authored
Sep 03, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[list selection] implement list selection draft
parent
40d51410
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
9 deletions
+107
-9
Upload.purs
...Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
+7
-2
Tools.purs
src/Gargantext/Components/Forest/Tree/Node/Tools.purs
+0
-1
ListSelection.purs
src/Gargantext/Components/ListSelection.purs
+88
-0
Tile.purs
src/Gargantext/Components/Tile.purs
+6
-3
TileMenu.purs
src/Gargantext/Components/TileMenu.purs
+6
-3
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
View file @
07d22861
...
...
@@ -18,6 +18,7 @@ import Gargantext.Components.Forest.Tree.Node.Action (Action(..), Props)
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType(..), UploadFileBlob(..), readUFBAsText)
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT, formChoiceSafe, panel)
import Gargantext.Components.Lang (Lang(..))
import Gargantext.Components.ListSelection as ListSelection
import Gargantext.Config.REST (RESTError)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, postWwwUrlencoded)
...
...
@@ -72,8 +73,7 @@ data DroppedFile =
, lang :: Lang
}
derive instance Generic DroppedFile _
instance Eq DroppedFile where
eq = genericEq
instance Eq DroppedFile where eq = genericEq
type FileHash = String
...
...
@@ -93,6 +93,7 @@ uploadFileViewCpt = here.component "uploadFileView" cpt
mFile <- T.useBox (Nothing :: Maybe UploadFile)
fileType <- T.useBox CSV
lang <- T.useBox EN
selection <- T.useBox ListSelection.MyListsFirst
let setFileType' val = T.write_ val fileType
let setLang' val = T.write_ val lang
...
...
@@ -125,6 +126,10 @@ uploadFileViewCpt = here.component "uploadFileView" cpt
show
]
]
, R2.row
[ H.div { className: "col-6 flex-space-around" }
[ ListSelection.selection { selection } [] ]
]
]
let footer = H.div {} [ uploadButton { dispatch
...
...
src/Gargantext/Components/Forest/Tree/Node/Tools.purs
View file @
07d22861
...
...
@@ -201,7 +201,6 @@ type CheckboxProps =
checkbox :: R2.Leaf CheckboxProps
checkbox props = R.createElement checkboxCpt props []
checkboxCpt :: R.Component CheckboxProps
checkboxCpt = here.component "checkbox" cpt
where
...
...
src/Gargantext/Components/ListSelection.purs
0 → 100644
View file @
07d22861
module Gargantext.Components.ListSelection where
import Gargantext.Prelude
import Data.Array as A
import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Gargantext.Components.Forest.Tree.Node.Tools (formChoiceSafe)
import Gargantext.Types (ListId)
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.ListSelection"
data Selection = MyListsFirst | OtherListsFirst | SelectedLists (Array ListId)
derive instance Generic Selection _
instance Show Selection where
show MyListsFirst = "My lists first"
show OtherListsFirst = "Other lists first"
show (SelectedLists _) = "Selected lists"
instance Eq Selection where eq = genericEq
instance Read Selection where
read "My lists first" = Just MyListsFirst
read "Other lists first" = Just OtherListsFirst
read "Selected lists" = Just $ SelectedLists []
read _ = Nothing
type Props =
( selection :: T.Box Selection )
selection :: R2.Component Props
selection = R.createElement selectionCpt
selectionCpt :: R.Component Props
selectionCpt = here.component "selection" cpt where
cpt { selection } _ = do
pure $ H.div {}
[ formChoiceSafe [ MyListsFirst
, OtherListsFirst
, SelectedLists [] ] MyListsFirst setSelection show
, selectedIds { selection } []
]
where
setSelection val = T.write_ val selection
selectedIds :: R2.Component Props
selectedIds = R.createElement selectedIdsCpt
selectedIdsCpt :: R.Component Props
selectedIdsCpt = here.component "selectedIds" cpt where
cpt { selection } _ = do
selection' <- T.useLive T.unequal selection
pure $ case selection' of
SelectedLists ids -> H.div {} [ idsSelector { ids, selection } [] ]
_ -> H.div {} []
type IdsSelectorProps =
( ids :: Array ListId
, selection :: T.Box Selection )
idsSelector :: R2.Component IdsSelectorProps
idsSelector = R.createElement idsSelectorCpt
idsSelectorCpt :: R.Component IdsSelectorProps
idsSelectorCpt = here.component "idsSelector" cpt where
cpt { ids, selection } _ = do
R.useEffect' $ do
here.log2 "[idsSelector] ids" ids
pure $ H.div {} $ map checkbox [1, 2, 3, 4]
where
checkbox val = H.div {}
[ H.input { className: "form-check-input"
, on: { click }
, type: "checkbox"
, value: A.elem val ids }
, H.label {} [ H.text $ show val ]
]
where
click _ = do
let f (SelectedLists lst) =
if A.elem val ids
then SelectedLists (A.delete val lst)
else SelectedLists (A.cons val lst)
f x = x
T.modify_ f selection
src/Gargantext/Components/Tile.purs
View file @
07d22861
...
...
@@ -9,9 +9,13 @@ import Data.Maybe (Maybe(..))
import Effect (Effect)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Routes (Tile)
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
here :: R2.Here
here = R2.here "Gargantext.Components.Tile"
type Props =
( boxes :: Boxes
, tile :: Record Tile
...
...
@@ -19,11 +23,10 @@ type Props =
, closeCallback :: Unit -> Effect Unit
)
tileBlock :: R
ecord Props -> Array R.Element -> R.Element
tileBlock :: R
2.Component Props
tileBlock = R.createElement tileBlockCpt
tileBlockCpt :: R.Component Props
tileBlockCpt =
R.hooksC
omponent "tileBlock" cpt where
tileBlockCpt =
here.c
omponent "tileBlock" cpt where
cpt props@{ closeCallback } children = do
-- Render
...
...
src/Gargantext/Components/TileMenu.purs
View file @
07d22861
...
...
@@ -13,10 +13,14 @@ import Gargantext.Components.App.Data (Boxes)
import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Routes (AppRoute, Tile)
import Gargantext.Utils.Popover as Popover
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.TileMenu"
type Props =
( boxes :: Boxes
, currentTile :: Maybe (Unit -> Effect AppRoute)
...
...
@@ -24,11 +28,10 @@ type Props =
, yTile :: Maybe (Unit -> Effect AppRoute)
)
tileMenu :: R
ecord Props -> Array (R.Element) -> R.Element
tileMenu :: R
2.Component Props
tileMenu = R.createElement tileMenuCpt
tileMenuCpt :: R.Component Props
tileMenuCpt =
R.hooksC
omponent "tileMenu" cpt where
tileMenuCpt =
here.c
omponent "tileMenu" cpt where
cpt props@{ boxes } children = do
-- Hooks
{ goToRoute } <- useLinkHandler
...
...
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