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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
55f5754c
Commit
55f5754c
authored
Jun 13, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngramstable] WIP
parent
93e4036b
Pipeline
#2903
failed with stage
in 0 seconds
Changes
3
Pipelines
1
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 @
55f5754c
...
...
@@ -33,7 +33,7 @@ import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..))
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.Nodes.Lists.Types as NT
import Gargantext.Components.Table as TT
...
...
@@ -592,7 +592,9 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
cpt props@{ cacheState, path } _ = do
searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
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
-- let path = initialPageParams session nodeId [defaultListId] tabType
...
...
@@ -606,58 +608,78 @@ mainNgramsTableCpt = here.component "mainNgramsTable" cpt
NT.CacheOff -> pure $ R.fragment
[
loadedNgramsTableHeader { searchQuery } []
, ngramsTreeEdit { onSave, treeEdit } []
, mainNgramsTableCacheOff (props { treeEdit = treeEdit }) []
, ngramsTreeEdit { treeEdit } []
, mainNgramsTableCacheOff (props { onCancelRef = onCancelRef
, onNgramsClickRef = onNgramsClickRef
, onSaveRef = onSaveRef
, treeEdit = treeEdit }) []
]
type NgramsTreeEditProps =
( onSave :: T.Box (Maybe (Effect Unit))
, treeEdit :: T.Box TreeEdit )
( onCancelRef :: R.Ref (Maybe (Unit -> Effect Unit))
, onNgramsClickRef :: R.Ref (Maybe NgramsClick)
, onSaveRef :: R.Ref (Maybe (Unit -> Effect Unit))
, treeEdit :: T.Box TreeEdit )
ngramsTreeEdit :: R2.Component NgramsTreeEditProps
ngramsTreeEdit = R.createElement ngramsTreeEditCpt
ngramsTreeEditCpt :: R.Component NgramsTreeEditProps
ngramsTreeEditCpt = here.component "ngramsTreeEdit" cpt where
cpt
{ onSave,
treeEdit } _ = do
cpt
props@{
treeEdit } _ = do
{ ngramsParent } <- T.useLive T.unequal treeEdit
pure $ if ngramsParent == Nothing
then
H.div {} []
else
ngramsTreeEditReal
{ onSave, treeEdit }
[]
ngramsTreeEditReal
props
[]
ngramsTreeEditReal :: R2.Component NgramsTreeEditProps
ngramsTreeEditReal = R.createElement ngramsTreeEditRealCpt
ngramsTreeEditRealCpt :: R.Component NgramsTreeEditProps
ngramsTreeEditRealCpt = here.component "ngramsTreeEditReal" cpt where
cpt { treeEdit } _ = do
pure $ H.div {} [ H.text "ngramsTreeEditReal" ]
-- pure $ H.div {}
-- [ H.p {}
-- [ H.text $ "Editing " <> ngramsTermText ngrams ]
-- , NTC.renderNgramsTree { ngramsClick
-- , ngramsDepth
-- , ngramsEdit
-- , ngramsStyle: []
-- , ngramsTable
-- }
-- , H.button { className: "btn btn-primary"
-- , on: {click: (const $ dispatch AddTermChildren)}
-- } [H.text "Save"]
-- , H.button { className: "btn btn-primary"
-- , on: {click: (const $ dispatch ClearTreeEdit)}
-- } [H.text "Cancel"]
-- ]
-- where
-- ngramsTable = ngramsTableCache # at ngrams
-- <<< _Just
-- <<< _NgramsRepoElement
-- <<< _children
-- %~ applyPatchSet (patchSetFromMap ngramsChildrenDiff)
-- ngramsClick {depth: 1, ngrams: child} = Just $ dispatch $ ToggleChild false child
-- ngramsClick _ = Nothing
-- ngramsEdit _ = Nothing
cpt { onCancelRef, onNgramsClickRef, onSaveRef, treeEdit } _ = do
-- pure $ H.div {} [ H.text "ngramsTreeEditReal" ]
{ ngramsChildren, ngramsChildrenDiff, ngramsParent } <- T.useLive T.unequal treeEdit
--let ngramsTable = applyPatchSet (patchSetFromMap ngramsChildrenDiff) ngramsChildren
let ngramsDepth = { depth: 1, ngrams: ngramsParent }
pure $ H.div {}
[ H.p {}
[ H.text $ "Editing " <> ngramsTermText ngramsDepth.ngrams ]
, NTC.renderNgramsTree { ngramsChildren: applyPatchSet (patchSetFromMap ngramsChildrenDiff) $ Set.toUnfoldable ngramsChildren
, ngramsClick
, ngramsDepth
, ngramsEdit
, ngramsStyle: []
}
, H.button { className: "btn btn-primary"
, on: {click: onSaveClick} --(const $ dispatch AddTermChildren)}
} [H.text "Save"]
, H.button { className: "btn btn-primary"
, on: {click: onCancelClick } --(const $ dispatch ClearTreeEdit)}
} [H.text "Cancel"]
]
where
-- ngramsTable = ngramsTableCache # at ngrams
-- <<< _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 = R.createElement mainNgramsTableCacheOnCpt
...
...
src/Gargantext/Components/NgramsTable/Components.purs
View file @
55f5754c
...
...
@@ -12,7 +12,7 @@ import Data.Set (Set)
import Data.Set as Set
import Effect (Effect)
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.Prelude (Unit, bind, const, discard, map, not, otherwise, pure, show, unit, ($), (+), (/=), (<<<), (<>), (==), (>), (||))
import Gargantext.Types as GT
...
...
@@ -146,9 +146,6 @@ renderNgramsTreeCpt = here.component "renderNgramsTree" cpt
]
type NgramsDepth = { ngrams :: NgramsTerm, depth :: Int }
type NgramsClick = NgramsDepth -> Maybe (Effect Unit)
type TagProps =
( ngramsClick :: NgramsClick
, ngramsDepth :: NgramsDepth
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
55f5754c
...
...
@@ -77,6 +77,9 @@ module Gargantext.Components.NgramsTable.Core
, syncResetButtons
, chartsAfterSync
, useAutoSync
, NgramsDepth
, NgramsClick
)
where
...
...
@@ -1190,3 +1193,7 @@ postNgramsChartsAsync { listIds, nodeId, session, tabType } = do
acu = AsyncNgramsChartsUpdate { listId: head listIds
, tabType }
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