webapp: Fix bad interaction between required fields and modals.

This commit is contained in:
Joey Hess 2012-12-02 17:32:54 -04:00
parent c941523b63
commit 7b032dbbc8
14 changed files with 50 additions and 13 deletions

View file

@ -10,8 +10,9 @@ module Assistant.WebApp.Common (module X) where
import Assistant.Common as X
import Assistant.WebApp as X
import Assistant.WebApp.Page as X
import Assistant.WebApp.Form as X
import Assistant.WebApp.Types as X
import Utility.Yesod as X
import Data.Text as X (Text)
import Yesod as X hiding (textField, passwordField, insertBy, replace, joinPath, deleteBy, delete, insert, Key, Option)

View file

@ -25,7 +25,6 @@ import qualified Git
import Assistant.XMPP.Client
#endif
import Yesod
import qualified Data.Map as M
{- The main configuration screen. -}

View file

@ -5,7 +5,7 @@
- Licensed under the GNU AGPL version 3 or higher.
-}
{-# LANGUAGE CPP, TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}
{-# LANGUAGE CPP, FlexibleContexts, TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}
module Assistant.WebApp.Configurators.AWS where
@ -23,7 +23,6 @@ import Types.Remote (RemoteConfig)
import Types.StandardGroups
import Logs.PreferredContent
import Yesod
import qualified Data.Text as T
import qualified Data.Map as M
@ -74,6 +73,15 @@ s3InputAForm = AWSInput
, ("Reduced redundancy (costs less)", ReducedRedundancy)
]
textField' :: RenderMessage master FormMessage => Field sub master Text
textField' = Field
{ fieldParse = fieldParse textField
, fieldView = \theId name attrs val _isReq ->
[whamlet|
<input id="#{theId}" name="#{name}" *{attrs} type="text" value="#{either id id val}">
|]
}
glacierInputAForm :: AForm WebApp WebApp AWSInput
glacierInputAForm = AWSInput
<$> areq textField "Access Key ID" Nothing

View file

@ -25,7 +25,6 @@ import qualified Git
import qualified Git.Command
import qualified Git.Config
import Yesod
import qualified Data.Text as T
import qualified Data.Map as M
import qualified Data.Set as S

View file

@ -30,7 +30,6 @@ import Types.StandardGroups
import Logs.PreferredContent
import Utility.UserInfo
import Yesod
import qualified Data.Text as T
import Data.Char
import System.Posix.Directory

View file

@ -37,7 +37,6 @@ import Assistant.WebApp.Configurators.XMPP
import Utility.UserInfo
import Git
import Yesod
#ifdef WITH_PAIRING
import qualified Data.Text as T
import qualified Data.Text.Encoding as T

View file

@ -19,7 +19,6 @@ import Logs.PreferredContent
import Types.StandardGroups
import Utility.UserInfo
import Yesod
import qualified Data.Text as T
import qualified Data.Map as M
import Network.Socket

View file

@ -22,7 +22,6 @@ import Logs.PreferredContent
import Logs.Remote
import Creds
import Yesod
import qualified Data.Text as T
import qualified Data.Map as M

View file

@ -23,7 +23,6 @@ import Assistant.DaemonStatus
import Utility.SRV
#endif
import Yesod
#ifdef WITH_XMPP
import Network
import Network.Protocol.XMPP

View file

@ -22,7 +22,6 @@ import Types.Key
import qualified Remote
import qualified Git
import Yesod
import Text.Hamlet
import qualified Data.Map as M
import Control.Concurrent

View file

@ -13,8 +13,6 @@ import Assistant.WebApp.Common
import Assistant.Install (standaloneAppBase)
import Build.SysConfig (packageversion)
import Yesod
{- The full license info may be included in a file on disk that can
- be read in and displayed. -}
licenseFile :: IO (Maybe FilePath)

35
Assistant/WebApp/Form.hs Normal file
View file

@ -0,0 +1,35 @@
{- git-annex assistant webapp form utilities
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
{-# LANGUAGE FlexibleContexts, TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}
module Assistant.WebApp.Form where
import Yesod hiding (textField, passwordField)
import Yesod.Form.Fields as F
import Data.Text (Text)
{- Yesod's textField sets the required attribute for required fields.
- We don't want this, because many of the forms used in this webapp
- display a modal dialog when submitted, which interacts badly with
- required field handling by the browser.
-
- Required fields are still checked by Yesod.
-}
textField :: RenderMessage master FormMessage => Field sub master Text
textField = F.textField
{ fieldView = \theId name attrs val _isReq -> [whamlet|
<input id="#{theId}" name="#{name}" *{attrs} type="text" value="#{either id id val}">
|]
}
passwordField :: RenderMessage master FormMessage => Field sub master Text
passwordField = F.passwordField
{ fieldView = \theId name attrs val _isReq -> toWidget [hamlet|
<input id="#{theId}" name="#{name}" *{attrs} type="password" value="#{either id id val}">
|]
}

1
debian/changelog vendored
View file

@ -16,6 +16,7 @@ git-annex (3.20121128) UNRELEASED; urgency=low
* webdav: Avoid trying to set props, avoiding incompatability with
livedrive.com. Needs DAV version 0.3.
* webapp: Prettify error display.
* webapp: Fix bad interaction between required fields and modals.
-- Joey Hess <joeyh@debian.org> Wed, 28 Nov 2012 13:31:07 -0400

View file

@ -8,6 +8,8 @@ The webapp is a web server that displays a shiny interface.
This is quite likely because of how the div containing transfers is refereshed.
If instead javascript was used to update the progress bar etc for transfers
with json data, the buttons would work better.
* Some forms display a modal message when submitted and also have required
fields. This does not interact well.
## interface