aboutsummaryrefslogtreecommitdiff
path: root/webgui/src/Main.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-02-24 17:18:33 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-02-24 17:18:33 +0000
commitee0e38eba89bdc1a6b7b22b79b4693d35fa5f0a8 (patch)
treef998376ed58d317b2556882a29a91a7d1a0141b4 /webgui/src/Main.hs
parentd687710cb8f5a5ceb605d9859cd8ba76fb2c45a0 (diff)
downloadthermoprint-ee0e38eba89bdc1a6b7b22b79b4693d35fa5f0a8.tar
thermoprint-ee0e38eba89bdc1a6b7b22b79b4693d35fa5f0a8.tar.gz
thermoprint-ee0e38eba89bdc1a6b7b22b79b4693d35fa5f0a8.tar.bz2
thermoprint-ee0e38eba89bdc1a6b7b22b79b4693d35fa5f0a8.tar.xz
thermoprint-ee0e38eba89bdc1a6b7b22b79b4693d35fa5f0a8.zip
Style tweaks & discard -> save & clear
Diffstat (limited to 'webgui/src/Main.hs')
-rw-r--r--webgui/src/Main.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/webgui/src/Main.hs b/webgui/src/Main.hs
index 537dcf1..be2a0a1 100644
--- a/webgui/src/Main.hs
+++ b/webgui/src/Main.hs
@@ -179,7 +179,8 @@ setup Config{..} window (split -> (socketErr, dataUpdate)) = void $ do
179 ] 179 ]
180 | otherwise = True 180 | otherwise = True
181 discardAction = do 181 discardAction = do
182 maybe (return ()) draftDelete . associatedDraft =<< currentValue editorStatus 182 -- maybe (return ()) draftDelete . associatedDraft =<< currentValue editorStatus
183 saveAction False
183 modifyStatus $ const def 184 modifyStatus $ const def
184 printAction = do 185 printAction = do
185 emitError "Printing not implemented" 186 emitError "Printing not implemented"
@@ -235,8 +236,12 @@ setup Config{..} window (split -> (socketErr, dataUpdate)) = void $ do
235 table <- fatal' "Could not find draft table" =<< getElementById window "draftListBody" 236 table <- fatal' "Could not find draft table" =<< getElementById window "draftListBody"
236 initialContent <- toTable =<< drafts 237 initialContent <- toTable =<< drafts
237 return table # set children initialContent 238 return table # set children initialContent
239
240 recheckTimer <- timer
241 return recheckTimer # set interval 5000
242 start recheckTimer
238 243
239 onEvent (filterE concernsDrafts dataUpdate) . const $ drafts >>= toTable >>= (\c -> return table # set children c) 244 onEvent (unionWith const (() <$ filterE concernsDrafts dataUpdate) (tick recheckTimer)) . const $ drafts >>= toTable >>= (\c -> return table # set children c)
240 where 245 where
241 concernsDrafts :: URI -> Bool 246 concernsDrafts :: URI -> Bool
242 concernsDrafts (uriPath -> p) 247 concernsDrafts (uriPath -> p)
@@ -267,8 +272,9 @@ toStatusString :: EditorState -> String
267toStatusString EditorState{..} 272toStatusString EditorState{..}
268 | null eTitle 273 | null eTitle
269 , null eText = "Draft is empty" 274 , null eText = "Draft is empty"
270 | Just (t, _) <- lastSaved = "Last saved: " ++ formatTime defaultTimeLocale "%F %X" t 275 | Just (DraftId (show -> id)) <- associatedDraft
271 | otherwise = "Draft was never saved" 276 , Just (t, _) <- lastSaved = "Last saved: " ++ formatTime defaultTimeLocale "%F %X" t ++ " as #" ++ id
277 | otherwise = "Draft was never saved successfully"
272 278
273toStatusString' :: Either BBCodeError a -> String 279toStatusString' :: Either BBCodeError a -> String
274toStatusString' (Right _) = "" 280toStatusString' (Right _) = ""