diff options
| author | Joris | 2019-11-17 19:55:22 +0100 | 
|---|---|---|
| committer | Joris | 2019-11-17 19:55:22 +0100 | 
| commit | 3c67fcf1d524811a18f0c4db3ef6eed1270b9a12 (patch) | |
| tree | d0433d15c788d8add30aa828457ffb7a533ab926 /client/src/View/Payment/Form.hs | |
| parent | c0ea63f8c1a8c7123b78798cec99726b113fb1f3 (diff) | |
Hide date from monthly payments
Diffstat (limited to 'client/src/View/Payment/Form.hs')
| -rw-r--r-- | client/src/View/Payment/Form.hs | 51 | 
1 files changed, 28 insertions, 23 deletions
diff --git a/client/src/View/Payment/Form.hs b/client/src/View/Payment/Form.hs index 6c3c1e8..99dce13 100644 --- a/client/src/View/Payment/Form.hs +++ b/client/src/View/Payment/Form.hs @@ -43,10 +43,11 @@ import qualified Util.Validation           as ValidationUtil  data In t = In    { _in_categories :: [Category]    , _in_operation  :: Operation t +  , _in_frequency  :: Frequency    }  data Operation t -  = New (Dynamic t Frequency) +  = New    | Clone Payment    | Edit Payment @@ -92,18 +93,23 @@ view input cancel = do          (cost <$ reset)          confirm) -      d <- date - -      date <- Input._out_raw <$> (Input.view -        (Input.defaultIn -          { Input._in_label = Msg.get Msg.Payment_Date -          , Input._in_initialValue = d -          , Input._in_inputType = "date" -          , Input._in_hasResetButton = False -          , Input._in_validation = PaymentValidation.date -          }) -        (d <$ reset) -        confirm) +      currentDate <- date + +      date <- +        case frequency of +          Punctual -> do +            Input._out_raw <$> (Input.view +              (Input.defaultIn +                { Input._in_label = Msg.get Msg.Payment_Date +                , Input._in_initialValue = currentDate +                , Input._in_inputType = "date" +                , Input._in_hasResetButton = False +                , Input._in_validation = PaymentValidation.date +                }) +              (currentDate <$ reset) +              confirm) +          Monthly -> +            return . R.constDyn $ currentDate        setCategory <-          R.debounce  (1 :: NominalDiffTime) (R.updated $ Input._out_raw name) @@ -125,13 +131,12 @@ view input cancel = do          c <- cost          d <- date          cat <- category -        f <- frequency          return (mkPayload            <$> ValidationUtil.nelError n            <*> V.Success c            <*> V.Success d            <*> ValidationUtil.nelError cat -          <*> V.Success f) +          <*> V.Success frequency)      frequencies =        M.fromList @@ -144,7 +149,7 @@ view input cancel = do      category =        case op of -        New _   -> -1 +        New     -> -1          Clone p -> _payment_category p          Edit p  -> _payment_category p @@ -152,13 +157,13 @@ view input cancel = do      name =        case op of -        New _   -> "" +        New     -> ""          Clone p -> _payment_name p          Edit p  -> _payment_name p      cost =        case op of -        New _   -> "" +        New     -> ""          Clone p -> T.pack . show . _payment_cost $ p          Edit p  -> T.pack . show . _payment_cost $ p @@ -166,19 +171,19 @@ view input cancel = do        currentDay <- liftIO $ Clock.getCurrentTime >>= TimeUtil.timeToDay        return . T.pack . Calendar.showGregorian $          case op of -          New _   -> currentDay +          New     -> currentDay            Clone p -> currentDay            Edit p  -> _payment_date p      frequency =        case op of -        New f   -> f -        Clone p -> R.constDyn $ _payment_frequency p -        Edit p  -> R.constDyn $ _payment_frequency p +        New     -> _in_frequency input +        Clone p -> _payment_frequency p +        Edit p  -> _payment_frequency p      headerLabel =        case op of -        New _   -> Msg.get Msg.Payment_Add +        New     -> Msg.get Msg.Payment_Add          Clone _ -> Msg.get Msg.Payment_CloneLong          Edit _  -> Msg.get Msg.Payment_EditLong  | 
