From 24633871359ec9fbd63fdfebf79a6351b2792f77 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 6 Sep 2015 00:05:50 +0200 Subject: Can add monthly payments, not visible at the moment though, just the count is printed --- src/client/Model/Payment.elm | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/client/Model/Payment.elm') diff --git a/src/client/Model/Payment.elm b/src/client/Model/Payment.elm index 4ae50de..313c6be 100644 --- a/src/client/Model/Payment.elm +++ b/src/client/Model/Payment.elm @@ -3,26 +3,22 @@ module Model.Payment , Payments , Payment , PaymentId - , PaymentWithId , paymentsDecoder - , removePayment ) where import Date exposing (..) import Json.Decode as Json exposing ((:=)) -import Dict exposing (..) import Model.User exposing (UserId, userIdDecoder) perPage : Int perPage = 8 -type alias Payments = Dict PaymentId Payment - -type alias PaymentWithId = (PaymentId, Payment) +type alias Payments = List Payment type alias Payment = - { creation : Date + { id : PaymentId + , creation : Date , name : String , cost : Int , userId : UserId @@ -31,15 +27,12 @@ type alias Payment = type alias PaymentId = Int paymentsDecoder : Json.Decoder Payments -paymentsDecoder = Json.map Dict.fromList (Json.list paymentWithIdDecoder) - -paymentWithIdDecoder : Json.Decoder (PaymentId, Payment) -paymentWithIdDecoder = - paymentDecoder `Json.andThen` (\payment -> Json.map (\id -> (id, payment)) ("id" := paymentIdDecoder)) +paymentsDecoder = Json.list paymentDecoder paymentDecoder : Json.Decoder Payment paymentDecoder = - Json.object4 Payment + Json.object5 Payment + ("id" := paymentIdDecoder) ("creation" := dateDecoder) ("name" := Json.string) ("cost" := Json.int) @@ -50,6 +43,3 @@ paymentIdDecoder = Json.int dateDecoder : Json.Decoder Date dateDecoder = Json.customDecoder Json.string Date.fromString - -removePayment : Payments -> PaymentId -> Payments -removePayment payments paymentId = Dict.remove paymentId payments -- cgit v1.2.3