Commit e05ff3b4 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngrams] save/reset buttons

parent ecb2608c
...@@ -91,6 +91,7 @@ data Action ...@@ -91,6 +91,7 @@ data Action
| ToggleSelect NgramsTerm | ToggleSelect NgramsTerm
-- ^ Toggles the NgramsTerm in the `Set` `ngramsSelection`. -- ^ Toggles the NgramsTerm in the `Set` `ngramsSelection`.
| ToggleSelectAll | ToggleSelectAll
| ResetPatches
setTermListA :: NgramsTerm -> Replace TermList -> Action setTermListA :: NgramsTerm -> Replace TermList -> Action
setTermListA n patch_list = setTermListA n patch_list =
...@@ -305,7 +306,8 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render ...@@ -305,7 +306,8 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
syncPatches path state syncPatches path state
performAction (CommitPatch pt) _ {ngramsVersion} = performAction (CommitPatch pt) _ {ngramsVersion} =
commitPatch (Versioned {version: ngramsVersion, data: pt}) commitPatch (Versioned {version: ngramsVersion, data: pt})
performAction ResetPatches _ {ngramsVersion} =
modifyState_ $ \s -> s { ngramsLocalPatch = { ngramsNewElems: mempty, ngramsPatches: mempty } }
performAction AddTermChildren _ {ngramsParent: Nothing} = performAction AddTermChildren _ {ngramsParent: Nothing} =
-- impossible but harmless -- impossible but harmless
pure unit pure unit
...@@ -329,7 +331,7 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render ...@@ -329,7 +331,7 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
state@{ ngramsParent, ngramsChildren, ngramsLocalPatch state@{ ngramsParent, ngramsChildren, ngramsLocalPatch
, ngramsSelection, ngramsSelectAll } , ngramsSelection, ngramsSelectAll }
_reactChildren = _reactChildren =
(autoUpdate <> [ (autoUpdate <> resetSaveButtons <> [
R2.scuff $ T.table { colNames R2.scuff $ T.table { colNames
, container , container
, params: params /\ setParams -- TODO-LENS , params: params /\ setParams -- TODO-LENS
...@@ -340,6 +342,12 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render ...@@ -340,6 +342,12 @@ loadedNgramsTableSpec = Thermite.simpleSpec performAction render
]) ])
where where
autoUpdate = if withAutoUpdate then [ autoUpdateElt { duration: 5000, effect: dispatch Synchronize } ] else [] autoUpdate = if withAutoUpdate then [ autoUpdateElt { duration: 5000, effect: dispatch Synchronize } ] else []
resetButton = H.button { className: "btn btn-primary"
, on: { click: \_ -> dispatch ResetPatches } } [ H.text "Reset" ]
saveButton = H.button { className: "btn btn-primary"
, on: { click: \_ -> dispatch Synchronize }} [ H.text "Save" ]
resetSaveButtons = if ngramsLocalPatch == mempty then [] else
[ R2.scuff $ H.div {} [ resetButton, saveButton ] ]
totalRecords = A.length rows totalRecords = A.length rows
filteredRows = T.filterRows { params } rows filteredRows = T.filterRows { params } rows
colNames = T.ColumnName <$> ["Select", "Map", "Stop", "Terms", "Score"] -- see convOrderBy colNames = T.ColumnName <$> ["Select", "Map", "Stop", "Terms", "Score"] -- see convOrderBy
......
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