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
b52dccca
Commit
b52dccca
authored
May 15, 2020
by
Przemyslaw Kaminski
Committed by
Alexandre Delanoë
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] small refactoring
parent
15adf4ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+17
-18
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
b52dccca
...
@@ -11,19 +11,18 @@ import Data.Lens.Common (_Just)
...
@@ -11,19 +11,18 @@ import Data.Lens.Common (_Just)
import Data.Lens.Fold (folded)
import Data.Lens.Fold (folded)
import Data.Lens.Index (ix)
import Data.Lens.Index (ix)
import Data.Lens.Record (prop)
import Data.Lens.Record (prop)
import Data.List as L
import Data.List
(List, filter, length, null, toUnfoldable)
as L
import Data.Map (Map)
import Data.Map (Map)
import Data.Map as Map
import Data.Map as Map
import Data.Maybe (Maybe(..), maybe, isJust, isNothing)
import Data.Maybe (Maybe(..), maybe, isJust, isNothing)
import Data.Monoid.Additive (Additive(..))
import Data.Monoid.Additive (Additive(..))
import Data.Nullable (
Nullable, toMaybe, null
)
import Data.Nullable (
null, toMaybe
)
import Data.Ord.Down (Down(..))
import Data.Ord.Down (Down(..))
import Data.Set (Set)
import Data.Set (Set)
import Data.Set as Set
import Data.Set as Set
import Data.Symbol (SProxy(..))
import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect (Effect)
import Effect (Effect)
import FFI.Simple (delay)
import FFI.Simple (delay)
import Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, otherwise, pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<), (==), (||))
import Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, otherwise, pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<), (==), (||))
...
@@ -42,7 +41,7 @@ import Gargantext.Components.Table as T
...
@@ -42,7 +41,7 @@ import Gargantext.Components.Table as T
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), readTermList, readTermSize, termLists, termSizes)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), readTermList, readTermSize, termLists, termSizes)
import Gargantext.Utils (queryMatchesLabel, toggleSet)
import Gargantext.Utils (queryMatchesLabel, toggleSet)
import Gargantext.Utils.List as L
import Gargantext.Utils.List
(sortWith)
as L
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
type State' =
type State' =
...
@@ -65,36 +64,36 @@ _ngramsSelection = prop (SProxy :: SProxy "ngramsSelection")
...
@@ -65,36 +64,36 @@ _ngramsSelection = prop (SProxy :: SProxy "ngramsSelection")
initialState' :: VersionedNgramsTable -> State'
initialState' :: VersionedNgramsTable -> State'
initialState' (Versioned {version}) =
initialState' (Versioned {version}) =
{ ngramsLocalPatch: mempty
{ ngramsChildren: mempty
, ngramsLocalPatch: mempty
, ngramsParent: Nothing
, ngramsSelection: mempty
, ngramsStagePatch: mempty
, ngramsStagePatch: mempty
, ngramsValidPatch: mempty
, ngramsValidPatch: mempty
, ngramsVersion: version
, ngramsVersion: version
, ngramsParent: Nothing
, ngramsChildren: mempty
, ngramsSelection: mempty
}
}
type State =
type State =
CoreState (
CoreState (
ngramsParent :: Maybe NgramsTerm -- Nothing means we are not currently grouping terms
ngramsChildren :: Map NgramsTerm Boolean
, ngramsChildren :: Map NgramsTerm Boolean
-- ^ Used only when grouping.
-- ^ Used only when grouping.
-- This updates the children of `ngramsParent`,
-- This updates the children of `ngramsParent`,
-- ngrams set to `true` are to be added, and `false` to
-- ngrams set to `true` are to be added, and `false` to
-- be removed.
-- be removed.
, ngramsParent :: Maybe NgramsTerm -- Nothing means we are not currently grouping terms
, ngramsSelection :: Set NgramsTerm
, ngramsSelection :: Set NgramsTerm
-- ^ The set of selected checkboxes of the first column.
-- ^ The set of selected checkboxes of the first column.
)
)
initialState :: VersionedNgramsTable -> State
initialState :: VersionedNgramsTable -> State
initialState (Versioned {version}) = {
initialState (Versioned {version}) = {
ngramsLocalPatch: mempty
ngramsChildren: mempty
, ngramsLocalPatch: mempty
, ngramsParent: Nothing
, ngramsSelection: mempty
, ngramsStagePatch: mempty
, ngramsStagePatch: mempty
, ngramsValidPatch: mempty
, ngramsValidPatch: mempty
, ngramsVersion: version
, ngramsVersion: version
, ngramsParent: Nothing
, ngramsChildren: mempty
, ngramsSelection: mempty
}
}
data Action
data Action
...
@@ -249,13 +248,13 @@ tableContainerCpt { dispatch
...
@@ -249,13 +248,13 @@ tableContainerCpt { dispatch
selectButtons true =
selectButtons true =
H.li {className: " list-group-item"} [
H.li {className: " list-group-item"} [
H.button { className: "btn btn-primary"
H.button { className: "btn btn-primary"
, on: {click: const $ setSelection GraphTerm }
, on: {
click: const $ setSelection GraphTerm }
} [ H.text "Map" ]
} [ H.text "Map" ]
, H.button { className: "btn btn-primary"
, H.button { className: "btn btn-primary"
, on: {click: const $ setSelection StopTerm }
, on: {
click: const $ setSelection StopTerm }
} [ H.text "Stop" ]
} [ H.text "Stop" ]
, H.button { className: "btn btn-primary"
, H.button { className: "btn btn-primary"
, on: {click: const $ setSelection CandidateTerm }
, on: {
click: const $ setSelection CandidateTerm }
} [ H.text "Candidate" ]
} [ H.text "Candidate" ]
]
]
...
@@ -389,7 +388,7 @@ loadedNgramsTableSpecCpt = R.hooksComponent "G.C.NT.loadedNgramsTable" cpt
...
@@ -389,7 +388,7 @@ loadedNgramsTableSpecCpt = R.hooksComponent "G.C.NT.loadedNgramsTable" cpt
performAction ToggleSelectAll =
performAction ToggleSelectAll =
setState toggler
setState toggler
where
where
toggler s
@{ ngramsSelection }
=
toggler s =
if allNgramsSelected then
if allNgramsSelected then
s { ngramsSelection = Set.empty :: Set NgramsTerm }
s { ngramsSelection = Set.empty :: Set NgramsTerm }
else
else
...
...
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