diff options
author | Joris | 2016-04-05 13:39:48 +0200 |
---|---|---|
committer | Joris | 2016-04-05 13:39:48 +0200 |
commit | edca79a7e2bfed1a08de780cc6ab7eac430ef950 (patch) | |
tree | 02f794910924f1ca0114d08a254deed98388c70f /src/client/elm/LoggedIn/User | |
parent | d19b69eeeb0c24ee7e4a75b0da32eefba1d43928 (diff) |
Add a statistics empty page
Diffstat (limited to 'src/client/elm/LoggedIn/User')
-rw-r--r-- | src/client/elm/LoggedIn/User/Action.elm | 9 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/User/Model.elm | 46 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/User/Update.elm | 25 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/User/View.elm | 95 |
4 files changed, 0 insertions, 175 deletions
diff --git a/src/client/elm/LoggedIn/User/Action.elm b/src/client/elm/LoggedIn/User/Action.elm deleted file mode 100644 index c5f8d47..0000000 --- a/src/client/elm/LoggedIn/User/Action.elm +++ /dev/null @@ -1,9 +0,0 @@ -module LoggedIn.User.Action - ( Action(..) - ) where - -import Form exposing (Form) - -type Action = - NoOp - | AddIncomeAction Form.Action diff --git a/src/client/elm/LoggedIn/User/Model.elm b/src/client/elm/LoggedIn/User/Model.elm deleted file mode 100644 index 4f96a80..0000000 --- a/src/client/elm/LoggedIn/User/Model.elm +++ /dev/null @@ -1,46 +0,0 @@ -module LoggedIn.User.Model - ( Model - , AddIncome - , init - ) where - -import String exposing (toInt, split) -import Date exposing (Date) -import Date.Utils exposing (dateFromFields) -import Utils.Date exposing (numToMonth) - -import Form exposing (Form) -import Form.Validate as Validate exposing (..) -import Form.Error exposing (Error(InvalidString)) - -type alias Model = - { addIncome : Form () AddIncome - } - -type alias AddIncome = - { creation : Date - , amount : Int - } - -init : Model -init = - { addIncome = Form.initial [] validate - } - -validate : Validation () AddIncome -validate = - form2 AddIncome - (get "creation" dateValidation) - (get "amount" (int `andThen` (minInt 1))) - -dateValidation : Validation () Date -dateValidation = - customValidation string (\str -> - case split "/" str of - [day, month, year] -> - case (toInt day, toInt month, toInt year) of - (Ok dayNum, Ok monthNum, Ok yearNum) -> - Ok (dateFromFields yearNum (numToMonth monthNum) dayNum 0 0 0 0) - _ -> Err InvalidString - _ -> Err InvalidString - ) diff --git a/src/client/elm/LoggedIn/User/Update.elm b/src/client/elm/LoggedIn/User/Update.elm deleted file mode 100644 index f44fee4..0000000 --- a/src/client/elm/LoggedIn/User/Update.elm +++ /dev/null @@ -1,25 +0,0 @@ -module LoggedIn.User.Update - ( update - ) where - -import Effects exposing (Effects) -import Form exposing (Form) - -import LoggedData exposing (LoggedData) - -import LoggedIn.User.Model as UserModel -import LoggedIn.User.Action as UserAction - -update : LoggedData -> UserAction.Action -> UserModel.Model -> (UserModel.Model, Effects UserAction.Action) -update loggedData action model = - case action of - - UserAction.NoOp -> - ( model - , Effects.none - ) - - UserAction.AddIncomeAction formAction -> - ( { model | addIncome = Form.update formAction model.addIncome } - , Effects.none - ) diff --git a/src/client/elm/LoggedIn/User/View.elm b/src/client/elm/LoggedIn/User/View.elm deleted file mode 100644 index 74e2ae2..0000000 --- a/src/client/elm/LoggedIn/User/View.elm +++ /dev/null @@ -1,95 +0,0 @@ -module LoggedIn.User.View - ( view - ) where - -import Dict -import Date - -import Html exposing (..) -import Html.Events exposing (..) -import Html.Attributes exposing (..) -import Form exposing (Form) -import Form.Input as Input - -import LoggedData exposing (LoggedData) - -import Model.Income exposing (IncomeId, Income) -import Model.Translations exposing (getMessage) -import LoggedIn.User.Model as UserModel - -import Mailbox - -import Action -import LoggedIn.Action as LoggedInAction -import LoggedIn.User.Action as UserAction - -import LoggedIn.View.Date exposing (renderShortDate) -import LoggedIn.View.Price exposing (price) - -import Utils.Maybe exposing (isJust) - -view : LoggedData -> UserModel.Model -> Html -view loggedData userModel = - div - [] - [ h1 [] [ text <| getMessage "AddIncome" loggedData.translations ] - , addIncomeView loggedData userModel.addIncome - , h1 [] [ text <| getMessage "Incomes" loggedData.translations ] - , incomesView loggedData - ] - -addIncomeView : LoggedData -> Form () UserModel.AddIncome -> Html -addIncomeView loggedData addIncome = - let - formAddress = Signal.forwardTo Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.UserAction << UserAction.AddIncomeAction) - errorFor error field = - if isJust field.liveError - then div [ class "error" ] [ text (getMessage error loggedData.translations) ] - else text "" - creation = Form.getFieldAsString "creation" addIncome - amount = Form.getFieldAsString "amount" addIncome - in - div - [] - [ label [] [ text "Creation" ] - , Input.textInput creation formAddress [] - , errorFor "DateValidationError" creation - - , label [] [ text "amount" ] - , Input.textInput amount formAddress [] - , errorFor "IncomeValidationError" amount - - , button - [ case Form.getOutput addIncome of - Just data -> - onClick Mailbox.address (Action.UpdateLoggedIn <| LoggedInAction.AddIncome data.creation data.amount) - Nothing -> - onClick formAddress Form.Submit - ] - [ text (getMessage "Add" loggedData.translations) ] - ] - -incomesView : LoggedData -> Html -incomesView loggedData = - ol - [] - ( loggedData.incomes - |> Dict.toList - |> List.filter ((==) loggedData.me << .userId << snd) - |> List.sortBy (.creation << snd) - |> List.reverse - |> List.map (incomeView loggedData) - ) - -incomeView : LoggedData -> (IncomeId, Income) -> Html -incomeView loggedData (incomeId, income) = - li - [] - [ text <| renderShortDate (Date.fromTime income.creation) loggedData.translations - , text " − " - , text <| price loggedData.conf income.amount - , text " − " - , button - [ onClick Mailbox.address (Action.UpdateLoggedIn <| LoggedInAction.DeleteIncome incomeId) ] - [ text "x" ] - ] |