From 702d60cbcdf85216a1b18416f4480afb77384e8a Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 27 Mar 2016 20:20:10 +0200 Subject: Regroup loggedIn modules --- src/client/elm/View/LoggedIn/Table.elm | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src/client/elm/View/LoggedIn/Table.elm') diff --git a/src/client/elm/View/LoggedIn/Table.elm b/src/client/elm/View/LoggedIn/Table.elm index 4c302a5..ababcbd 100644 --- a/src/client/elm/View/LoggedIn/Table.elm +++ b/src/client/elm/View/LoggedIn/Table.elm @@ -11,23 +11,24 @@ import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) +import LoggedIn.Action as LoggedInAction +import LoggedIn.Model as LoggedInModel + import Model exposing (Model) import Model.User exposing (getUserName) import Model.Payment exposing (..) import Model.Translations exposing (getMessage) import Model.Action exposing (..) -import Model.Action.LoggedInAction exposing (..) -import Model.View.LoggedInView exposing (LoggedInView) import View.Icon exposing (renderIcon) import View.Date exposing (..) import View.Price exposing (price) -paymentsTable : Address Action -> Model -> LoggedInView -> Html -paymentsTable address model loggedInView = +paymentsTable : Address Action -> Model -> LoggedInModel.Model -> Html +paymentsTable address model loggedInModel = div [ class "table" ] - ( headerLine model :: paymentLines address model loggedInView) + ( headerLine model :: paymentLines address model loggedInModel) headerLine : Model -> Html headerLine model = @@ -40,23 +41,23 @@ headerLine model = , div [ class "cell" ] [] ] -paymentLines : Address Action -> Model -> LoggedInView -> List Html -paymentLines address model loggedInView = - loggedInView.payments +paymentLines : Address Action -> Model -> LoggedInModel.Model -> List Html +paymentLines address model loggedInModel = + loggedInModel.payments |> List.sortBy (Date.toTime << .creation) |> List.reverse - |> List.drop ((loggedInView.currentPage - 1) * perPage) + |> List.drop ((loggedInModel.currentPage - 1) * perPage) |> List.take perPage - |> List.map (paymentLine address model loggedInView) + |> List.map (paymentLine address model loggedInModel) -paymentLine : Address Action -> Model -> LoggedInView -> Payment -> Html -paymentLine address model loggedInView payment = +paymentLine : Address Action -> Model -> LoggedInModel.Model -> Payment -> Html +paymentLine address model loggedInModel payment = a [ classList [ ("row", True) - , ("edition", loggedInView.paymentEdition == Just payment.id) + , ("edition", loggedInModel.paymentEdition == Just payment.id) ] - , onClick address (UpdateLoggedIn (ToggleEdit payment.id)) + , onClick address (UpdateLoggedIn (LoggedInAction.ToggleEdit payment.id)) ] [ div [ class "cell category" ] [ text payment.name ] , div @@ -69,7 +70,7 @@ paymentLine address model loggedInView payment = , div [ class "cell user" ] [ payment.userId - |> getUserName loggedInView.users + |> getUserName loggedInModel.users |> Maybe.withDefault "−" |> text ] @@ -82,12 +83,12 @@ paymentLine address model loggedInView payment = [ class "longDate" ] [ text (renderLongDate payment.creation model.translations) ] ] - , if loggedInView.account.me == payment.userId + , if loggedInModel.account.me == payment.userId then div [ class "cell delete" ] [ button - [ onClick address (UpdateLoggedIn <| DeletePayment payment Punctual)] + [ onClick address (UpdateLoggedIn <| LoggedInAction.DeletePayment payment Punctual)] [ renderIcon "times" ] ] else -- cgit v1.2.3