loading script only when needed

This commit is contained in:
nek0 2017-02-12 11:58:54 +01:00
parent db8e561704
commit 3a53ab0f24
3 changed files with 9 additions and 5 deletions

View file

@ -130,7 +130,7 @@ instance Yesod App where
]
mapM_ addScript $ map StaticR
[ js_crementing_js
, js_barcode_js
-- , js_barcode_js
]
$(widgetFile "default-layout")
withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet")

View file

@ -31,14 +31,16 @@ getHomeR = do
beverages <- runDB $ selectList [BeverageAmount !=. 0] [Desc BeverageIdent]
today <- liftIO $ utctDay <$> getCurrentTime
users <- runDB $ selectList [UserTimestamp >=. addDays (-30) today] [Asc UserIdent]
defaultLayout $
defaultLayout $ do
addScript $ StaticR js_barcode_js
$(widgetFile "home")
getReactivateR :: Handler Html
getReactivateR = do
today <- liftIO $ return . utctDay =<< getCurrentTime
users <- runDB $ selectList [UserTimestamp <. addDays (-30) today] [Asc UserIdent]
defaultLayout $
defaultLayout $ do
addScript $ StaticR js_barcode_js
$(widgetFile "reactivate")
getUserReactivateR :: UserId -> Handler Html

View file

@ -25,14 +25,16 @@ getSelectR uId =
isUser uId HomeR >>= (\user -> do
master <- getYesod
beverages <- runDB $ selectList [BeverageAmount >. 0] [Asc BeverageIdent]
defaultLayout $
defaultLayout $ do
addScript $ StaticR js_barcode_js
$(widgetFile "select")
)
getSelectCashR :: Handler Html
getSelectCashR = do
beverages <- runDB $ selectList [BeverageAmount >. 0] [Asc BeverageIdent]
defaultLayout $
defaultLayout $ do
addScript $ StaticR js_barcode_js
$(widgetFile "selectCash")
getRechargeR :: UserId -> Handler Html