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
48c44695
Commit
48c44695
authored
Dec 11, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
[CONF] backdev by default on master.
parents
1048af55
9302fe74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
18 deletions
+22
-18
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+22
-18
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
48c44695
...
...
@@ -6,7 +6,7 @@ import Affjax.ResponseFormat (printResponseFormatError)
import Affjax.ResponseFormat as ResponseFormat
import Control.Monad.Cont.Trans (lift)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.?), (:=), (~>))
import Data.Array (drop, take, (:))
import Data.Array (drop, take, (:)
, filter
)
import Data.Either (Either(..))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
...
...
@@ -29,10 +29,9 @@ import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Table as T
import Gargantext.Utils.DecodeMaybe ((.|))
import React.DOM (a, br', button, div, i, input, p, text)
import React.DOM.Props (_type, className, href, onClick, placeholder, style, target)
import React.DOM.Props (_type, className, href, onClick, placeholder, style,
checked,
target)
import Thermite (PerformAction, Render, Spec, defaultPerformAction, modifyState_, simpleSpec, hideState)
------------------------------------------------------------------------
-- TODO: Pagination Details are not available from the BackEnd
-- TODO: Search is pending
-- TODO: Fav is pending
-- TODO: Sort is Pending
...
...
@@ -49,15 +48,16 @@ type Props =
-- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ngramtable. Let's see how this evolves.
}
-- TODO: When a pagination link is clicked, reload data.
type State =
{ documentIdsToDelete :: Set Int
, documentIdsDeleted :: Set Int
}
initialState :: State
initialState =
{ documentIdsToDelete: mempty
, documentIdsDeleted: mempty
}
data Action
...
...
@@ -156,20 +156,15 @@ layoutDocview = simpleSpec performAction render
--TODO add array of delete rows here
performAction (ToggleDocumentToDelete nid) _ _ =
modifyState_ \state -> state {documentIdsToDelete = toggleSet nid state.documentIdsToDelete}
performAction Trash {nodeId} {documentIdsToDelete} =
performAction Trash {nodeId} {documentIdsToDelete} =
do
void $ lift $ deleteDocuments nodeId (DeleteDocumentQuery {documents: Set.toUnfoldable documentIdsToDelete})
-- TODO: what to do now that the documents are deleted
-- * should we reload? NO (if you change page, yes and come back yes)
-- * should we locally update our data? YES
-- * should we reset documentIdsToDelete? YES
-- * if so, how to un-check the checkboxes since the inputs are uncontrolled?
-- + There is no need to uncheck them if they disapear because we
-- either reload or local update our data. YES
-- + Sync the checked value using (why check, just reset documentsIdsToDelete)
-- `checked: Set.member n state.documentIdsToDelete`
modifyState_ \{documentIdsToDelete, documentIdsDeleted} ->
{ documentIdsToDelete: mempty
, documentIdsDeleted: documentIdsDeleted <> documentIdsToDelete
}
render :: Render State Props Action
render dispatch {nodeId, tabType, totalRecords, chart}
_
_ =
render dispatch {nodeId, tabType, totalRecords, chart}
deletionState
_ =
[ br'
, div [ style {textAlign : "center"}] [ text " Filter "
, input [className "form-control", style {width : "120px", display : "inline-block"}, placeholder "Filter here"]
...
...
@@ -183,6 +178,7 @@ layoutDocview = simpleSpec performAction render
[ pageLoader
{ path: initialPageParams {nodeId, tabType}
, totalRecords
, deletionState
, dispatch
}
]
...
...
@@ -239,6 +235,7 @@ type PageLoaderProps row =
{ path :: PageParams
, totalRecords :: Int
, dispatch :: Action -> Effect Unit
, deletionState :: State
| row
}
...
...
@@ -246,11 +243,14 @@ renderPage :: forall props path.
Render (Loader.State {nodeId :: Int, tabType :: TabType | path} (Array DocumentsView))
{ totalRecords :: Int
, dispatch :: Action -> Effect Unit
, deletionState :: State
| props
}
(Loader.Action PageParams)
renderPage _ _ {loaded: Nothing} _ = [] -- TODO loading spinner
renderPage loaderDispatch {totalRecords, dispatch} {currentPath: {nodeId, tabType}, loaded: Just res} _ =
renderPage loaderDispatch { totalRecords, dispatch
, deletionState: {documentIdsToDelete, documentIdsDeleted}}
{currentPath: {nodeId, tabType}, loaded: Just res} _ =
[ T.tableElt
{ rows
, setParams: \params -> liftEffect $ loaderDispatch (Loader.SetPath {nodeId, tabType, params})
...
...
@@ -269,6 +269,8 @@ renderPage loaderDispatch {totalRecords, dispatch} {currentPath: {nodeId, tabTyp
where
fa true = "fas "
fa false = "far "
isChecked _id = Set.member _id documentIdsToDelete
isDeleted (DocumentsView {_id}) = Set.member _id documentIdsDeleted
rows = (\(DocumentsView r) ->
{ row:
[ div []
...
...
@@ -289,10 +291,12 @@ renderPage loaderDispatch {totalRecords, dispatch} {currentPath: {nodeId, tabTyp
div [style {textDecoration : "line-through"}] [ text r.source]
else
div [] [ text r.source]
, input [ _type "checkbox", onClick $ (\_ -> dispatch $ ToggleDocumentToDelete r._id)]
, input [ _type "checkbox"
, checked (isChecked r._id)
, onClick $ (\_ -> dispatch $ ToggleDocumentToDelete r._id)]
]
, delete: true
}) <$> res
}) <$>
filter (not <<< isDeleted)
res
pageLoaderClass :: ReactClass (PageLoaderProps (children :: Children))
pageLoaderClass = Loader.createLoaderClass' "PageLoader" loadPage renderPage
...
...
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