diff options
Diffstat (limited to 'src/client/elm/LoggedIn/Home')
-rw-r--r-- | src/client/elm/LoggedIn/Home/Account/View.elm | 10 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/Action.elm | 15 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/AddPayment/Model.elm | 4 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/AddPayment/Msg.elm (renamed from src/client/elm/LoggedIn/Home/AddPayment/Action.elm) | 8 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/AddPayment/Update.elm | 26 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/AddPayment/View.elm | 36 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/Model.elm | 4 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/Msg.elm | 15 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/Update.elm | 34 | ||||
-rw-r--r-- | src/client/elm/LoggedIn/Home/View.elm | 10 | ||||
-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 |
14 files changed, 133 insertions, 133 deletions
diff --git a/src/client/elm/LoggedIn/Home/Account/View.elm b/src/client/elm/LoggedIn/Home/Account/View.elm index dc72791..fdc1941 100644 --- a/src/client/elm/LoggedIn/Home/Account/View.elm +++ b/src/client/elm/LoggedIn/Home/Account/View.elm @@ -1,10 +1,12 @@ -module LoggedIn.Home.Account.View +module LoggedIn.Home.Account.View exposing ( view - ) where + ) import Html exposing (..) import Html.Attributes exposing (..) +import Msg exposing (Msg) + import LoggedData exposing (LoggedData) import LoggedIn.Home.Model as HomeModel @@ -14,7 +16,7 @@ import Model exposing (Model) import Model.User exposing (getUserName) import Model.Payer exposing (..) -view : LoggedData -> HomeModel.Model -> Html +view : LoggedData -> HomeModel.Model -> Html Msg view loggedData homeModel = div [ class "account" ] @@ -23,7 +25,7 @@ view loggedData homeModel = (List.map (exceedingPayer loggedData homeModel) (getOrderedExceedingPayers loggedData.currentTime loggedData.users loggedData.incomes loggedData.payments)) ] -exceedingPayer : LoggedData -> HomeModel.Model -> ExceedingPayer -> Html +exceedingPayer : LoggedData -> HomeModel.Model -> ExceedingPayer -> Html Msg exceedingPayer loggedData homeModel payer = div [ class "exceedingPayer" ] diff --git a/src/client/elm/LoggedIn/Home/Action.elm b/src/client/elm/LoggedIn/Home/Action.elm deleted file mode 100644 index 1590fb8..0000000 --- a/src/client/elm/LoggedIn/Home/Action.elm +++ /dev/null @@ -1,15 +0,0 @@ -module LoggedIn.Home.Action - ( Action(..) - ) where - -import Model.Payment exposing (PaymentId) - -import LoggedIn.Home.AddPayment.Action as AddPaymentAction - -type Action = - NoOp - | UpdateAdd AddPaymentAction.Action - | ToggleEdit PaymentId - | UpdatePage Int - | ShowMonthlyDetail - | ToggleMonthlyDetail diff --git a/src/client/elm/LoggedIn/Home/AddPayment/Model.elm b/src/client/elm/LoggedIn/Home/AddPayment/Model.elm index 19933fd..b656077 100644 --- a/src/client/elm/LoggedIn/Home/AddPayment/Model.elm +++ b/src/client/elm/LoggedIn/Home/AddPayment/Model.elm @@ -1,7 +1,7 @@ -module LoggedIn.Home.AddPayment.Model +module LoggedIn.Home.AddPayment.Model exposing ( Model , init - ) where + ) import Result as Result exposing (Result(..)) import Json.Decode exposing ((:=)) diff --git a/src/client/elm/LoggedIn/Home/AddPayment/Action.elm b/src/client/elm/LoggedIn/Home/AddPayment/Msg.elm index a692b15..53e6e26 100644 --- a/src/client/elm/LoggedIn/Home/AddPayment/Action.elm +++ b/src/client/elm/LoggedIn/Home/AddPayment/Msg.elm @@ -1,10 +1,10 @@ -module LoggedIn.Home.AddPayment.Action - ( Action(..) - ) where +module LoggedIn.Home.AddPayment.Msg exposing + ( Msg(..) + ) import Model.Payment exposing (Frequency) -type Action = +type Msg = NoOp | Init Frequency | UpdateName String diff --git a/src/client/elm/LoggedIn/Home/AddPayment/Update.elm b/src/client/elm/LoggedIn/Home/AddPayment/Update.elm index 7f5fb0a..46b3786 100644 --- a/src/client/elm/LoggedIn/Home/AddPayment/Update.elm +++ b/src/client/elm/LoggedIn/Home/AddPayment/Update.elm @@ -1,49 +1,49 @@ -module LoggedIn.Home.AddPayment.Update +module LoggedIn.Home.AddPayment.Update exposing ( update , addPaymentError - ) where + ) import Maybe import Json.Decode as Json exposing ((:=)) -import LoggedIn.Home.AddPayment.Action as AddPaymentAction +import LoggedIn.Home.AddPayment.Msg as AddPaymentMsg import LoggedIn.Home.AddPayment.Model as AddPaymentModel import Model.Translations exposing (Translations, getMessage) import Model.Payment exposing (Frequency(..)) -update : AddPaymentAction.Action -> AddPaymentModel.Model -> AddPaymentModel.Model +update : AddPaymentMsg.Msg -> AddPaymentModel.Model -> AddPaymentModel.Model update action addPayment = case action of - AddPaymentAction.NoOp -> + AddPaymentMsg.NoOp -> addPayment - AddPaymentAction.Init frequency -> + AddPaymentMsg.Init frequency -> AddPaymentModel.init frequency - AddPaymentAction.UpdateName name -> + AddPaymentMsg.UpdateName name -> { addPayment | name = name } - AddPaymentAction.UpdateCost cost -> + AddPaymentMsg.UpdateCost cost -> { addPayment | cost = cost } - AddPaymentAction.AddError nameError costError -> + AddPaymentMsg.AddError nameError costError -> { addPayment | nameError = nameError , costError = costError , waitingServer = False } - AddPaymentAction.ToggleFrequency -> + AddPaymentMsg.ToggleFrequency -> { addPayment | frequency = if addPayment.frequency == Punctual then Monthly else Punctual } - AddPaymentAction.WaitingServer -> + AddPaymentMsg.WaitingServer -> { addPayment | waitingServer = True } -addPaymentError : Translations -> String -> Maybe AddPaymentAction.Action +addPaymentError : Translations -> String -> Maybe AddPaymentMsg.Msg addPaymentError translations jsonErr = let decoder = Json.object2 (,) @@ -53,6 +53,6 @@ addPaymentError translations jsonErr = Err _ -> Nothing Ok (mbNameKey, mbCostKey) -> - Just <| AddPaymentAction.AddError + Just <| AddPaymentMsg.AddError (Maybe.map (flip getMessage translations) mbNameKey) (Maybe.map (flip getMessage translations) mbCostKey) diff --git a/src/client/elm/LoggedIn/Home/AddPayment/View.elm b/src/client/elm/LoggedIn/Home/AddPayment/View.elm index 96f3a6a..d97f3ca 100644 --- a/src/client/elm/LoggedIn/Home/AddPayment/View.elm +++ b/src/client/elm/LoggedIn/Home/AddPayment/View.elm @@ -1,44 +1,44 @@ -module LoggedIn.Home.AddPayment.View +module LoggedIn.Home.AddPayment.View exposing ( view - ) where + ) import Result exposing (..) +import Json.Decode as Json 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.Home.AddPayment.Action as AddPaymentAction +import LoggedIn.Home.AddPayment.Msg as AddPaymentMsg import LoggedIn.Home.AddPayment.Model as AddPaymentModel import Model.Payment exposing (Frequency(..)) import Model.Translations exposing (getMessage) import LoggedData exposing (LoggedData) -import Action -import Mailbox - import View.Events exposing (onSubmitPrevDefault) import View.Icon exposing (..) import Utils.Maybe exposing (isJust) import Utils.Either exposing (toMaybeError) -view : LoggedData -> HomeModel.Model -> Html +view : LoggedData -> HomeModel.Model -> Html Msg view loggedData homeModel = Html.form [ let update = if homeModel.add.waitingServer then - Action.NoOp + Msg.NoOp else - Action.UpdateLoggedIn <| LoggedInAction.AddPayment homeModel.add.name homeModel.add.cost homeModel.add.frequency - in onSubmitPrevDefault Mailbox.address update + Msg.UpdateLoggedIn <| LoggedInMsg.AddPayment homeModel.add.name homeModel.add.cost homeModel.add.frequency + in onSubmitPrevDefault update , class "addPayment" ] [ addPaymentName loggedData homeModel.add @@ -56,7 +56,7 @@ view loggedData homeModel = ] ] -addPaymentName : LoggedData -> AddPaymentModel.Model -> Html +addPaymentName : LoggedData -> AddPaymentModel.Model -> Html Msg addPaymentName loggedData addPayment = div [ classList @@ -67,7 +67,7 @@ addPaymentName loggedData addPayment = [ input [ id "nameInput" , value addPayment.name - , on "input" targetValue (Signal.message Mailbox.address << Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdateAdd << AddPaymentAction.UpdateName) + , on "input" (targetValue |> (Json.map <| Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdateAdd << AddPaymentMsg.UpdateName)) , maxlength 20 ] [] @@ -81,7 +81,7 @@ addPaymentName loggedData addPayment = text "" ] -addPaymentCost : LoggedData -> AddPaymentModel.Model -> Html +addPaymentCost : LoggedData -> AddPaymentModel.Model -> Html Msg addPaymentCost loggedData addPayment = div [ classList @@ -92,7 +92,7 @@ addPaymentCost loggedData addPayment = [ input [ id "costInput" , value addPayment.cost - , on "input" targetValue (Signal.message Mailbox.address << Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdateAdd << AddPaymentAction.UpdateCost) + , on "input" (targetValue |> (Json.map <| Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdateAdd << AddPaymentMsg.UpdateCost)) , maxlength 7 ] [] @@ -106,12 +106,12 @@ addPaymentCost loggedData addPayment = text "" ] -paymentFrequency : LoggedData -> AddPaymentModel.Model -> Html +paymentFrequency : LoggedData -> AddPaymentModel.Model -> Html Msg paymentFrequency loggedData addPayment = button [ type' "button" , class "frequency" - , onClick Mailbox.address (Action.UpdateLoggedIn << LoggedInAction.HomeAction << HomeAction.UpdateAdd <| AddPaymentAction.ToggleFrequency) + , onClick (Msg.UpdateLoggedIn << LoggedInMsg.HomeMsg << HomeMsg.UpdateAdd <| AddPaymentMsg.ToggleFrequency) ] [ div [ classList diff --git a/src/client/elm/LoggedIn/Home/Model.elm b/src/client/elm/LoggedIn/Home/Model.elm index 217a851..e448b66 100644 --- a/src/client/elm/LoggedIn/Home/Model.elm +++ b/src/client/elm/LoggedIn/Home/Model.elm @@ -1,7 +1,7 @@ -module LoggedIn.Home.Model +module LoggedIn.Home.Model exposing ( Model , init - ) where + ) import Model.User exposing (Users, UserId) import Model.Payment exposing (PaymentId, Payments, Frequency(..)) diff --git a/src/client/elm/LoggedIn/Home/Msg.elm b/src/client/elm/LoggedIn/Home/Msg.elm new file mode 100644 index 0000000..bb17a91 --- /dev/null +++ b/src/client/elm/LoggedIn/Home/Msg.elm @@ -0,0 +1,15 @@ +module LoggedIn.Home.Msg exposing + ( Msg(..) + ) + +import Model.Payment exposing (PaymentId) + +import LoggedIn.Home.AddPayment.Msg as AddPaymentMsg + +type Msg = + NoOp + | UpdateAdd AddPaymentMsg.Msg + | ToggleEdit PaymentId + | UpdatePage Int + | ShowMonthlyDetail + | ToggleMonthlyDetail diff --git a/src/client/elm/LoggedIn/Home/Update.elm b/src/client/elm/LoggedIn/Home/Update.elm index cebdc70..6de341d 100644 --- a/src/client/elm/LoggedIn/Home/Update.elm +++ b/src/client/elm/LoggedIn/Home/Update.elm @@ -1,43 +1,41 @@ -module LoggedIn.Home.Update +module LoggedIn.Home.Update exposing ( update - ) where - -import Effects exposing (Effects) + ) import LoggedData exposing (LoggedData) -import LoggedIn.Home.Action as HomeAction +import LoggedIn.Home.Msg as HomeMsg import LoggedIn.Home.Model as HomeModel import LoggedIn.Home.AddPayment.Update as AddPaymentUpdate -update : LoggedData -> HomeAction.Action -> HomeModel.Model -> (HomeModel.Model, Effects HomeAction.Action) +update : LoggedData -> HomeMsg.Msg -> HomeModel.Model -> (HomeModel.Model, Cmd HomeMsg.Msg) update loggedData action homeModel = case action of - HomeAction.NoOp -> (homeModel, Effects.none) + HomeMsg.NoOp -> (homeModel, Cmd.none) - HomeAction.UpdateAdd addPaymentAction -> - ( { homeModel | add = AddPaymentUpdate.update addPaymentAction homeModel.add } - , Effects.none + HomeMsg.UpdateAdd addPaymentMsg -> + ( { homeModel | add = AddPaymentUpdate.update addPaymentMsg homeModel.add } + , Cmd.none ) - HomeAction.ToggleEdit id -> + HomeMsg.ToggleEdit id -> ( { homeModel | paymentEdition = if homeModel.paymentEdition == Just id then Nothing else Just id } - , Effects.none + , Cmd.none ) - HomeAction.UpdatePage page -> + HomeMsg.UpdatePage page -> ( { homeModel | currentPage = page } - , Effects.none + , Cmd.none ) - HomeAction.ShowMonthlyDetail -> + HomeMsg.ShowMonthlyDetail -> ( { homeModel | monthlyDetail = True } - , Effects.none + , Cmd.none ) - HomeAction.ToggleMonthlyDetail -> + HomeMsg.ToggleMonthlyDetail -> ( { homeModel | monthlyDetail = not homeModel.monthlyDetail } - , Effects.none + , Cmd.none ) diff --git a/src/client/elm/LoggedIn/Home/View.elm b/src/client/elm/LoggedIn/Home/View.elm index 4c5e330..097e730 100644 --- a/src/client/elm/LoggedIn/Home/View.elm +++ b/src/client/elm/LoggedIn/Home/View.elm @@ -1,10 +1,12 @@ -module LoggedIn.Home.View +module LoggedIn.Home.View exposing ( view - ) where + ) import Html exposing (..) import Html.Attributes exposing (..) +import Msg exposing (Msg) + import LoggedData exposing (LoggedData) import LoggedIn.Home.Model as LoggedInModel @@ -15,9 +17,7 @@ import LoggedIn.Home.View.Monthly as MonthlyView import LoggedIn.Home.View.Table exposing (paymentsTable) import LoggedIn.Home.View.Paging exposing (paymentsPaging) -import Mailbox - -view : LoggedData -> LoggedInModel.Model -> Html +view : LoggedData -> LoggedInModel.Model -> Html Msg view loggedData loggedIn = div [ class "home" ] 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 |