From ee0e38eba89bdc1a6b7b22b79b4693d35fa5f0a8 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 24 Feb 2016 17:18:33 +0000 Subject: Style tweaks & discard -> save & clear --- webgui/src/Main.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'webgui/src/Main.hs') 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 ] | otherwise = True discardAction = do - maybe (return ()) draftDelete . associatedDraft =<< currentValue editorStatus + -- maybe (return ()) draftDelete . associatedDraft =<< currentValue editorStatus + saveAction False modifyStatus $ const def printAction = do emitError "Printing not implemented" @@ -235,8 +236,12 @@ setup Config{..} window (split -> (socketErr, dataUpdate)) = void $ do table <- fatal' "Could not find draft table" =<< getElementById window "draftListBody" initialContent <- toTable =<< drafts return table # set children initialContent + + recheckTimer <- timer + return recheckTimer # set interval 5000 + start recheckTimer - onEvent (filterE concernsDrafts dataUpdate) . const $ drafts >>= toTable >>= (\c -> return table # set children c) + onEvent (unionWith const (() <$ filterE concernsDrafts dataUpdate) (tick recheckTimer)) . const $ drafts >>= toTable >>= (\c -> return table # set children c) where concernsDrafts :: URI -> Bool concernsDrafts (uriPath -> p) @@ -267,8 +272,9 @@ toStatusString :: EditorState -> String toStatusString EditorState{..} | null eTitle , null eText = "Draft is empty" - | Just (t, _) <- lastSaved = "Last saved: " ++ formatTime defaultTimeLocale "%F %X" t - | otherwise = "Draft was never saved" + | Just (DraftId (show -> id)) <- associatedDraft + , Just (t, _) <- lastSaved = "Last saved: " ++ formatTime defaultTimeLocale "%F %X" t ++ " as #" ++ id + | otherwise = "Draft was never saved successfully" toStatusString' :: Either BBCodeError a -> String toStatusString' (Right _) = "" -- cgit v1.2.3