Commit 94dddd69 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngramsTable] some more refactoring

parent 4a3f362c
...@@ -14,7 +14,6 @@ import Gargantext.Components.Bootstrap.Types (SpinnerTheme(..)) ...@@ -14,7 +14,6 @@ import Gargantext.Components.Bootstrap.Types (SpinnerTheme(..))
import Gargantext.Components.Document.Types (DocPath, Document(..), LoadedData, initialState) import Gargantext.Components.Document.Types (DocPath, Document(..), LoadedData, initialState)
import Gargantext.Components.NgramsTable.Core (addNewNgramA, applyNgramsPatches, coreDispatch, findNgramRoot, setTermListA) import Gargantext.Components.NgramsTable.Core (addNewNgramA, applyNgramsPatches, coreDispatch, findNgramRoot, setTermListA)
import Gargantext.Components.NgramsTable.AutoSync (useAutoSync) import Gargantext.Components.NgramsTable.AutoSync (useAutoSync)
import Gargantext.Components.NgramsTable.SyncResetButton (syncResetButtons)
import Gargantext.Components.Node (NodePoly(..)) import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Core.NgramsTable.Types (CoreAction(..), Versioned(..), replace) import Gargantext.Core.NgramsTable.Types (CoreAction(..), Versioned(..), replace)
import Gargantext.Utils as U import Gargantext.Utils as U
......
...@@ -36,10 +36,10 @@ import Effect.Class (liftEffect) ...@@ -36,10 +36,10 @@ import Effect.Class (liftEffect)
import Gargantext.Components.App.Store (Boxes) 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.Core (addNewNgramA, applyNgramsPatches, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, ngramsRepoElementToNgramsElement, normNgram, patchSetFromMap, setTermListA, singletonNgramsTablePatch, toVersioned) import Gargantext.Components.NgramsTable.Core (addNewNgramA, applyNgramsPatches, chartsAfterSync, commitPatch, convOrderBy, coreDispatch, filterTermSize, ngramsRepoElementToNgramsElement, normNgram, patchSetFromMap, setTermListA, singletonNgramsTablePatch, tablePatchHasNgrams, toVersioned)
import Gargantext.Components.NgramsTable.Search as NTS import Gargantext.Components.NgramsTable.Search as NTS
import Gargantext.Components.NgramsTable.SelectionCheckbox as NTSC import Gargantext.Components.NgramsTable.SelectionCheckbox as NTSC
import Gargantext.Components.NgramsTable.Tree as NTT import Gargantext.Components.NgramsTable.Tree (renderNgramsItem, renderNgramsTree)
import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI) import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI)
import Gargantext.Components.NgramsTable.SyncResetButton (syncResetButtons) import Gargantext.Components.NgramsTable.SyncResetButton (syncResetButtons)
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
...@@ -358,14 +358,14 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where ...@@ -358,14 +358,14 @@ loadedNgramsTableBodyCpt = here.component "loadedNgramsTableBody" cpt where
filteredConvertedRows = convertRow <$> filteredRows filteredConvertedRows = convertRow <$> filteredRows
convertRow ngramsElement = convertRow ngramsElement =
{ row: NTT.renderNgramsItem { dispatch: performAction { row: renderNgramsItem { dispatch: performAction
, getNgramsChildren , getNgramsChildren
, ngrams: ngramsElement ^. _NgramsElement <<< _ngrams , ngrams: ngramsElement ^. _NgramsElement <<< _ngrams
, ngramsElement , ngramsElement
, ngramsLocalPatch , ngramsLocalPatch
, ngramsParent , ngramsParent
, ngramsSelection , ngramsSelection
, ngramsTable } [] , ngramsTable } []
, delete: false , delete: false
} }
...@@ -552,7 +552,7 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list} ...@@ -552,7 +552,7 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list}
-- ^ and which satisfies the chosen term size -- ^ and which satisfies the chosen term size
|| ngramsChildrenDiff ^. at ngrams == Just false || ngramsChildrenDiff ^. at ngrams == Just false
-- ^ unless they are scheduled to be removed. -- ^ unless they are scheduled to be removed.
|| NTT.tablePatchHasNgrams ngramsLocalPatch ngrams || tablePatchHasNgrams ngramsLocalPatch ngrams
-- ^ unless they are being processed at the moment. -- ^ unless they are being processed at the moment.
allNgramsSelectedOnFirstPage :: Set NgramsTerm -> PreConversionRows -> Boolean allNgramsSelectedOnFirstPage :: Set NgramsTerm -> PreConversionRows -> Boolean
...@@ -689,15 +689,15 @@ ngramsTreeEditRealCpt = here.component "ngramsTreeEditReal" cpt where ...@@ -689,15 +689,15 @@ ngramsTreeEditRealCpt = here.component "ngramsTreeEditReal" cpt where
pure $ H.div {} pure $ H.div {}
[ H.p {} [ H.p {}
[ H.text $ "Editing " <> ngramsTermText ngramsDepth.ngrams ] [ H.text $ "Editing " <> ngramsTermText ngramsDepth.ngrams ]
, NTT.renderNgramsTree { getNgramsChildren: gnc , renderNgramsTree { getNgramsChildren: gnc
, ngramsClick , ngramsClick
, ngramsDepth , ngramsDepth
, ngramsEdit , ngramsEdit
, ngramsStyle: [] , ngramsStyle: []
, key: show ngramsParent' , key: show ngramsParent'
<> "-" <> show ngramsChildren <> "-" <> show ngramsChildren
<> "-" <> show ngramsChildrenDiff <> "-" <> show ngramsChildrenDiff
} }
, H.button { className: "btn btn-primary" , H.button { className: "btn btn-primary"
, on: { click: onSaveClick } --(const $ dispatch AddTermChildren)} , on: { click: onSaveClick } --(const $ dispatch AddTermChildren)}
} [ H.text "Save" ] } [ H.text "Save" ]
......
...@@ -8,7 +8,7 @@ import Data.Array (head) ...@@ -8,7 +8,7 @@ import Data.Array (head)
import Data.Array as A import Data.Array as A
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Foldable (foldl) import Data.Foldable (foldl)
import Data.Lens (use, view, (^?), (?=), (%~), (%=), (.~)) import Data.Lens (use, view, (^?), (^.), (?=), (%~), (%=), (.~))
import Data.Lens.At (at) import Data.Lens.At (at)
import Data.Lens.Common (_Just) import Data.Lens.Common (_Just)
import Data.Lens.Fold (folded, traverseOf_) import Data.Lens.Fold (folded, traverseOf_)
...@@ -17,7 +17,7 @@ import Data.List ((:), List(Nil)) ...@@ -17,7 +17,7 @@ import Data.List ((:), List(Nil))
import Data.List as L import Data.List as L
import Data.Map (Map) import Data.Map (Map)
import Data.Map as Map import Data.Map as Map
import Data.Maybe (Maybe(..), fromMaybe, fromMaybe') import Data.Maybe (Maybe(..), fromMaybe, fromMaybe', isJust)
import Data.Set (Set) import Data.Set (Set)
import Data.String as S import Data.String as S
import Data.String.Common as DSC import Data.String.Common as DSC
...@@ -518,3 +518,8 @@ postNgramsChartsAsync { listIds, nodeId, session, tabType } = do ...@@ -518,3 +518,8 @@ 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)
tablePatchHasNgrams :: NgramsTablePatch -> NgramsTerm -> Boolean
tablePatchHasNgrams (NgramsTablePatch ngramsPatches) ngrams =
isJust $ ngramsPatches ^. _PatchMap <<< at ngrams
...@@ -18,7 +18,7 @@ import DOM.Simple as DOM ...@@ -18,7 +18,7 @@ import DOM.Simple as DOM
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 Gargantext.Components.NgramsTable.Core (applyNgramsPatches, setTermListA) import Gargantext.Components.NgramsTable.Core (applyNgramsPatches, setTermListA, tablePatchHasNgrams)
import Gargantext.Core.NgramsTable.Types (Action(..), NgramsClick, NgramsDepth, NgramsElement, NgramsTable, NgramsTablePatch(..), NgramsTerm, _NgramsElement, _NgramsRepoElement, _PatchMap, _children, _list, _ngrams, _occurrences, ngramsTermText, replace) import Gargantext.Core.NgramsTable.Types (Action(..), NgramsClick, NgramsDepth, NgramsElement, NgramsTable, NgramsTablePatch(..), NgramsTerm, _NgramsElement, _NgramsRepoElement, _PatchMap, _children, _list, _ngrams, _occurrences, ngramsTermText, replace)
import Gargantext.Components.Table as Tbl import Gargantext.Components.Table as Tbl
import Gargantext.Config.REST (logRESTError) import Gargantext.Config.REST (logRESTError)
...@@ -273,10 +273,6 @@ termStyle GT.CandidateTerm opacity = DOM.style ...@@ -273,10 +273,6 @@ termStyle GT.CandidateTerm opacity = DOM.style
, opacity , opacity
} }
tablePatchHasNgrams :: NgramsTablePatch -> NgramsTerm -> Boolean
tablePatchHasNgrams (NgramsTablePatch ngramsPatches) ngrams =
isJust $ ngramsPatches ^. _PatchMap <<< at ngrams
nextTermList :: GT.TermList -> GT.TermList nextTermList :: GT.TermList -> GT.TermList
nextTermList GT.MapTerm = GT.StopTerm nextTermList GT.MapTerm = GT.StopTerm
......
...@@ -6,7 +6,6 @@ import Data.Generic.Rep (class Generic) ...@@ -6,7 +6,6 @@ import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Gargantext.Components.App.Store (Boxes) import Gargantext.Components.App.Store (Boxes)
import Gargantext.Components.App.Store as AppStore import Gargantext.Components.App.Store as AppStore
...@@ -128,7 +127,7 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt where ...@@ -128,7 +127,7 @@ textsLayoutWithKeyCpt = here.component "textsLayoutWithKey" cpt where
} }
where where
errorHandler = logRESTError here "[textsLayoutWithKey]" errorHandler = logRESTError here "[textsLayoutWithKey]"
afterCacheStateChange cacheState = do afterCacheStateChange _cacheState = do
launchAff_ $ clearCache unit launchAff_ $ clearCache unit
-- TODO -- TODO
--sessionUpdate $ setCacheState session nodeId cacheState --sessionUpdate $ setCacheState session nodeId cacheState
...@@ -248,7 +247,7 @@ histoRender = R.createElement histoRenderCpt ...@@ -248,7 +247,7 @@ histoRender = R.createElement histoRenderCpt
histoRenderCpt :: R.Component HistoProps histoRenderCpt :: R.Component HistoProps
histoRenderCpt = here.component "histoRender" cpt where histoRenderCpt = here.component "histoRender" cpt where
cpt { boxes, path, onClick, onInit, reload, session } _ = do cpt { boxes, path, onClick, onInit, reload, session } _ = do
reload' <- T.useLive T.unequal reload _ <- T.useLive T.unequal reload
pure $ histo { boxes, path, onClick, onInit, session } pure $ histo { boxes, path, onClick, onInit, session }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment