Commit bcd18e87 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[NGRAMSTABLE] WIP fix default behavior.

parent eef156fc
...@@ -343,7 +343,7 @@ loadPage session {nodeId, tabType, query, listId, corpusId, params: {limit, offs ...@@ -343,7 +343,7 @@ loadPage session {nodeId, tabType, query, listId, corpusId, params: {limit, offs
let docs = res2corpus <$> res.docs let docs = res2corpus <$> res.docs
pure $ pure $
if mock then if mock then
Tuple 4737 (take limit $ drop offset sampleData) Tuple 0 (take limit $ drop offset sampleData)
else else
Tuple res.count docs Tuple res.count docs
where where
......
...@@ -96,10 +96,10 @@ toHtml reload treeState@(ts@{tree: (NTree (LNode {id, name, nodeType}) ary), asy ...@@ -96,10 +96,10 @@ toHtml reload treeState@(ts@{tree: (NTree (LNode {id, name, nodeType}) ary), asy
pAction = performAction session reload openNodes treeState pAction = performAction session reload openNodes treeState
cpt props _ = do cpt props _ = do
let folderIsOpen = Set.member id (fst openNodes) let folderIsOpen = Set.member id (fst openNodes)
let setFn = if folderIsOpen then Set.delete else Set.insert let setFn = if folderIsOpen then Set.delete else Set.insert
let toggleFolderIsOpen _ = (snd openNodes) (setFn id) let toggleFolderIsOpen _ = (snd openNodes) (setFn id)
let folderOpen = Tuple folderIsOpen toggleFolderIsOpen let folderOpen = Tuple folderIsOpen toggleFolderIsOpen
let withId (NTree (LNode {id: id'}) _) = id' let withId (NTree (LNode {id: id'}) _) = id'
......
...@@ -57,10 +57,10 @@ nodeMainSpan d p folderOpen session frontends = R.createElement el p [] ...@@ -57,10 +57,10 @@ nodeMainSpan d p folderOpen session frontends = R.createElement el p []
el = R.hooksComponent "NodeMainSpan" cpt el = R.hooksComponent "NodeMainSpan" cpt
cpt props@{id, asyncTasks, mCurrentRoute, name, nodeType, onAsyncTaskFinish} _ = do cpt props@{id, asyncTasks, mCurrentRoute, name, nodeType, onAsyncTaskFinish} _ = do
-- only 1 popup at a time is allowed to be opened -- only 1 popup at a time is allowed to be opened
popupOpen <- R.useState' (Nothing :: Maybe NodePopup) popupOpen <- R.useState' (Nothing :: Maybe NodePopup)
popupPosition <- R.useState' (Nothing :: Maybe R2.Point) popupPosition <- R.useState' (Nothing :: Maybe R2.Point)
droppedFile <- R.useState' (Nothing :: Maybe DroppedFile) droppedFile <- R.useState' (Nothing :: Maybe DroppedFile)
isDragOver <- R.useState' false isDragOver <- R.useState' false
pure $ H.span (dropProps droppedFile isDragOver) $ pure $ H.span (dropProps droppedFile isDragOver) $
[ folderIcon nodeType folderOpen [ folderIcon nodeType folderOpen
......
...@@ -167,7 +167,10 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath ...@@ -167,7 +167,10 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
, H.div {} ( , H.div {} (
if A.null props.tableBody && searchQuery /= "" then [ if A.null props.tableBody && searchQuery /= "" then [
H.button { className: "btn btn-primary" H.button { className: "btn btn-primary"
, on: {click: const $ dispatch $ addNewNgramA $ normNgram tabNgramType searchQuery} , on: {click: const $ dispatch
$ addNewNgramA
$ normNgram tabNgramType searchQuery
}
} }
[ H.text ("Add " <> searchQuery) ] [ H.text ("Add " <> searchQuery) ]
] else [])] ] else [])]
...@@ -204,7 +207,7 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath ...@@ -204,7 +207,7 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
ngramsClick {depth: 1, ngrams: child} = ngramsClick {depth: 1, ngrams: child} =
Just $ dispatch $ ToggleChild false child Just $ dispatch $ ToggleChild false child
ngramsClick _ = Nothing ngramsClick _ = Nothing
ngramsEdit _ = Nothing ngramsEdit _ = Nothing
in in
[ H.p {} [H.text $ "Editing " <> ngramsTermText ngrams] [ H.p {} [H.text $ "Editing " <> ngramsTermText ngrams]
, R2.buff $ renderNgramsTree { ngramsTable, ngrams, ngramsStyle: [], ngramsClick, ngramsEdit } , R2.buff $ renderNgramsTree { ngramsTable, ngrams, ngramsStyle: [], ngramsClick, ngramsEdit }
...@@ -336,7 +339,7 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render ...@@ -336,7 +339,7 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
} }
] ]
where where
totalRecords = 47361 -- TODO totalRecords = 0 -- TODO, 0 to show first users that it is fake (until it is fixed)
colNames = T.ColumnName <$> ["Select", "Map", "Stop", "Terms", "Score"] -- see convOrderBy colNames = T.ColumnName <$> ["Select", "Map", "Stop", "Terms", "Score"] -- see convOrderBy
selected = selected =
input input
...@@ -354,7 +357,7 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render ...@@ -354,7 +357,7 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
ngramsTable = applyNgramsPatches state initTable ngramsTable = applyNgramsPatches state initTable
orderWith = orderWith =
case convOrderBy <$> params.orderBy of case convOrderBy <$> params.orderBy of
Just ScoreAsc -> A.sortWith \x -> (snd x) ^. _NgramsElement <<< _occurrences Just ScoreAsc -> A.sortWith \x -> (snd x) ^. _NgramsElement <<< _occurrences
Just ScoreDesc -> A.sortWith \x -> Down $ (snd x) ^. _NgramsElement <<< _occurrences Just ScoreDesc -> A.sortWith \x -> Down $ (snd x) ^. _NgramsElement <<< _occurrences
_ -> identity -- the server ordering is enough here _ -> identity -- the server ordering is enough here
...@@ -365,7 +368,12 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render ...@@ -365,7 +368,12 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
ngramsParentRoot :: Maybe NgramsTerm ngramsParentRoot :: Maybe NgramsTerm
ngramsParentRoot = ngramsParentRoot =
(\np -> ngramsTable ^? at np <<< _Just <<< _NgramsElement <<< _root <<< _Just) =<< ngramsParent (\np -> ngramsTable ^? at np
<<< _Just
<<< _NgramsElement
<<< _root
<<< _Just
) =<< ngramsParent
displayRow (NgramsElement {ngrams, root}) = displayRow (NgramsElement {ngrams, root}) =
root == Nothing root == Nothing
......
...@@ -180,13 +180,13 @@ _list = prop (SProxy :: SProxy "list") ...@@ -180,13 +180,13 @@ _list = prop (SProxy :: SProxy "list")
derive instance newtypeNgramsElement :: Newtype NgramsElement _ derive instance newtypeNgramsElement :: Newtype NgramsElement _
_NgramsElement :: Iso' NgramsElement { _NgramsElement :: Iso' NgramsElement {
children :: Set NgramsTerm children :: Set NgramsTerm
, list :: TermList , list :: TermList
, ngrams :: NgramsTerm , ngrams :: NgramsTerm
, occurrences :: Int , occurrences :: Int
, parent :: Maybe NgramsTerm , parent :: Maybe NgramsTerm
, root :: Maybe NgramsTerm , root :: Maybe NgramsTerm
} }
_NgramsElement = _Newtype _NgramsElement = _Newtype
......
...@@ -57,4 +57,4 @@ ngramsViewCpt = R.staticComponent "ListsNgramsView" cpt ...@@ -57,4 +57,4 @@ ngramsViewCpt = R.staticComponent "ListsNgramsView" cpt
chart Authors = pie {session, path} chart Authors = pie {session, path}
chart Sources = bar {session, path} chart Sources = bar {session, path}
chart Institutes = tree {session, path: path2} chart Institutes = tree {session, path: path2}
chart Terms = metrics {session, path: path2} chart Terms = metrics {session, path: path2}
...@@ -79,7 +79,7 @@ type TableHeaderLayoutProps = ...@@ -79,7 +79,7 @@ type TableHeaderLayoutProps =
) )
initialParams :: Params initialParams :: Params
initialParams = stateParams {page: 1, pageSize: PS10, orderBy: Nothing} initialParams = stateParams {page: 1, pageSize: PS10, orderBy: Just (DESC $ ColumnName "Score")}
-- TODO: Not sure this is the right place for this -- TODO: Not sure this is the right place for this
tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element
......
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