From 515338784b8fc2fb5435ee4e061c092ff754d6cf Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Thu, 24 Oct 2013 15:34:15 -0400 Subject: Use newer persistent and newer Yesod --- Handler/Category.hs | 8 ++++---- Handler/Home.hs | 2 +- Handler/User.hs | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'Handler') diff --git a/Handler/Category.hs b/Handler/Category.hs index 6a2c6df..73d9128 100644 --- a/Handler/Category.hs +++ b/Handler/Category.hs @@ -9,7 +9,7 @@ getCategoryR tcid = do cat <- runDB $ get404 tcid (formWidget, formEnctype) <- generateFormPost (timeCategoryForm cat) defaultLayout $ do - aDomId <- lift newIdent + aDomId <- newIdent (setTitle . toHtml) ("Time category " `T.append` timeCategoryName cat) $(widgetFile "categorypage") @@ -22,14 +22,14 @@ postCategoryR tcid = do _ -> return () defaultLayout $ do - aDomId <- lift newIdent + aDomId <- newIdent (setTitle . toHtml) ("Time category " `T.append` timeCategoryName cat) $(widgetFile "categorypage") -timeCategoryAForm :: TimeCategory -> AForm App App TimeCategory +timeCategoryAForm :: TimeCategory -> AForm Handler TimeCategory timeCategoryAForm tc = TimeCategory <$> pure (timeCategoryName tc) <*> areq checkBoxField "Disable" (Just (timeCategoryDisabled tc)) -timeCategoryForm :: TimeCategory -> Html -> MForm App App (FormResult TimeCategory, Widget) +timeCategoryForm :: TimeCategory -> Html -> MForm Handler (FormResult TimeCategory, Widget) timeCategoryForm tc h = renderDivs (timeCategoryAForm tc) h diff --git a/Handler/Home.hs b/Handler/Home.hs index 34078d5..247e55e 100644 --- a/Handler/Home.hs +++ b/Handler/Home.hs @@ -7,7 +7,7 @@ getHomeR :: Handler RepHtml getHomeR = do people <- runDB $ selectList [] [] defaultLayout $ do - aDomId <- lift newIdent + aDomId <- newIdent setTitle "Welcome To Yesod!" $(widgetFile "homepage") diff --git a/Handler/User.hs b/Handler/User.hs index e89b365..3d81f20 100644 --- a/Handler/User.hs +++ b/Handler/User.hs @@ -9,7 +9,7 @@ import Data.Time.Clock (getCurrentTime, UTCTime, utctDay) import Yesod.Auth (maybeAuth) import Yesod.Form.Jquery (jqueryDayField, def) -getUserR :: UserId -> Handler RepHtml +getUserR :: UserId -> Handler Html getUserR cid = do user <- runDB $ get404 cid ma <- maybeAuth @@ -27,11 +27,11 @@ getUserR cid = do employments <- runDB $ selectList [EmploymentUser ==. cid] [Asc EmploymentStartDate] (formWidget, formEnctype) <- generateFormPost (timeEntryForm cid cats) defaultLayout $ do - aDomId <- lift newIdent + aDomId <- newIdent (setTitle . toHtml) ("Time entries for " `T.append` username) $(widgetFile "userpage") -postUserR :: UserId -> Handler RepHtml +postUserR :: UserId -> Handler Html postUserR cid = do user <- runDB $ get404 cid ma <- maybeAuth @@ -53,11 +53,11 @@ postUserR cid = do entries <- runDB $ getEntriesForPage cid pageNumber defaultLayout $ do - aDomId <- lift newIdent + aDomId <- newIdent (setTitle . toHtml) ("Entry submitted for " `T.append` username) $(widgetFile "userpage") -timeEntryAForm :: UTCTime -> [(Text,TimeCategoryId)] -> UserId -> AForm App App TimeEntry +timeEntryAForm :: UTCTime -> [(Text,TimeCategoryId)] -> UserId -> AForm Handler TimeEntry timeEntryAForm ct cats uid = TimeEntry <$> pure uid <*> areq (selectFieldList cats) "category" Nothing @@ -66,17 +66,17 @@ timeEntryAForm ct cats uid = TimeEntry <*> areq textField "note" Nothing <*> pure ct -timeEntryForm :: UserId -> [(Text,TimeCategoryId)] -> Html -> MForm App App (FormResult TimeEntry, Widget) +timeEntryForm :: UserId -> [(Text,TimeCategoryId)] -> Html -> MForm Handler (FormResult TimeEntry, Widget) timeEntryForm u c h = do ct <- liftIO getCurrentTime renderDivs (timeEntryAForm ct c u) h -getEntriesForPage :: UserId -> Int -> YesodDB App App [(TimeCategoryId, TimeCategory, Text, Text, Text)] +-- getEntriesForPage :: UserId -> Int -> YesodDB m [(TimeCategoryId, TimeCategory, Text, Text, Text)] getEntriesForPage uid pageNumber = do entries <- selectList [TimeEntryUser ==. uid] [Desc TimeEntryTimestamp, LimitTo 25, OffsetBy ((pageNumber - 1) * 25)] mapM (\(Entity _ e) -> cat (timeEntryCategory e) >>= \x -> return (timeEntryCategory e, x, hours e, day e, timeEntryNote e)) entries where - cat :: TimeCategoryId -> YesodDB App App TimeCategory + -- cat :: TimeCategoryId -> YesodDB Handler TimeCategory cat y = do x <- getJust y return x day :: TimeEntry -> Text @@ -84,7 +84,7 @@ getEntriesForPage uid pageNumber = do hours :: TimeEntry -> Text hours = T.pack . show . timeEntryHours -pagePosition :: UserId -> GHandler App App (Int, Int) +pagePosition :: UserId -> Handler (Int, Int) pagePosition uid = do pageNumber <- fmap (either (const 1) id . fmap fst . fromMaybe (Right (1,"")) . fmap decimal) (lookupGetParam "page") cnt <- runDB $ count [TimeEntryUser ==. uid] -- cgit v1.2.3