Commit 61907ea6 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[docstable, score] fix various merge issues

parent 3ea34423
Pipeline #1928 failed with stage
......@@ -43,6 +43,7 @@ import Gargantext.Utils (sortWith)
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.QueryString (joinQueryStrings, mQueryParam, mQueryParamS, queryParam, queryParamS)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as GUT
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
......@@ -407,17 +408,14 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
(\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel
mCurrentDocId' <- T.useLive T.unequal mCurrentDocId
<<<<<<< HEAD
reload <- GUR.new
=======
reload <- T.useBox GUT.newReload
localCategories' <- T.useLive T.unequal localCategories
>>>>>>> dev
pure $ TT.table
{ colNames
, container: TT.defaultContainer
, params
, rows: rows localCategories' mCurrentDocId'
, rows: rows reload localCategories' mCurrentDocId'
, syncResetButton : [ H.div {} [] ]
, totalRecords
, wrapColElts
......@@ -432,19 +430,10 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
| otherwise = Routes.Document sid listId
colNames = TT.ColumnName <$> [ "Show", "Tag", "Date", "Title", "Source", "Score" ]
wrapColElts = const identity
rows localCategories' mCurrentDocId' = row <$> A.toUnfoldable documents
rows reload localCategories' mCurrentDocId' = row reload <$> A.toUnfoldable documents
where
row dv@(DocumentsView r@{ _id, category }) =
row reload dv@(DocumentsView r@{ _id, category }) =
{ row:
<<<<<<< HEAD
T.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ]
H.div { className: "" }
[ docChooser { listId, mCorpusId, nodeId: r._id, selected, sidePanelTriggers, tableReload: reload } []
]
--, H.div { className: "column-tag flex" } [ caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } [] ]
, H.div { className: "column-tag flex" }
[ rating { score: cat, nodeId, row: dv, session, setLocalCategories } [] ]
=======
TT.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ]
H.div { className: "" }
[ docChooser { boxes
......@@ -460,7 +449,6 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
, score: cat
, setLocalCategories: \lc -> T.modify_ lc localCategories
, session } [] ]
>>>>>>> dev
--, H.input { type: "checkbox", defaultValue: checked, on: {click: click Trash} }
-- TODO show date: Year-Month-Day only
, H.div { className: tClassName } [ R2.showText r.date ]
......
......@@ -2,21 +2,24 @@ module Gargantext.Components.Score where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.:), (:=), (~>), encodeJson)
import Data.Int (fromString)
import Data.Either (Either)
import Data.Maybe (Maybe(..), maybe)
import DOM.Simple.Console (log2)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Simple.JSON as JSON
import Gargantext.Prelude
import Gargantext.Config.REST (RESTError)
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, sessionId, get, delete, put)
import Gargantext.Types as GT
import Gargantext.Utils.Array as GUA
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reload as GUR
import Gargantext.Utils.Toestand as GUT
type Score = Int
type DocID = Int
......@@ -30,7 +33,7 @@ type Props = (
, nodeId :: GT.NodeID
, score :: Maybe Score
, session :: Session
, tableReload :: GUR.ReloadS
, tableReload :: GUT.ReloadS
)
type Choice = Maybe Score
......@@ -53,7 +56,7 @@ scoreElCpt = R.hooksComponentWithModule thisModule "scoreEl" cpt
, score: readChoice $ R.unsafeEventValue e }
launchAff_ $ do
_ <- putScore session nodeId query
liftEffect $ GUR.bump reloadS
liftEffect $ GUT.reload reloadS
option :: Choice -> R.Element
option c = H.option { value: showChoice c } [ H.text $ showChoice c ]
......@@ -72,13 +75,11 @@ newtype ScoreQuery =
, score :: Choice
}
instance encodeJsonScoreQuery :: EncodeJson ScoreQuery where
encodeJson (ScoreQuery post) =
"nts_nodesId" := post.nodeIds
~> "nts_score" := encodeJson post.score
~> jsonEmptyObject
instance JSON.WriteForeign ScoreQuery where
writeImpl (ScoreQuery post) = JSON.writeImpl { nts_nodesId: post.nodeIds
, nts_score: post.score }
putScore :: Session -> GT.NodeID -> ScoreQuery -> Aff (Array Int)
putScore :: Session -> GT.NodeID -> ScoreQuery -> Aff (Either RESTError (Array Int))
putScore session nodeId = put session $ scoreRoute nodeId
where
scoreRoute :: GT.NodeID -> SessionRoute
......
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