diff options
author | Joris | 2018-06-24 22:02:00 +0200 |
---|---|---|
committer | Joris | 2018-06-24 22:02:00 +0200 |
commit | df83b634006c699cfa1e921bf74ce951a906a62f (patch) | |
tree | 65584291f8e93268326c6385df6c33d954b52199 | |
parent | 33b85b7f12798f5762d940ed5c30f775cdd7b751 (diff) |
Use date input type
-rw-r--r-- | client/src/Component/Button.hs | 10 | ||||
-rw-r--r-- | client/src/Component/Input.hs | 38 | ||||
-rw-r--r-- | client/src/View/Payment/Add.hs | 8 | ||||
-rw-r--r-- | client/src/View/Payment/Header.hs | 6 | ||||
-rw-r--r-- | client/src/View/SignIn.hs | 2 | ||||
-rw-r--r-- | tools.nix | 5 |
6 files changed, 34 insertions, 35 deletions
diff --git a/client/src/Component/Button.hs b/client/src/Component/Button.hs index bf604f1..46c0afa 100644 --- a/client/src/Component/Button.hs +++ b/client/src/Component/Button.hs @@ -31,20 +31,10 @@ defaultButtonIn content = ButtonIn , _buttonIn_submit = False } --- defaultButtonIn :: MonadWidget t m => ButtonIn t m --- defaultButtonIn = ButtonIn --- { _buttonIn_class = R.constDyn "" --- , _buttonIn_content = R.blank --- , _buttonIn_waiting = R.never --- , _buttonIn_tabIndex = Nothing --- , _buttonIn_submit = False --- } - data ButtonOut t = ButtonOut { _buttonOut_clic :: Event t () } - button :: forall t m. MonadWidget t m => ButtonIn t m -> m (ButtonOut t) button buttonIn = do dynWaiting <- R.holdDyn False $ _buttonIn_waiting buttonIn diff --git a/client/src/Component/Input.hs b/client/src/Component/Input.hs index 92f8ec9..c1eb4e8 100644 --- a/client/src/Component/Input.hs +++ b/client/src/Component/Input.hs @@ -17,16 +17,20 @@ import qualified Component.Button as Button import qualified Icon data InputIn t a b = InputIn - { _inputIn_reset :: Event t a - , _inputIn_label :: Text - , _inputIn_initialValue :: Text + { _inputIn_reset :: Event t a + , _inputIn_hasResetButton :: Bool + , _inputIn_label :: Text + , _inputIn_initialValue :: Text + , _inputIn_inputType :: Text } defaultInputIn :: (Reflex t) => InputIn t a b defaultInputIn = InputIn - { _inputIn_reset = R.never - , _inputIn_label = "" - , _inputIn_initialValue = "" + { _inputIn_reset = R.never + , _inputIn_hasResetButton = True + , _inputIn_label = "" + , _inputIn_initialValue = "" + , _inputIn_inputType = "text" } data InputOut t = InputOut @@ -40,11 +44,13 @@ input inputIn = rec let resetValue = R.leftmost [ fmap (const "") (_inputIn_reset inputIn) - , fmap (const "") (_buttonOut_clic reset) + , fmap (const "") resetClic ] attributes = R.ffor value (\v -> - if T.null v then M.empty else M.singleton "class" "filled") + if T.null v && _inputIn_inputType inputIn /= "date" + then M.empty + else M.singleton "class" "filled") value = R._textInput_value textInput @@ -52,14 +58,20 @@ input inputIn = & R.attributes .~ attributes & R.setValue .~ resetValue & R.textInputConfig_initialValue .~ (_inputIn_initialValue inputIn) + & R.textInputConfig_inputType .~ (_inputIn_inputType inputIn) R.el "label" $ R.text (_inputIn_label inputIn) - reset <- Button.button $ - (Button.defaultButtonIn Icon.cross) - { _buttonIn_class = R.constDyn "reset" - , _buttonIn_tabIndex = Just (-1) - } + resetClic <- + if _inputIn_hasResetButton inputIn + then + _buttonOut_clic <$> (Button.button $ + (Button.defaultButtonIn Icon.cross) + { _buttonIn_class = R.constDyn "reset" + , _buttonIn_tabIndex = Just (-1) + }) + else + return R.never let enter = fmap (const ()) $ R.ffilter ((==) 13) . R._textInput_keypress $ textInput diff --git a/client/src/View/Payment/Add.hs b/client/src/View/Payment/Add.hs index 2eaec0f..5ff09dd 100644 --- a/client/src/View/Payment/Add.hs +++ b/client/src/View/Payment/Add.hs @@ -8,6 +8,7 @@ import Control.Monad.IO.Class (liftIO) import qualified Data.Map as M import qualified Data.Maybe as Maybe import qualified Data.Text as T +import qualified Data.Time.Calendar as Calendar import qualified Data.Time.Clock as Time import Reflex.Dom (Event, MonadWidget) import qualified Reflex.Dom as R @@ -17,7 +18,6 @@ import Common.Model (Category (..), CreatePayment (..), Frequency (..)) import qualified Common.Msg as Msg import qualified Common.Util.Time as Time -import qualified Common.View.Format as Format import Component (ButtonIn (..), InputIn (..), InputOut (..), SelectIn (..), SelectOut (..)) @@ -49,8 +49,10 @@ view addIn = do date <- _inputOut_value <$> (Component.input $ Component.defaultInputIn - { _inputIn_label = Msg.get Msg.Payment_Cost - , _inputIn_initialValue = Format.shortDay currentDay + { _inputIn_label = Msg.get Msg.Payment_Date + , _inputIn_initialValue = T.pack . Calendar.showGregorian $ currentDay + , _inputIn_inputType = "date" + , _inputIn_hasResetButton = False }) frequency <- _selectOut_value <$> (Component.select $ SelectIn diff --git a/client/src/View/Payment/Header.hs b/client/src/View/Payment/Header.hs index d01dec6..fd46c25 100644 --- a/client/src/View/Payment/Header.hs +++ b/client/src/View/Payment/Header.hs @@ -104,10 +104,8 @@ payerAndAdd incomes payments users categories currency = do searchLine :: forall t m. MonadWidget t m => m (Dynamic t Text, Dynamic t Frequency) searchLine = do R.divClass "searchLine" $ do - searchName <- _inputOut_value <$> (Component.input $ InputIn - { _inputIn_reset = R.never - , _inputIn_label = Msg.get Msg.Search_Name - , _inputIn_initialValue = "" + searchName <- _inputOut_value <$> (Component.input $ Component.defaultInputIn + { _inputIn_label = Msg.get Msg.Search_Name }) let frequencies = M.fromList diff --git a/client/src/View/SignIn.hs b/client/src/View/SignIn.hs index 912aea2..21d0fcc 100644 --- a/client/src/View/SignIn.hs +++ b/client/src/View/SignIn.hs @@ -30,8 +30,10 @@ view signInMessage = rec input <- Component.input $ InputIn { _inputIn_reset = R.ffilter Either.isRight signInResult + , _inputIn_hasResetButton = True , _inputIn_label = Msg.get Msg.SignIn_EmailLabel , _inputIn_initialValue = "" + , _inputIn_inputType = "text" } button <- Component.button $ @@ -8,11 +8,6 @@ with import <nixpkgs> {}; { tmux tmuxinator stylish-haskell - # (import ./stylish-haskell { - # inherit mkDerivation aeson base bytestring containers directory filepath - # fetchFromGitHub haskell-src-exts mtl syb yaml stylish-haskell strict - # optparse-applicative HUnit test-framework test-framework-hunit stdenv; - # }) ]; }; } |