Merge branch 'master' of github.com:bjornbm/yesod
Conflicts: yesod-form/Yesod/Form/Fields.hs
This commit is contained in:
commit
a065862828
@ -9,6 +9,6 @@ module Yesod.Form
|
||||
|
||||
import Yesod.Form.Types
|
||||
import Yesod.Form.Functions
|
||||
import Yesod.Form.Fields
|
||||
import Yesod.Form.Fields hiding (FormMessage (..))
|
||||
import Yesod.Form.Class
|
||||
import Yesod.Form.Input
|
||||
|
||||
@ -34,6 +34,7 @@ module Yesod.Form.Fields
|
||||
) where
|
||||
|
||||
import Yesod.Form.Types
|
||||
import Yesod.Form.I18n.English
|
||||
import Yesod.Widget
|
||||
import Yesod.Message (RenderMessage (renderMessage), SomeMessage (..))
|
||||
import Text.Hamlet
|
||||
@ -58,7 +59,6 @@ import qualified Data.ByteString as S
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import Data.Text (Text, unpack, pack)
|
||||
import qualified Data.Text.Read
|
||||
import Data.Monoid (mappend)
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
|
||||
import Control.Applicative ((<$>))
|
||||
@ -80,44 +80,9 @@ import Yesod.Request (FileInfo)
|
||||
#define HTML $html
|
||||
#endif
|
||||
|
||||
data FormMessage = MsgInvalidInteger Text
|
||||
| MsgInvalidNumber Text
|
||||
| MsgInvalidEntry Text
|
||||
| MsgInvalidUrl Text
|
||||
| MsgInvalidEmail Text
|
||||
| MsgInvalidTimeFormat
|
||||
| MsgInvalidHour Text
|
||||
| MsgInvalidMinute Text
|
||||
| MsgInvalidSecond Text
|
||||
| MsgInvalidDay
|
||||
| MsgCsrfWarning
|
||||
| MsgValueRequired
|
||||
| MsgInputNotFound Text
|
||||
| MsgSelectNone
|
||||
| MsgInvalidBool Text
|
||||
| MsgBoolYes
|
||||
| MsgBoolNo
|
||||
| MsgDelete
|
||||
|
||||
defaultFormMessage :: FormMessage -> Text
|
||||
defaultFormMessage (MsgInvalidInteger t) = "Invalid integer: " `mappend` t
|
||||
defaultFormMessage (MsgInvalidNumber t) = "Invalid number: " `mappend` t
|
||||
defaultFormMessage (MsgInvalidEntry t) = "Invalid entry: " `mappend` t
|
||||
defaultFormMessage MsgInvalidTimeFormat = "Invalid time, must be in HH:MM[:SS] format"
|
||||
defaultFormMessage MsgInvalidDay = "Invalid day, must be in YYYY-MM-DD format"
|
||||
defaultFormMessage (MsgInvalidUrl t) = "Invalid URL: " `mappend` t
|
||||
defaultFormMessage (MsgInvalidEmail t) = "Invalid e-mail address: " `mappend` t
|
||||
defaultFormMessage (MsgInvalidHour t) = "Invalid hour: " `mappend` t
|
||||
defaultFormMessage (MsgInvalidMinute t) = "Invalid minute: " `mappend` t
|
||||
defaultFormMessage (MsgInvalidSecond t) = "Invalid second: " `mappend` t
|
||||
defaultFormMessage MsgCsrfWarning = "As a protection against cross-site request forgery attacks, please confirm your form submission."
|
||||
defaultFormMessage MsgValueRequired = "Value is required"
|
||||
defaultFormMessage (MsgInputNotFound t) = "Input not found: " `mappend` t
|
||||
defaultFormMessage MsgSelectNone = "<None>"
|
||||
defaultFormMessage (MsgInvalidBool t) = "Invalid boolean: " `mappend` t
|
||||
defaultFormMessage MsgBoolYes = "Yes"
|
||||
defaultFormMessage MsgBoolNo = "No"
|
||||
defaultFormMessage MsgDelete = "Delete?"
|
||||
defaultFormMessage = englishFormMessage
|
||||
|
||||
blank :: (Monad m, RenderMessage master FormMessage)
|
||||
=> (Text -> Either FormMessage a) -> [Text] -> m (Either (SomeMessage master) (Maybe a))
|
||||
|
||||
@ -34,7 +34,6 @@ module Yesod.Form.Functions
|
||||
) where
|
||||
|
||||
import Yesod.Form.Types
|
||||
import Yesod.Form.Fields (FormMessage (MsgCsrfWarning, MsgValueRequired))
|
||||
import Data.Text (Text, pack)
|
||||
import Control.Monad.Trans.RWS (ask, get, put, runRWST, tell, evalRWST)
|
||||
import Control.Monad.Trans.Class (lift)
|
||||
|
||||
26
yesod-form/Yesod/Form/I18n/English.hs
Normal file
26
yesod-form/Yesod/Form/I18n/English.hs
Normal file
@ -0,0 +1,26 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Yesod.Form.I18n.English where
|
||||
|
||||
import Yesod.Form.Types (FormMessage (..))
|
||||
import Data.Monoid (mappend)
|
||||
import Data.Text (Text)
|
||||
|
||||
englishFormMessage :: FormMessage -> Text
|
||||
englishFormMessage (MsgInvalidInteger t) = "Invalid integer: " `mappend` t
|
||||
englishFormMessage (MsgInvalidNumber t) = "Invalid number: " `mappend` t
|
||||
englishFormMessage (MsgInvalidEntry t) = "Invalid entry: " `mappend` t
|
||||
englishFormMessage MsgInvalidTimeFormat = "Invalid time, must be in HH:MM[:SS] format"
|
||||
englishFormMessage MsgInvalidDay = "Invalid day, must be in YYYY-MM-DD format"
|
||||
englishFormMessage (MsgInvalidUrl t) = "Invalid URL: " `mappend` t
|
||||
englishFormMessage (MsgInvalidEmail t) = "Invalid e-mail address: " `mappend` t
|
||||
englishFormMessage (MsgInvalidHour t) = "Invalid hour: " `mappend` t
|
||||
englishFormMessage (MsgInvalidMinute t) = "Invalid minute: " `mappend` t
|
||||
englishFormMessage (MsgInvalidSecond t) = "Invalid second: " `mappend` t
|
||||
englishFormMessage MsgCsrfWarning = "As a protection against cross-site request forgery attacks, please confirm your form submission."
|
||||
englishFormMessage MsgValueRequired = "Value is required"
|
||||
englishFormMessage (MsgInputNotFound t) = "Input not found: " `mappend` t
|
||||
englishFormMessage MsgSelectNone = "<None>"
|
||||
englishFormMessage (MsgInvalidBool t) = "Invalid boolean: " `mappend` t
|
||||
englishFormMessage MsgBoolYes = "Yes"
|
||||
englishFormMessage MsgBoolNo = "No"
|
||||
englishFormMessage MsgDelete = "Delete?"
|
||||
26
yesod-form/Yesod/Form/I18n/Swedish.hs
Normal file
26
yesod-form/Yesod/Form/I18n/Swedish.hs
Normal file
@ -0,0 +1,26 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Yesod.Form.I18n.Swedish where
|
||||
|
||||
import Yesod.Form.Types (FormMessage (..))
|
||||
import Data.Monoid (mappend)
|
||||
import Data.Text (Text)
|
||||
|
||||
swedishFormMessage :: FormMessage -> Text
|
||||
swedishFormMessage (MsgInvalidInteger t) = "Ogiltigt antal: " `mappend` t
|
||||
swedishFormMessage (MsgInvalidNumber t) = "Ogiltigt nummer: " `mappend` t
|
||||
swedishFormMessage (MsgInvalidEntry t) = "Invalid entry: " `mappend` t
|
||||
swedishFormMessage MsgInvalidTimeFormat = "Ogiltigt klockslag, måste vara på formatet HH:MM[:SS]"
|
||||
swedishFormMessage MsgInvalidDay = "Ogiltigt datum, måste vara på formatet ÅÅÅÅ-MM-DD"
|
||||
swedishFormMessage (MsgInvalidUrl t) = "Ogiltig URL: " `mappend` t
|
||||
swedishFormMessage (MsgInvalidEmail t) = "Ogiltig epostadress: " `mappend` t
|
||||
swedishFormMessage (MsgInvalidHour t) = "Ogiltig timme: " `mappend` t
|
||||
swedishFormMessage (MsgInvalidMinute t) = "Ogiltig minut: " `mappend` t
|
||||
swedishFormMessage (MsgInvalidSecond t) = "Ogiltig sekund: " `mappend` t
|
||||
swedishFormMessage MsgValueRequired = "Fältet är obligatoriskt"
|
||||
swedishFormMessage (MsgInputNotFound t) = "Fältet hittades ej: " `mappend` t
|
||||
swedishFormMessage MsgSelectNone = "<Ingenting>"
|
||||
swedishFormMessage (MsgInvalidBool t) = "Ogiltig boolesk: " `mappend` t
|
||||
swedishFormMessage MsgBoolYes = "Ja"
|
||||
swedishFormMessage MsgBoolNo = "Nej"
|
||||
swedishFormMessage MsgDelete = "Radera?"
|
||||
swedishFormMessage MsgCsrfWarning = "Som skydd mot \"cross-site request forgery\" attacker, vänligen bekräfta skickandet av formuläret."
|
||||
@ -9,7 +9,6 @@ module Yesod.Form.Input
|
||||
) where
|
||||
|
||||
import Yesod.Form.Types
|
||||
import Yesod.Form.Fields (FormMessage (MsgInputNotFound))
|
||||
import Data.Text (Text)
|
||||
import Control.Applicative (Applicative (..))
|
||||
import Yesod.Handler (GHandler, GGHandler, invalidArgs, runRequestBody, getRequest, getYesod, liftIOHandler)
|
||||
|
||||
@ -11,7 +11,7 @@ module Yesod.Form.MassInput
|
||||
|
||||
import Yesod.Form.Types
|
||||
import Yesod.Form.Functions
|
||||
import Yesod.Form.Fields (boolField, FormMessage (MsgDelete))
|
||||
import Yesod.Form.Fields (boolField)
|
||||
import Yesod.Widget (GWidget, whamlet)
|
||||
import Yesod.Message (RenderMessage)
|
||||
import Yesod.Handler (newIdent, GGHandler)
|
||||
|
||||
@ -5,6 +5,7 @@ module Yesod.Form.Types
|
||||
( -- * Helpers
|
||||
Enctype (..)
|
||||
, FormResult (..)
|
||||
, FormMessage (..)
|
||||
, Env
|
||||
, FileEnv
|
||||
, Ints (..)
|
||||
@ -121,3 +122,22 @@ data Field sub master a = Field
|
||||
-> Bool
|
||||
-> GWidget sub master ()
|
||||
}
|
||||
|
||||
data FormMessage = MsgInvalidInteger Text
|
||||
| MsgInvalidNumber Text
|
||||
| MsgInvalidEntry Text
|
||||
| MsgInvalidUrl Text
|
||||
| MsgInvalidEmail Text
|
||||
| MsgInvalidTimeFormat
|
||||
| MsgInvalidHour Text
|
||||
| MsgInvalidMinute Text
|
||||
| MsgInvalidSecond Text
|
||||
| MsgInvalidDay
|
||||
| MsgCsrfWarning
|
||||
| MsgValueRequired
|
||||
| MsgInputNotFound Text
|
||||
| MsgSelectNone
|
||||
| MsgInvalidBool Text
|
||||
| MsgBoolYes
|
||||
| MsgBoolNo
|
||||
| MsgDelete
|
||||
|
||||
@ -42,6 +42,8 @@ library
|
||||
Yesod.Form.Jquery
|
||||
Yesod.Form.Nic
|
||||
Yesod.Form.MassInput
|
||||
Yesod.Form.I18n.English
|
||||
Yesod.Form.I18n.Swedish
|
||||
-- FIXME Yesod.Helpers.Crud
|
||||
ghc-options: -Wall
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user