packages feed

yesod-form 1.6.1 → 1.6.2

raw patch · 5 files changed

+69/−32 lines, 5 filesdep −networkdep −template-haskell

Dependencies removed: network, template-haskell

Files

ChangeLog.md view
@@ -1,3 +1,12 @@+# ChangeLog for yesod-form++## 1.6.2++* Move `addClass` from private/undocumented in `Yesod.Form.Bootstrap3` to `Yesod.Form.Functions` [#1510](https://github.com/yesodweb/yesod/pull/1510)+* Add `Yesod.Form.Functions.removeClass` [#1510](https://github.com/yesodweb/yesod/pull/1510)+* Changed `Textarea` to derive `IsString` [#1514](https://github.com/yesodweb/yesod/pull/1514)+* Expose `selectFieldHelper` [#1530](https://github.com/yesodweb/yesod/pull/1530)+ ## 1.6.1  * Explicitly define `(<>)` in the `Semigroup` instance for `Enctype`
Yesod/Form/Bootstrap3.hs view
@@ -33,9 +33,6 @@ import Data.Text (Text) import Data.String (IsString(..)) import Yesod.Core--import qualified Data.Text as T- import Yesod.Form.Types import Yesod.Form.Functions @@ -80,12 +77,6 @@ withSmallInput :: FieldSettings site -> FieldSettings site withSmallInput fs = fs { fsAttrs = newAttrs }     where newAttrs = addClass "input-sm" (fsAttrs fs)---addClass :: Text -> [(Text, Text)] -> [(Text, Text)]-addClass klass []                    = [("class", klass)]-addClass klass (("class", old):rest) = ("class", T.concat [old, " ", klass]) : rest-addClass klass (other         :rest) = other : addClass klass rest   -- | How many bootstrap grid columns should be taken (see
Yesod/Form/Fields.hs view
@@ -42,6 +42,7 @@     , fileAFormOpt       -- * Options       -- $optionsOverview+    , selectFieldHelper     , selectField     , selectFieldList     , radioField@@ -106,6 +107,8 @@  import Yesod.Persist.Core +import Data.String (IsString)+ #if !MIN_VERSION_base(4,8,0) import Data.Monoid #endif@@ -217,7 +220,7 @@ -- If this text is then placed verbatim into HTML, the lines won't be separated, thus the need for replacing with @\<br>@ tags). -- If you don't need this functionality, simply use 'unTextarea' to access the raw text. newtype Textarea = Textarea { unTextarea :: Text }-    deriving (Show, Read, Eq, PersistField, Ord, ToJSON, FromJSON)+    deriving (Show, Read, Eq, PersistField, Ord, ToJSON, FromJSON, IsString) instance PersistFieldSql Textarea where     sqlType _ = SqlString instance ToHtml Textarea where@@ -727,11 +730,15 @@         , optionExternalValue = toPathPiece key         }) pairs +-- |+-- A helper function for constucting 'selectField's. You may want to use this when you define your custom 'selectField's or 'radioField's.+--+-- @since 1.6.2 selectFieldHelper         :: (Eq a, RenderMessage site FormMessage)-        => (Text -> Text -> [(Text, Text)] -> WidgetFor site () -> WidgetFor site ())-        -> (Text -> Text -> Bool -> WidgetFor site ())-        -> (Text -> Text -> [(Text, Text)] -> Text -> Bool -> Text -> WidgetFor site ())+        => (Text -> Text -> [(Text, Text)] -> WidgetFor site () -> WidgetFor site ()) -- ^ Outermost part of the field+        -> (Text -> Text -> Bool -> WidgetFor site ()) -- ^ An option for None if the field is optional+        -> (Text -> Text -> [(Text, Text)] -> Text -> Bool -> Text -> WidgetFor site ()) -- ^ Other options         -> HandlerFor site (OptionList a)         -> Field (HandlerFor site) a selectFieldHelper outside onOpt inside opts' = Field
Yesod/Form/Functions.hs view
@@ -51,10 +51,13 @@     , parseHelper     , parseHelperGen     , convertField+    , addClass+    , removeClass     ) where  import Yesod.Form.Types import Data.Text (Text, pack)+import qualified Data.Text as T import Control.Arrow (second) import Control.Monad.Trans.Class import Control.Monad.Trans.RWS (ask, get, put, runRWST, tell, evalRWST, local, mapRWST)@@ -615,3 +618,33 @@   fParse' ts = fmap (fmap (fmap to)) . fParse ts   fView' ti tn at ei = fView ti tn at (fmap from ei)   in Field fParse' fView' fEnctype++-- | Removes a CSS class from the 'fsAttrs' in a 'FieldSettings'.+--+-- ==== __Examples__+--+-- >>> removeClass "form-control" [("class","form-control login-form"),("id","home-login")]+-- [("class","  login-form"),("id","home-login")]+--+-- @since 1.6.2+removeClass :: Text -- ^ The class to remove+            -> [(Text, Text)] -- ^ List of existing 'fsAttrs'+            -> [(Text, Text)]+removeClass _     []                    = []+removeClass klass (("class", old):rest) = ("class", T.replace klass " " old) : rest+removeClass klass (other         :rest) = other : removeClass klass rest++-- | Adds a CSS class to the 'fsAttrs' in a 'FieldSettings'.+--+-- ==== __Examples__+--+-- >>> addClass "login-form" [("class", "form-control"), ("id", "home-login")]+-- [("class","form-control login-form"),("id","home-login")]+--+-- @since 1.6.2+addClass :: Text -- ^ The class to add+         -> [(Text, Text)] -- ^ List of existing 'fsAttrs'+         -> [(Text, Text)]+addClass klass []                    = [("class", klass)]+addClass klass (("class", old):rest) = ("class", T.concat [old, " ", klass]) : rest+addClass klass (other         :rest) = other : addClass klass rest
yesod-form.cabal view
@@ -1,5 +1,5 @@ name:            yesod-form-version:         1.6.1+version:         1.6.2 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -20,33 +20,30 @@  library     build-depends:   base                  >= 4        && < 5-                   , yesod-core            >= 1.6      && < 1.7-                   , yesod-persistent      >= 1.6      && < 1.7-                   , time                  >= 1.1.4-                   , shakespeare           >= 2.0-                   , persistent-                   , template-haskell-                   , transformers          >= 0.2.2-                   , data-default-                   , xss-sanitize          >= 0.3.0.1+                   , aeson+                   , attoparsec            >= 0.10                    , blaze-builder         >= 0.2.1.4-                   , email-validate        >= 1.0-                   , bytestring            >= 0.9.1.4-                   , text                  >= 0.9-                   , wai                   >= 1.3-                   , containers            >= 0.2                    , blaze-html            >= 0.5                    , blaze-markup          >= 0.5.1-                   , attoparsec            >= 0.10                    , byteable-                   , aeson+                   , bytestring            >= 0.9.1.4+                   , containers            >= 0.2+                   , data-default+                   , email-validate        >= 1.0+                   , persistent                    , resourcet                    , semigroups+                   , shakespeare           >= 2.0+                   , text                  >= 0.9+                   , time                  >= 1.1.4+                   , transformers          >= 0.2.2+                   , wai                   >= 1.3+                   , xss-sanitize          >= 0.3.0.1+                   , yesod-core            >= 1.6      && < 1.7+                   , yesod-persistent      >= 1.6      && < 1.7      if flag(network-uri)       build-depends: network-uri >= 2.6-    else-      build-depends: network < 2.6      exposed-modules: Yesod.Form                      Yesod.Form.Types