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
a605dc66
Commit
a605dc66
authored
Jun 13, 2022
by
Przemyslaw Kaminski
Committed by
Karen Konou
Jun 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngramstable] WIP
parent
a1b4c82f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
39 deletions
+65
-39
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+57
-35
Components.purs
src/Gargantext/Components/NgramsTable/Components.purs
+1
-4
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+7
-0
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
a605dc66
...
@@ -33,7 +33,7 @@ import Gargantext.Components.App.Store (Boxes)
...
@@ -33,7 +33,7 @@ import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..))
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..))
import Gargantext.Components.NgramsTable.Components as NTC
import Gargantext.Components.NgramsTable.Components as NTC
import Gargantext.Components.NgramsTable.Core (Action(..), CoreAction(..), CoreState, Dispatch, NgramsElement(..), NgramsPatch(..), NgramsTable, NgramsTerm, PageParams, PatchMap(..), Versioned(..), VersionedNgramsTable, VersionedWithCountNgramsTable, _NgramsElement, _NgramsRepoElement, _NgramsTable, _children, _list, _ngrams, _ngrams_repo_elements, _ngrams_scores, _occurrences, _root, addNewNgramA, applyNgramsPatches, applyPatchSet, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, fromNgramsPatches, ngramsRepoElementToNgramsElement, ngramsTermText, normNgram, patchSetFromMap, replace, setTermListA, singletonNgramsTablePatch, syncResetButtons, toVersioned)
import Gargantext.Components.NgramsTable.Core (Action(..), CoreAction(..), CoreState, Dispatch, Ngrams
Click, NgramsDepth, Ngrams
Element(..), NgramsPatch(..), NgramsTable, NgramsTerm, PageParams, PatchMap(..), Versioned(..), VersionedNgramsTable, VersionedWithCountNgramsTable, _NgramsElement, _NgramsRepoElement, _NgramsTable, _children, _list, _ngrams, _ngrams_repo_elements, _ngrams_scores, _occurrences, _root, addNewNgramA, applyNgramsPatches, applyPatchSet, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, fromNgramsPatches, ngramsRepoElementToNgramsElement, ngramsTermText, normNgram, patchSetFromMap, replace, setTermListA, singletonNgramsTablePatch, syncResetButtons, toVersioned)
import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI)
import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI)
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as TT
import Gargantext.Components.Table as TT
...
@@ -591,7 +591,9 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
...
@@ -591,7 +591,9 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
cpt props@{ cacheState, path } _ = do
cpt props@{ cacheState, path } _ = do
searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
cacheState' <- T.useLive T.unequal cacheState
cacheState' <- T.useLive T.unequal cacheState
onSave <- T.useBox Nothing
onCancelRef <- R.useRef Nothing
onNgramsClickRef <- R.useRef Nothing
onSaveRef <- R.useRef Nothing
treeEdit <- T.useBox initialTreeEdit
treeEdit <- T.useBox initialTreeEdit
-- let path = initialPageParams session nodeId [defaultListId] tabType
-- let path = initialPageParams session nodeId [defaultListId] tabType
...
@@ -605,58 +607,78 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
...
@@ -605,58 +607,78 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
NT.CacheOff -> pure $ R.fragment
NT.CacheOff -> pure $ R.fragment
[
[
loadedNgramsTableHeader { searchQuery } []
loadedNgramsTableHeader { searchQuery } []
, ngramsTreeEdit { onSave, treeEdit } []
, ngramsTreeEdit { treeEdit } []
, mainNgramsTableCacheOff (props { treeEdit = treeEdit }) []
, mainNgramsTableCacheOff (props { onCancelRef = onCancelRef
, onNgramsClickRef = onNgramsClickRef
, onSaveRef = onSaveRef
, treeEdit = treeEdit }) []
]
]
type NgramsTreeEditProps =
type NgramsTreeEditProps =
( onSave :: T.Box (Maybe (Effect Unit))
( onCancelRef :: R.Ref (Maybe (Unit -> Effect Unit))
, treeEdit :: T.Box TreeEdit )
, onNgramsClickRef :: R.Ref (Maybe NgramsClick)
, onSaveRef :: R.Ref (Maybe (Unit -> Effect Unit))
, treeEdit :: T.Box TreeEdit )
ngramsTreeEdit :: R2.Component NgramsTreeEditProps
ngramsTreeEdit :: R2.Component NgramsTreeEditProps
ngramsTreeEdit = R.createElement ngramsTreeEditCpt
ngramsTreeEdit = R.createElement ngramsTreeEditCpt
ngramsTreeEditCpt :: R.Component NgramsTreeEditProps
ngramsTreeEditCpt :: R.Component NgramsTreeEditProps
ngramsTreeEditCpt = here.component "ngramsTreeEdit" cpt where
ngramsTreeEditCpt = here.component "ngramsTreeEdit" cpt where
cpt
{ onSave,
treeEdit } _ = do
cpt
props@{
treeEdit } _ = do
{ ngramsParent } <- T.useLive T.unequal treeEdit
{ ngramsParent } <- T.useLive T.unequal treeEdit
pure $ if ngramsParent == Nothing
pure $ if ngramsParent == Nothing
then
then
H.div {} []
H.div {} []
else
else
ngramsTreeEditReal
{ onSave, treeEdit }
[]
ngramsTreeEditReal
props
[]
ngramsTreeEditReal :: R2.Component NgramsTreeEditProps
ngramsTreeEditReal :: R2.Component NgramsTreeEditProps
ngramsTreeEditReal = R.createElement ngramsTreeEditRealCpt
ngramsTreeEditReal = R.createElement ngramsTreeEditRealCpt
ngramsTreeEditRealCpt :: R.Component NgramsTreeEditProps
ngramsTreeEditRealCpt :: R.Component NgramsTreeEditProps
ngramsTreeEditRealCpt = here.component "ngramsTreeEditReal" cpt where
ngramsTreeEditRealCpt = here.component "ngramsTreeEditReal" cpt where
cpt { treeEdit } _ = do
cpt { onCancelRef, onNgramsClickRef, onSaveRef, treeEdit } _ = do
pure $ H.div {} [ H.text "ngramsTreeEditReal" ]
-- pure $ H.div {} [ H.text "ngramsTreeEditReal" ]
-- pure $ H.div {}
-- [ H.p {}
{ ngramsChildren, ngramsChildrenDiff, ngramsParent } <- T.useLive T.unequal treeEdit
-- [ H.text $ "Editing " <> ngramsTermText ngrams ]
-- , NTC.renderNgramsTree { ngramsClick
--let ngramsTable = applyPatchSet (patchSetFromMap ngramsChildrenDiff) ngramsChildren
-- , ngramsDepth
let ngramsDepth = { depth: 1, ngrams: ngramsParent }
-- , ngramsEdit
-- , ngramsStyle: []
pure $ H.div {}
-- , ngramsTable
[ H.p {}
-- }
[ H.text $ "Editing " <> ngramsTermText ngramsDepth.ngrams ]
-- , H.button { className: "btn btn-primary"
, NTC.renderNgramsTree { ngramsChildren: applyPatchSet (patchSetFromMap ngramsChildrenDiff) $ Set.toUnfoldable ngramsChildren
-- , on: {click: (const $ dispatch AddTermChildren)}
, ngramsClick
-- } [H.text "Save"]
, ngramsDepth
-- , H.button { className: "btn btn-primary"
, ngramsEdit
-- , on: {click: (const $ dispatch ClearTreeEdit)}
, ngramsStyle: []
-- } [H.text "Cancel"]
}
-- ]
, H.button { className: "btn btn-primary"
-- where
, on: {click: onSaveClick} --(const $ dispatch AddTermChildren)}
-- ngramsTable = ngramsTableCache # at ngrams
} [H.text "Save"]
-- <<< _Just
, H.button { className: "btn btn-primary"
-- <<< _NgramsRepoElement
, on: {click: onCancelClick } --(const $ dispatch ClearTreeEdit)}
-- <<< _children
} [H.text "Cancel"]
-- %~ applyPatchSet (patchSetFromMap ngramsChildrenDiff)
]
-- ngramsClick {depth: 1, ngrams: child} = Just $ dispatch $ ToggleChild false child
where
-- ngramsClick _ = Nothing
-- ngramsTable = ngramsTableCache # at ngrams
-- ngramsEdit _ = Nothing
-- <<< _Just
-- <<< _NgramsRepoElement
-- <<< _children
-- %~ applyPatchSet (patchSetFromMap ngramsChildrenDiff)
--ngramsClick {depth: 1, ngrams: child} = Just $ dispatch $ ToggleChild false child
--ngramsClick _ = Nothing
ngramsClick nd = case R.readRef onNgramsClickRef of
Nothing -> Nothing
Just ngc -> ngc nd
ngramsEdit _ = Nothing
onCancelClick _ = case R.readRef onCancelRef of
Nothing -> Nothing
Just onCancel -> onCancel unit
onSaveClick _ = case R.readRef onSaveRef of
Nothing -> Nothing
Just onSave -> onSave unit
mainNgramsTableCacheOn :: R2.Component MainNgramsTableProps
mainNgramsTableCacheOn :: R2.Component MainNgramsTableProps
mainNgramsTableCacheOn = R.createElement mainNgramsTableCacheOnCpt
mainNgramsTableCacheOn = R.createElement mainNgramsTableCacheOnCpt
...
...
src/Gargantext/Components/NgramsTable/Components.purs
View file @
a605dc66
...
@@ -12,7 +12,7 @@ import Data.Set (Set)
...
@@ -12,7 +12,7 @@ import Data.Set (Set)
import Data.Set as Set
import Data.Set as Set
import Effect (Effect)
import Effect (Effect)
import FFI.Simple (delay)
import FFI.Simple (delay)
import Gargantext.Components.NgramsTable.Core (Action(..), Dispatch, NgramsElement, NgramsTable, NgramsTablePatch, NgramsTerm, _NgramsElement, _NgramsRepoElement, _PatchMap, _children, _list, _ngrams, _occurrences, ngramsTermText, replace, setTermListA)
import Gargantext.Components.NgramsTable.Core (Action(..), Dispatch, Ngrams
Click, NgramsDepth, Ngrams
Element, NgramsTable, NgramsTablePatch, NgramsTerm, _NgramsElement, _NgramsRepoElement, _PatchMap, _children, _list, _ngrams, _occurrences, ngramsTermText, replace, setTermListA)
import Gargantext.Components.Table as Tbl
import Gargantext.Components.Table as Tbl
import Gargantext.Prelude (Unit, bind, const, discard, map, not, otherwise, pure, show, unit, ($), (+), (/=), (<<<), (<>), (==), (>), (||))
import Gargantext.Prelude (Unit, bind, const, discard, map, not, otherwise, pure, show, unit, ($), (+), (/=), (<<<), (<>), (==), (>), (||))
import Gargantext.Types as GT
import Gargantext.Types as GT
...
@@ -146,9 +146,6 @@ renderNgramsTreeCpt = here.component "renderNgramsTree" cpt
...
@@ -146,9 +146,6 @@ renderNgramsTreeCpt = here.component "renderNgramsTree" cpt
]
]
type NgramsDepth = { ngrams :: NgramsTerm, depth :: Int }
type NgramsClick = NgramsDepth -> Maybe (Effect Unit)
type TagProps =
type TagProps =
( ngramsClick :: NgramsClick
( ngramsClick :: NgramsClick
, ngramsDepth :: NgramsDepth
, ngramsDepth :: NgramsDepth
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
a605dc66
...
@@ -77,6 +77,9 @@ module Gargantext.Components.NgramsTable.Core
...
@@ -77,6 +77,9 @@ module Gargantext.Components.NgramsTable.Core
, syncResetButtons
, syncResetButtons
, chartsAfterSync
, chartsAfterSync
, useAutoSync
, useAutoSync
, NgramsDepth
, NgramsClick
)
)
where
where
...
@@ -1190,3 +1193,7 @@ postNgramsChartsAsync { listIds, nodeId, session, tabType } = do
...
@@ -1190,3 +1193,7 @@ postNgramsChartsAsync { listIds, nodeId, session, tabType } = do
acu = AsyncNgramsChartsUpdate { listId: head listIds
acu = AsyncNgramsChartsUpdate { listId: head listIds
, tabType }
, tabType }
putNgramsAsync = PostNgramsChartsAsync (Just nodeId)
putNgramsAsync = PostNgramsChartsAsync (Just nodeId)
type NgramsDepth = { ngrams :: NgramsTerm, depth :: Int }
type NgramsClick = NgramsDepth -> Maybe (Effect Unit)
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