diff options
author | Joris | 2016-06-03 20:27:16 +0200 |
---|---|---|
committer | Joris | 2016-06-03 20:27:16 +0200 |
commit | 8e3a7bf1cb83bbb6e3dcd54308eefa52a29cd679 (patch) | |
tree | d6ba0985a534a0e2e317b1edb0d4c999119d87ff /src/client/elm/LoggedIn/Home/View | |
parent | 3a88115d118f8256f3ff034dc359df42a9e4051c (diff) |
Migrate to elm 0.17
Diffstat (limited to 'src/client/elm/LoggedIn/Home/View')
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Expand.elm | 8 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Monthly.elm | 27 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Paging.elm | 45 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/View/Table.elm | 24 |
4 files changed, 52 insertions, 52 deletions
diff --git a/src/client/elm/LoggedIn/Home/View/Expand.elm b/src/client/elm/LoggedIn/Home/View/Expand.elm index 514bf93..a50ebfe 100644 --- a/src/client/elm/LoggedIn/Home/View/Expand.elm +++ b/src/client/elm/LoggedIn/Home/View/Expand.elm @@ -1,16 +1,18 @@ -module LoggedIn.Home.View.Expand +module LoggedIn.Home.View.Expand exposing ( expand , ExpandType(..) - ) where + ) import Html exposing (..) import Html.Attributes exposing (..) +import Msg exposing (Msg) + import View.Icon exposing (renderIcon) type ExpandType = ExpandUp | ExpandDown -expand : ExpandType -> Bool -> Html +expand : ExpandType -> Bool -> Html Msg expand expandType isExpanded = div [ class "expand" ] diff --git a/src/client/elm/LoggedIn/Home/View/Monthly.elm b/src/client/elm/LoggedIn/Home/View/Monthly.elm index 237b551..26dbe98 100644 --- a/src/client/elm/LoggedIn/Home/View/Monthly.elm +++ b/src/client/elm/LoggedIn/Home/View/Monthly.elm @@ -1,6 +1,6 @@ -module LoggedIn.Home.View.Monthly +module LoggedIn.Home.View.Monthly exposing ( view - ) where + ) import String @@ -8,9 +8,11 @@ import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) -import LoggedIn.Action as LoggedInAction +import Msg exposing (Msg) -import LoggedIn.Home.Action as HomeAction +import LoggedIn.Msg as LoggedInMsg + +import LoggedIn.Home.Msg as HomeMsg import LoggedIn.Home.Model as HomeModel import LoggedIn.View.Format as Format import LoggedIn.Home.View.Expand exposing (..) @@ -19,12 +21,9 @@ import Model.Payment as Payment exposing (Payments, Payment, monthly) import Model.Translations exposing (getMessage, getParamMessage) import LoggedData exposing (LoggedData) -import Action -import Mailbox - import View.Icon exposing (renderIcon) -view : LoggedData -> HomeModel.Model -> Html +view : LoggedData -> HomeModel.Model -> Html Msg view loggedData homeModel = let monthlyPayments = Payment.monthly loggedData.me loggedData.payments in if List.length monthlyPayments == 0 @@ -43,20 +42,20 @@ view loggedData homeModel = else text "" ] -monthlyCount : LoggedData -> Payments -> HomeModel.Model -> Html +monthlyCount : LoggedData -> Payments -> HomeModel.Model -> Html Msg monthlyCount loggedData monthlyPayments homeModel = let count = List.length monthlyPayments total = List.sum << List.map .cost <| monthlyPayments key = if count > 1 then "PluralMonthlyCount" else "SingularMonthlyCount" in button [ class "header" - , onClick Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.HomeAction <| HomeAction.ToggleMonthlyDetail) + , onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg <| HomeMsg.ToggleMonthlyDetail) ] [ text (getParamMessage [toString count, Format.price loggedData.conf total] key loggedData.translations) , expand ExpandDown homeModel.monthlyDetail ] -paymentsTable : LoggedData -> Payments -> HomeModel.Model -> Html +paymentsTable : LoggedData -> Payments -> HomeModel.Model -> Html Msg paymentsTable loggedData monthlyPayments homeModel = div [ class "table" ] @@ -65,14 +64,14 @@ paymentsTable loggedData monthlyPayments homeModel = |> List.map (paymentLine loggedData homeModel) ) -paymentLine : LoggedData -> HomeModel.Model -> Payment -> Html +paymentLine : LoggedData -> HomeModel.Model -> Payment -> Html Msg paymentLine loggedData homeModel payment = a [ classList [ ("row", True) , ("edition", homeModel.paymentEdition == Just payment.id) ] - , onClick Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.HomeAction <| HomeAction.ToggleEdit payment.id) + , onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg <| HomeMsg.ToggleEdit payment.id) ] [ div [ class "cell category" ] [ text (payment.name) ] , div @@ -84,7 +83,7 @@ paymentLine loggedData homeModel payment = [ text (Format.price loggedData.conf payment.cost) ] , div [ class "cell delete" - , onClick Mailbox.address (Action.UpdateLoggedIn <| LoggedInAction.DeletePayment payment.id) + , onClick (Msg.UpdateLoggedIn <| LoggedInMsg.DeletePayment payment.id) ] [ button [] [ renderIcon "times" ] ] diff --git a/src/client/elm/LoggedIn/Home/View/Paging.elm b/src/client/elm/LoggedIn/Home/View/Paging.elm index 939ee55..15bb5a1 100644 --- a/src/client/elm/LoggedIn/Home/View/Paging.elm +++ b/src/client/elm/LoggedIn/Home/View/Paging.elm @@ -1,18 +1,17 @@ -module LoggedIn.Home.View.Paging +module LoggedIn.Home.View.Paging exposing ( paymentsPaging - ) where + ) import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) -import LoggedIn.Action as LoggedInAction +import LoggedIn.Msg as LoggedInMsg -import LoggedIn.Home.Action as HomeAction +import LoggedIn.Home.Msg as HomeMsg import LoggedIn.Home.Model as HomeModel -import Action exposing (Action) -import Mailbox +import Msg exposing (Msg) import LoggedData exposing (LoggedData) import Model.Payment as Payment exposing (Payments, perPage) @@ -21,7 +20,7 @@ import View.Icon exposing (renderIcon) showedPages : Int showedPages = 5 -paymentsPaging : Payments -> HomeModel.Model -> Html +paymentsPaging : Payments -> HomeModel.Model -> Html Msg paymentsPaging payments homeModel = let maxPage = ceiling (toFloat (List.length (Payment.punctual payments)) / toFloat perPage) pages = truncatePages homeModel.currentPage [1..maxPage] @@ -50,48 +49,48 @@ truncatePages currentPage pages = [(currentPage - showedLeftPages)..(currentPage + showedRightPages)] in List.filter (flip List.member pages) truncatedPages -firstPage : HomeModel.Model -> Html +firstPage : HomeModel.Model -> Html Msg firstPage homeModel = button [ classList [ ("page", True) , ("disable", homeModel.currentPage <= 1) ] - , onClick Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdatePage <| 1) + , onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| 1) ] [ renderIcon "fast-backward" ] -previousPage : HomeModel.Model -> Html +previousPage : HomeModel.Model -> Html Msg previousPage homeModel = button [ class "page" - , onClick Mailbox.address <| + , onClick <| if homeModel.currentPage > 1 - then (Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdatePage <| homeModel.currentPage - 1) - else Action.NoOp + then (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| homeModel.currentPage - 1) + else Msg.NoOp ] [ renderIcon "backward" ] -nextPage : HomeModel.Model -> Int -> Html +nextPage : HomeModel.Model -> Int -> Html Msg nextPage homeModel maxPage = button [ class "page" - , onClick Mailbox.address <| + , onClick <| if homeModel.currentPage < maxPage - then (Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdatePage <| homeModel.currentPage + 1) - else Action.NoOp + then (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| homeModel.currentPage + 1) + else Msg.NoOp ] [ renderIcon "forward" ] -lastPage : HomeModel.Model -> Int -> Html +lastPage : HomeModel.Model -> Int -> Html Msg lastPage homeModel maxPage = button [ class "page" - , onClick Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdatePage <| maxPage) + , onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| maxPage) ] [ renderIcon "fast-forward" ] -paymentsPage : HomeModel.Model -> Int -> Html +paymentsPage : HomeModel.Model -> Int -> Html Msg paymentsPage homeModel page = let onCurrentPage = page == homeModel.currentPage in button @@ -99,9 +98,9 @@ paymentsPage homeModel page = [ ("page", True) , ("current", onCurrentPage) ] - , onClick Mailbox.address <| + , onClick <| if onCurrentPage - then Action.NoOp - else Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdatePage <| page + then Msg.NoOp + else Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdatePage <| page ] [ text (toString page) ] diff --git a/src/client/elm/LoggedIn/Home/View/Table.elm b/src/client/elm/LoggedIn/Home/View/Table.elm index 5ac740c..6631af7 100644 --- a/src/client/elm/LoggedIn/Home/View/Table.elm +++ b/src/client/elm/LoggedIn/Home/View/Table.elm @@ -1,6 +1,6 @@ -module LoggedIn.Home.View.Table +module LoggedIn.Home.View.Table exposing ( paymentsTable - ) where + ) import Dict exposing (..) import Date exposing (Date) @@ -10,29 +10,29 @@ import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) +import Msg exposing (Msg) + import LoggedData exposing (LoggedData) -import LoggedIn.Action as LoggedInAction +import LoggedIn.Msg as LoggedInMsg -import LoggedIn.Home.Action as HomeAction +import LoggedIn.Home.Msg as HomeMsg import LoggedIn.Home.Model as HomeModel import LoggedIn.View.Date exposing (..) import LoggedIn.View.Format as Format import Model.User exposing (getUserName) import Model.Payment as Payment exposing (..) -import Action -import Mailbox import View.Icon exposing (renderIcon) -paymentsTable : LoggedData -> HomeModel.Model -> Html +paymentsTable : LoggedData -> HomeModel.Model -> Html Msg paymentsTable loggedData homeModel = div [ class "table" ] ( headerLine loggedData :: paymentLines loggedData homeModel) -headerLine : LoggedData -> Html +headerLine : LoggedData -> Html Msg headerLine loggedData = div [ class "header" ] @@ -43,7 +43,7 @@ headerLine loggedData = , div [ class "cell" ] [] ] -paymentLines : LoggedData -> HomeModel.Model -> List Html +paymentLines : LoggedData -> HomeModel.Model -> List (Html Msg) paymentLines loggedData homeModel = Payment.punctual loggedData.payments |> List.sortBy (Date.toTime << .creation) @@ -52,14 +52,14 @@ paymentLines loggedData homeModel = |> List.take perPage |> List.map (paymentLine loggedData homeModel) -paymentLine : LoggedData -> HomeModel.Model -> Payment -> Html +paymentLine : LoggedData -> HomeModel.Model -> Payment -> Html Msg paymentLine loggedData homeModel payment = a [ classList [ ("row", True) , ("edition", homeModel.paymentEdition == Just payment.id) ] - , onClick Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.ToggleEdit <| payment.id) + , onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.ToggleEdit <| payment.id) ] [ div [ class "cell category" ] [ text payment.name ] , div @@ -90,7 +90,7 @@ paymentLine loggedData homeModel payment = div [ class "cell delete" ] [ button - [ onClick Mailbox.address (Action.UpdateLoggedIn <| LoggedInAction.DeletePayment payment.id)] + [ onClick (Msg.UpdateLoggedIn <| LoggedInMsg.DeletePayment payment.id)] [ renderIcon "times" ] ] else |