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
d8913830
Commit
d8913830
authored
Oct 26, 2020
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #213: Use applyNgramsPatches instead of applyNgramsTablePatch; cleanup
parent
d8729444
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
21 deletions
+22
-21
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+5
-3
Document.purs
src/Gargantext/Components/Nodes/Corpus/Document.purs
+17
-18
No files found.
src/Gargantext/Components/NgramsTable/Core.purs
View file @
d8913830
...
...
@@ -33,7 +33,7 @@ module Gargantext.Components.NgramsTable.Core
, _PatchMap
, patchSetFromMap
, applyPatchSet
, applyNgramsTablePatch
--, applyNgramsTablePatch -- re-export only if we have a good reason not to use applyNgramsPatches
, applyNgramsPatches
, rootsOf
, singletonPatchMap
...
...
@@ -501,7 +501,7 @@ derive instance eqReplace :: Eq a => Eq (Replace a)
instance semigroupReplace :: Eq a => Semigroup (Replace a) where
append Keep p = p
append p Keep = p
--
append (Replace { old }) (Replace { new }) | old /= new = unsafeThrow "old != new"
append (Replace { old }) (Replace { new }) | old /= new = unsafeThrow "old != new"
append (Replace { new }) (Replace { old }) = replace old new
instance semigroupMonoid :: Eq a => Monoid (Replace a) where
...
...
@@ -597,7 +597,9 @@ invert :: forall a. a -> a
invert _ = unsafeThrow "invert: TODO"
instance semigroupNgramsPatch :: Semigroup NgramsPatch where
append (NgramsReplace p) (NgramsReplace q) = ngramsReplace q.patch_old p.patch_new
append (NgramsReplace p) (NgramsReplace q)
| p.patch_old /= q.patch_new = unsafeThrow "append/NgramsPatch: old != new"
| otherwise = ngramsReplace q.patch_old p.patch_new
append (NgramsPatch p) (NgramsPatch q) = NgramsPatch
{ patch_children: p.patch_children <> q.patch_children
, patch_list: p.patch_list <> q.patch_list
...
...
src/Gargantext/Components/Nodes/Corpus/Document.purs
View file @
d8913830
...
...
@@ -4,6 +4,7 @@ import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (Aff)
...
...
@@ -17,7 +18,7 @@ import Gargantext.Components.Search (SearchType(..))
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.NgramsTable.Core
( CoreState, NgramsPatch(..), NgramsTerm, Replace, Versioned(..)
, VersionedNgramsTable, addNewNgram, applyNgrams
TablePatch
, commitPatch
, VersionedNgramsTable, addNewNgram, applyNgrams
Patches
, commitPatch
, loadNgramsTable, replace, singletonNgramsTablePatch, syncPatches )
import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Hooks.Loader (useLoader)
...
...
@@ -321,7 +322,10 @@ docView props = R.createElement docViewCpt props []
docViewCpt :: R.Component DocViewProps
docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
where
cpt props@{ loaded: loaded@{ ngramsTable: Versioned { data: initTable }, document }, state } _ = do
cpt { path
, loaded: loaded@{ ngramsTable: Versioned { data: initTable }, document }
, state: state@({ ngramsVersion: version } /\ _)
} _children = do
pure $ H.div {} [
autoUpdate { duration: 3000, effect: dispatch Synchronize }
, H.div { className: "container1" }
...
...
@@ -329,7 +333,7 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
R2.row
[
R2.col 8
[ H.h4 {} [ annotate
state
doc.title ]
[ H.h4 {} [ annotate doc.title ]
, H.ul { className: "list-group" }
[ li' [ H.span {} [ text' doc.source ]
, badge "source"
...
...
@@ -343,7 +347,7 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
]
]
, badge "abstract"
, annotate
state
doc.abstract
, annotate doc.abstract
, H.div { className: "jumbotron" }
[ H.p {} [ H.text "Empty Full Text" ]
]
...
...
@@ -354,29 +358,24 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
where
dispatch :: Action -> Effect Unit
dispatch (AddNewNgram ngram termList) = do
commitPatch (Versioned {version, data: pt}) state
where
({ ngramsVersion: version } /\ _) = state
pt = addNewNgram ngram termList
commitPatch (Versioned {version, data: addNewNgram ngram termList}) state
dispatch (SetTermListItem ngram termList) = do
commitPatch (Versioned {version, data: pt}) state
where
({ ngramsVersion: version } /\ _) = state
pe = NgramsPatch { patch_list: termList, patch_children: mempty }
pt = singletonNgramsTablePatch ngram pe
dispatch Synchronize = do
syncPatches p
rops.path props.
state (\_ -> pure unit)
annotate
state text = AnnotatedField.annotatedField { ngrams: ngramsTable state
, setTermList: setTermList state
, text }
syncPatches p
ath
state (\_ -> pure unit)
ngrams = applyNgramsPatches (fst state) initTable
annotate
text = AnnotatedField.annotatedField { ngrams
, setTermList
, text }
badge s = H.span { className: "badge badge-default badge-pill" } [ H.text s ]
li' = H.li { className: "list-group-item justify-content-between" }
ngramsTable ({ ngramsLocalPatch, ngramsValidPatch } /\ _) = applyNgramsTablePatch (ngramsLocalPatch <> ngramsValidPatch) initTable
setTermList state ngram Nothing newList = dispatch (AddNewNgram ngram newList)
setTermList state ngram (Just oldList) newList = dispatch (SetTermListItem ngram (replace oldList newList))
setTermList ngram Nothing newList = dispatch (AddNewNgram ngram newList)
setTermList ngram (Just oldList) newList = dispatch (SetTermListItem ngram (replace oldList newList))
text' x = H.text $ fromMaybe "Nothing" x
NodePoly {hyperdata
: Document doc} = document
NodePoly {hyperdata: Document doc} = document
type LayoutProps = (
corpusId :: Maybe Int
...
...
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