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
6ef4fe73
Unverified
Commit
6ef4fe73
authored
Feb 26, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS-TABLE] filters should be stored in the loader since they impact the loaded URL
parent
cacef583
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
27 deletions
+45
-27
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+45
-27
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
6ef4fe73
...
...
@@ -66,10 +66,21 @@ type PageParams =
, listIds :: Array Int
, params :: T.Params
, tabType :: TabType
, searchQuery :: String
, termListFilter :: Maybe TermList -- Nothing means all
, termTypeFilter :: Maybe TermType -- Nothing means all
}
initialPageParams :: Int -> Array Int -> TabType -> PageParams
initialPageParams nodeId listIds tabType = {nodeId, listIds, params: T.initialParams, tabType}
initialPageParams nodeId listIds tabType =
{ nodeId
, listIds
, params: T.initialParams
, tabType
, termTypeFilter: Nothing
, termListFilter: Nothing
, searchQuery: ""
}
type Props' = Loader.InnerProps PageParams VersionedNgramsTable ()
...
...
@@ -366,9 +377,6 @@ type State =
-- This updates the children of `ngramsParent`,
-- ngrams set to `true` are to be added, and `false` to
-- be removed.
, searchQuery :: String
, termListFilter :: Maybe TermList -- Nothing means all
, termTypeFilter :: Maybe TermType -- Nothing means all
}
_ngramsChildren = prop (SProxy :: SProxy "ngramsChildren")
...
...
@@ -380,9 +388,6 @@ initialState {loaded: Versioned {version}} =
, ngramsVersion: version
, ngramsParent: Nothing
, ngramsChildren: mempty
, searchQuery: ""
, termListFilter: Nothing
, termTypeFilter: Nothing
}
data Action
...
...
@@ -397,21 +402,29 @@ data Action
-- ^ The NgramsTable argument is here as a cache of `ngramsTablePatch`
-- applied to `initTable`.
-- TODO more docs
| SetTermListFilter (Maybe TermList)
| SetTermTypeFilter (Maybe TermType)
| SetSearchQuery String
| Refresh
type Dispatch = Action -> Effect Unit
tableContainer :: { searchQuery :: String
type LoaderAction = Loader.Action PageParams
type LoaderDispatch = LoaderAction -> Effect Unit
tableContainer :: { pageParams :: PageParams
, dispatch :: Dispatch
, loaderDispatch :: LoaderDispatch
, ngramsParent :: Maybe NgramsTerm
, ngramsChildren :: Map NgramsTerm Boolean
, ngramsTable :: NgramsTable
}
-> T.TableContainerProps -> Array ReactElement
tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable: ngramsTableCache} props =
tableContainer { pageParams
, dispatch
, loaderDispatch
, ngramsParent
, ngramsChildren
, ngramsTable: ngramsTableCache
} props =
[ div [className "container-fluid"]
[ div [className "jumbotron1"]
[ div [className "row"]
...
...
@@ -427,28 +440,29 @@ tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable
[ button [_id "ImportListOrSaveAll", className "btn btn-warning", style {fontSize : "120%"}]
[ text "Import a Termlist" ]
]
, div [className "col-md-4", style {marginTop : "37px"}]
,-}
div [className "col-md-4", style {marginTop : "37px"}]
[ input [ className "form-control "
, _id "id_password"
, name "search", placeholder "Search"
, _type "value"
, value searchQuery
, onInput \e ->
dispatch (SetSearchQuery (unsafeEventValue e)
)
, value
pageParams.
searchQuery
, onInput \e ->
setSearchQuery (unsafeEventValue e
)
]
]
,-}
div [_id "filter_terms", className "col-md-6", style{ marginTop : "2.1em",paddingLeft :"1em"}]
, div [_id "filter_terms", className "col-md-6", style{ marginTop : "2.1em",paddingLeft :"1em"}]
[ div [className "col-md-10 list-group", style {marginTop : "6px"}]
[ li [className " list-group-item"]
[ select [ _id "picklistmenu"
, className "form-control custom-select"
, onChange (\e -> dispatch (SetTermListFilter $ readTermList $ unsafeEventValue e))
-- , value ?
, onChange (\e -> setTermListFilter $ readTermList $ unsafeEventValue e)
] $ map optps1 termLists
]
, li [className "list-group-item"]
[ select [ _id "picktermtype"
, className "form-control custom-select"
, onChange (\e -> dispatch (SetTermTypeFilter $ readTermType $ unsafeEventValue e))
-- , value ?
, onChange (\e -> setTermTypeFilter $ readTermType $ unsafeEventValue e)
] $ map optps1 termTypes
]
, li [className " list-group-item"] [ props.pageSizeControl ]
...
...
@@ -488,6 +502,11 @@ tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable
]
]
]
where
setPageParams f = loaderDispatch $ Loader.SetPath $ f pageParams
setSearchQuery x = setPageParams $ _ { searchQuery = x }
setTermListFilter x = setPageParams $ _ { termListFilter = x }
setTermTypeFilter x = setPageParams $ _ { termTypeFilter = x }
putTable :: {nodeId :: Int, listIds :: Array Int, tabType :: TabType} -> Versioned NgramsTablePatch -> Aff (Versioned NgramsTablePatch)
putTable {nodeId, listIds, tabType} =
...
...
@@ -514,9 +533,6 @@ ngramsTableSpec = simpleSpec performAction render
setParentResetChildren p = _ { ngramsParent = p, ngramsChildren = mempty }
performAction :: PerformAction State Props' Action
performAction (SetTermListFilter c) _ _ = modifyState_ $ _ { termListFilter = c }
performAction (SetTermTypeFilter c) _ _ = modifyState_ $ _ { termTypeFilter = c }
performAction (SetSearchQuery s) _ _ = modifyState_ $ _ { searchQuery = s }
performAction (SetParentResetChildren p) _ _ =
modifyState_ $ setParentResetChildren p
performAction (ToggleChild b c) _ _ =
...
...
@@ -548,18 +564,18 @@ ngramsTableSpec = simpleSpec performAction render
-- patch the root of the child to be equal to the root of the parent.
render :: Render State Props' Action
render dispatch { path:
{nodeId, listIds, tabType}
render dispatch { path:
pageParams
, loaded: Versioned { data: initTable }
, dispatch: loaderDispatch }
{ ngramsTablePatch, ngramsParent, ngramsChildren
, searchQuery
}
{ ngramsTablePatch, ngramsParent, ngramsChildren }
_reactChildren =
[ autoUpdateElt { duration: 3000
, effect: dispatch Refresh
}
, T.tableElt
{ rows
, setParams
: \params -> loaderDispatch (Loader.SetPath {nodeId, listIds, params, tabType})
, container: tableContainer {
searchQuery
, dispatch, ngramsParent, ngramsChildren, ngramsTable}
, setParams
, container: tableContainer {
pageParams, loaderDispatch
, dispatch, ngramsParent, ngramsChildren, ngramsTable}
, colNames:
T.ColumnName <$>
[ "Graph"
...
...
@@ -571,6 +587,8 @@ ngramsTableSpec = simpleSpec performAction render
}
]
where
setParams params =
loaderDispatch $ Loader.SetPath $ pageParams {params = params}
ngramsTable = applyNgramsTablePatch ngramsTablePatch initTable
rows = convertRow <$> Map.toUnfoldable (Map.filter displayRow (ngramsTable ^. _NgramsTable))
isRoot (NgramsElement e) = e.parent == Nothing
...
...
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