From 166cd04e4b28770ede854dafc9ae30eae64102fe Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 28 Mar 2016 17:51:14 +0200 Subject: Create an empty but reachable user page --- src/client/elm/LoggedIn/Account/View.elm | 131 ------------------------------- 1 file changed, 131 deletions(-) delete mode 100644 src/client/elm/LoggedIn/Account/View.elm (limited to 'src/client/elm/LoggedIn/Account/View.elm') diff --git a/src/client/elm/LoggedIn/Account/View.elm b/src/client/elm/LoggedIn/Account/View.elm deleted file mode 100644 index 5d96da6..0000000 --- a/src/client/elm/LoggedIn/Account/View.elm +++ /dev/null @@ -1,131 +0,0 @@ -module LoggedIn.Account.View - ( view - ) where - -import List -import Signal exposing (Address) - -import Html exposing (..) -import Html as H exposing (..) -import Html.Attributes exposing (..) -import Html.Events exposing (..) - -import LoggedIn.Action as LoggedInAction -import LoggedIn.Model as LoggedInModel -import LoggedIn.Model.Payer exposing (..) -import LoggedIn.View.Price exposing (price) -import LoggedIn.View.Expand exposing (..) - -import LoggedIn.Account.Action as AccountAction -import LoggedIn.Account.Model as AccountModel - -import Model exposing (Model) -import Model.User exposing (getUserName) -import Model.Translations exposing (getParamMessage, getMessage) -import Action exposing (..) - -import View.Events exposing (onSubmitPrevDefault) - -import Utils.Either exposing (toMaybeError) - -view : Address Action -> Model -> LoggedInModel.Model -> Html -view address model loggedInModel = - let account = loggedInModel.account - in div - [ classList - [ ("account", True) - , ("detail", account.visibleDetail) - ] - ] - [ exceedingPayers address model loggedInModel - , if account.visibleDetail - then income address model account - else text "" - ] - -exceedingPayers : Address Action -> Model -> LoggedInModel.Model -> Html -exceedingPayers address model loggedInModel = - button - [ class "header" - , onClick address (UpdateLoggedIn << LoggedInAction.UpdateAccount <| AccountAction.ToggleDetail) - ] - ( (List.map (exceedingPayer model loggedInModel) (getOrderedExceedingPayers model.currentTime loggedInModel.users loggedInModel.account.incomes loggedInModel.payments)) - ++ [ expand ExpandDown loggedInModel.account.visibleDetail ] - ) - -exceedingPayer : Model -> LoggedInModel.Model -> ExceedingPayer -> Html -exceedingPayer model loggedInModel payer = - div - [ class "exceedingPayer" ] - [ span - [ class "userName" ] - [ payer.userId - |> getUserName loggedInModel.users - |> Maybe.withDefault "−" - |> text - ] - , span - [ class "amount" ] - [ text ("+ " ++ (price model payer.amount)) ] - ] - -income : Address Action -> Model -> AccountModel.Model -> Html -income address model account = - case account.incomeEdition of - Nothing -> - incomeRead address model account - Just edition -> - incomeEdition address model account edition - -incomeRead : Address Action -> Model -> AccountModel.Model -> Html -incomeRead address model account = - div - [ class "income" ] - [ ( case AccountModel.getCurrentIncome account of - Nothing -> - text (getMessage "NoIncome" model.translations) - Just income -> - text (getParamMessage [price model income] "Income" model.translations) - ) - , toggleIncomeEdition address "editIncomeEdition" (getMessage "Edit" model.translations) - ] - -incomeEdition : Address Action -> Model -> AccountModel.Model -> AccountModel.IncomeEdition -> Html -incomeEdition address model account edition = - H.form - [ case AccountModel.validateIncome edition.income model.translations of - Ok validatedAmount -> - onSubmitPrevDefault address (UpdateLoggedIn << LoggedInAction.UpdateAccount <| AccountAction.UpdateIncome model.currentTime validatedAmount) - Err error -> - onSubmitPrevDefault address (UpdateLoggedIn << LoggedInAction.UpdateAccount << AccountAction.UpdateEditionError <| error) - , class "income" - ] - [ label - [ for "incomeInput" ] - [ text (getMessage "NewIncome" model.translations) ] - , input - [ id "incomeInput" - , value edition.income - , on "input" targetValue (Signal.message address << UpdateLoggedIn << LoggedInAction.UpdateAccount << AccountAction.UpdateIncomeEdition) - , maxlength 10 - ] - [] - , button - [ type' "submit" - , class "validateIncomeEdition" - ] - [ text (getMessage "Validate" model.translations) ] - , toggleIncomeEdition address "undoIncomeEdition" (getMessage "Undo" model.translations) - , case edition.error of - Just error -> div [ class "error" ] [ text error ] - Nothing -> text "" - ] - -toggleIncomeEdition : Address Action -> String -> String -> Html -toggleIncomeEdition address className name = - button - [ type' "button" - , class className - , onClick address (UpdateLoggedIn << LoggedInAction.UpdateAccount <| AccountAction.ToggleIncomeEdition) - ] - [ text name ] -- cgit v1.2.3