From 3853811450d4fe801da996eb48825049c3541030 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 6 Sep 2015 16:46:59 +0200 Subject: Renaming PaymentView to LoggedInView --- src/client/Model/View/LoggedIn/Add.elm | 43 ++++++++++++++++++++++++++++++ src/client/Model/View/LoggedIn/Edition.elm | 7 +++++ src/client/Model/View/LoggedIn/Monthly.elm | 17 ++++++++++++ src/client/Model/View/LoggedInView.elm | 36 +++++++++++++++++++++++++ src/client/Model/View/LoggedView.elm | 36 ------------------------- src/client/Model/View/Payment/Add.elm | 43 ------------------------------ src/client/Model/View/Payment/Edition.elm | 7 ----- src/client/Model/View/Payment/Monthly.elm | 17 ------------ 8 files changed, 103 insertions(+), 103 deletions(-) create mode 100644 src/client/Model/View/LoggedIn/Add.elm create mode 100644 src/client/Model/View/LoggedIn/Edition.elm create mode 100644 src/client/Model/View/LoggedIn/Monthly.elm create mode 100644 src/client/Model/View/LoggedInView.elm delete mode 100644 src/client/Model/View/LoggedView.elm delete mode 100644 src/client/Model/View/Payment/Add.elm delete mode 100644 src/client/Model/View/Payment/Edition.elm delete mode 100644 src/client/Model/View/Payment/Monthly.elm (limited to 'src/client/Model/View') diff --git a/src/client/Model/View/LoggedIn/Add.elm b/src/client/Model/View/LoggedIn/Add.elm new file mode 100644 index 0000000..abd8a4d --- /dev/null +++ b/src/client/Model/View/LoggedIn/Add.elm @@ -0,0 +1,43 @@ +module Model.View.LoggedIn.Add + ( AddPayment + , Frequency(..) + , initAddPayment + , validateName + , validateCost + ) where + +import Result as Result exposing (Result(..)) + +import Utils.Validation exposing (..) + +import Model.Translations exposing (..) + +type alias AddPayment = + { name : String + , nameError : Maybe String + , cost : String + , costError : Maybe String + , frequency : Frequency + } + +initAddPayment : Frequency -> AddPayment +initAddPayment frequency = + { name = "" + , nameError = Nothing + , cost = "" + , costError = Nothing + , frequency = frequency + } + +validateName : String -> Translations -> Result String String +validateName name translations = + name + |> validateNonEmpty (getMessage "CategoryRequired" translations) + +validateCost : String -> Translations -> Result String Int +validateCost cost translations = + cost + |> validateNonEmpty (getMessage "CostRequired" translations) + |> flip Result.andThen (validateNumber (getMessage "CostMustBeNumber" translations) (\number -> number >= 0)) + +type Frequency = Punctual | Monthly diff --git a/src/client/Model/View/LoggedIn/Edition.elm b/src/client/Model/View/LoggedIn/Edition.elm new file mode 100644 index 0000000..da6d7b0 --- /dev/null +++ b/src/client/Model/View/LoggedIn/Edition.elm @@ -0,0 +1,7 @@ +module Model.View.LoggedIn.Edition + ( Edition + ) where + +import Model.Payment exposing (PaymentId) + +type alias Edition = PaymentId diff --git a/src/client/Model/View/LoggedIn/Monthly.elm b/src/client/Model/View/LoggedIn/Monthly.elm new file mode 100644 index 0000000..3c6f66a --- /dev/null +++ b/src/client/Model/View/LoggedIn/Monthly.elm @@ -0,0 +1,17 @@ +module Model.View.LoggedIn.Monthly + ( Monthly + , initMonthly + ) where + +import Model.Payment exposing (Payments) + +type alias Monthly = + { payments : Payments + , visibleDetail : Bool + } + +initMonthly : Payments -> Monthly +initMonthly payments = + { payments = payments + , visibleDetail = False + } diff --git a/src/client/Model/View/LoggedInView.elm b/src/client/Model/View/LoggedInView.elm new file mode 100644 index 0000000..cf7f552 --- /dev/null +++ b/src/client/Model/View/LoggedInView.elm @@ -0,0 +1,36 @@ +module Model.View.LoggedInView + ( LoggedInView + , initLoggedInView + ) where + +import Model.User exposing (Users, UserId) +import Model.Payment exposing (Payments) +import Model.Payers exposing (Payers) +import Model.View.LoggedIn.Add exposing (..) +import Model.View.LoggedIn.Edition exposing (..) +import Model.View.LoggedIn.Monthly exposing (..) + +type alias LoggedInView = + { users : Users + , me : UserId + , add : AddPayment + , monthly : Monthly + , payments : Payments + , paymentsCount : Int + , payers : Payers + , paymentEdition : Maybe Edition + , currentPage : Int + } + +initLoggedInView : Users -> UserId -> Payments -> Payments -> Int -> Payers -> LoggedInView +initLoggedInView users me monthlyPayments payments paymentsCount payers = + { users = users + , me = me + , add = initAddPayment Punctual + , monthly = initMonthly monthlyPayments + , payments = payments + , paymentsCount = paymentsCount + , payers = payers + , paymentEdition = Nothing + , currentPage = 1 + } diff --git a/src/client/Model/View/LoggedView.elm b/src/client/Model/View/LoggedView.elm deleted file mode 100644 index 264fdf5..0000000 --- a/src/client/Model/View/LoggedView.elm +++ /dev/null @@ -1,36 +0,0 @@ -module Model.View.LoggedView - ( LoggedView - , initLoggedView - ) where - -import Model.User exposing (Users, UserId) -import Model.Payment exposing (Payments) -import Model.Payers exposing (Payers) -import Model.View.Payment.Add exposing (..) -import Model.View.Payment.Edition exposing (..) -import Model.View.Payment.Monthly exposing (..) - -type alias LoggedView = - { users : Users - , me : UserId - , add : AddPayment - , monthly : Monthly - , payments : Payments - , paymentsCount : Int - , payers : Payers - , paymentEdition : Maybe Edition - , currentPage : Int - } - -initLoggedView : Users -> UserId -> Payments -> Payments -> Int -> Payers -> LoggedView -initLoggedView users me monthlyPayments payments paymentsCount payers = - { users = users - , me = me - , add = initAddPayment Punctual - , monthly = initMonthly monthlyPayments - , payments = payments - , paymentsCount = paymentsCount - , payers = payers - , paymentEdition = Nothing - , currentPage = 1 - } diff --git a/src/client/Model/View/Payment/Add.elm b/src/client/Model/View/Payment/Add.elm deleted file mode 100644 index dc00e86..0000000 --- a/src/client/Model/View/Payment/Add.elm +++ /dev/null @@ -1,43 +0,0 @@ -module Model.View.Payment.Add - ( AddPayment - , Frequency(..) - , initAddPayment - , validateName - , validateCost - ) where - -import Result as Result exposing (Result(..)) - -import Utils.Validation exposing (..) - -import Model.Translations exposing (..) - -type alias AddPayment = - { name : String - , nameError : Maybe String - , cost : String - , costError : Maybe String - , frequency : Frequency - } - -initAddPayment : Frequency -> AddPayment -initAddPayment frequency = - { name = "" - , nameError = Nothing - , cost = "" - , costError = Nothing - , frequency = frequency - } - -validateName : String -> Translations -> Result String String -validateName name translations = - name - |> validateNonEmpty (getMessage "CategoryRequired" translations) - -validateCost : String -> Translations -> Result String Int -validateCost cost translations = - cost - |> validateNonEmpty (getMessage "CostRequired" translations) - |> flip Result.andThen (validateNumber (getMessage "CostMustBeNumber" translations) (\number -> number >= 0)) - -type Frequency = Punctual | Monthly diff --git a/src/client/Model/View/Payment/Edition.elm b/src/client/Model/View/Payment/Edition.elm deleted file mode 100644 index f58ce43..0000000 --- a/src/client/Model/View/Payment/Edition.elm +++ /dev/null @@ -1,7 +0,0 @@ -module Model.View.Payment.Edition - ( Edition - ) where - -import Model.Payment exposing (PaymentId) - -type alias Edition = PaymentId diff --git a/src/client/Model/View/Payment/Monthly.elm b/src/client/Model/View/Payment/Monthly.elm deleted file mode 100644 index 15a5f2e..0000000 --- a/src/client/Model/View/Payment/Monthly.elm +++ /dev/null @@ -1,17 +0,0 @@ -module Model.View.Payment.Monthly - ( Monthly - , initMonthly - ) where - -import Model.Payment exposing (Payments) - -type alias Monthly = - { payments : Payments - , visibleDetail : Bool - } - -initMonthly : Payments -> Monthly -initMonthly payments = - { payments = payments - , visibleDetail = False - } -- cgit v1.2.3