aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--front/src/Main.elm60
1 files changed, 40 insertions, 20 deletions
diff --git a/front/src/Main.elm b/front/src/Main.elm
index 8b5dc16..4ff3dab 100644
--- a/front/src/Main.elm
+++ b/front/src/Main.elm
@@ -353,7 +353,7 @@ simUpdateDecoder =
simUpdateFlatten : List SimUpdate -> List SimUpdate
simUpdateFlatten us =
let
- { amortized, other } =
+ { amortized, newI1 } =
List.foldr
(\upd acc ->
case upd of
@@ -361,12 +361,20 @@ simUpdateFlatten us =
{ acc | amortized = acc.amortized + f }
SetI1 f ->
- { acc | other = upd :: acc.other }
+ { acc | newI1 = f }
)
- { amortized = 0, other = [] }
+ { amortized = 0, newI1 = 0 }
us
+
+ singleton cond x =
+ if cond then
+ [ x ]
+
+ else
+ []
in
- Amortize amortized :: other
+ singleton (amortized /= 0) (Amortize amortized)
+ ++ singleton (newI1 /= 0) (SetI1 newI1)
type alias PeriodicUpdate =
@@ -1358,8 +1366,8 @@ specsView { t, settings, rawSpecs } =
]
-simUpdateView : Model -> Bool -> SimUpdate -> Msg -> Html Msg
-simUpdateView m periodic upd onClick =
+simUpdateView : Model -> Bool -> Maybe Msg -> SimUpdate -> Html Msg
+simUpdateView m periodic onRemove upd =
let
( title_, attrs, els ) =
case upd of
@@ -1386,14 +1394,23 @@ simUpdateView m periodic upd onClick =
else
text ""
+
+ rmIconEls =
+ case onRemove of
+ Nothing ->
+ []
+
+ Just e ->
+ [ text " "
+ , span
+ (clickableAttrs e ++ [ title (m.t "Remove"), class "text-red-600" ])
+ [ text "×" ]
+ ]
in
span (attrs ++ [ title title_, class "px-1 rounded-md border border-1" ])
(periodicIcon
:: els
- ++ [ text " "
- , span (clickableAttrs onClick ++ [ title (m.t "Remove"), class "text-red-600" ])
- [ text "×" ]
- ]
+ ++ rmIconEls
)
@@ -1417,10 +1434,10 @@ quotaView m { updates } { month, payed, pending_principal } =
( "+ ", Set.insert year m.expandedYears )
periodicUpdates =
- List.map (\pu -> simUpdateView m True pu.upd (RmPeriodicUpdate pu)) monthUpdates.periodic
+ List.map (\pu -> simUpdateView m True (Just <| RmPeriodicUpdate pu) pu.upd) monthUpdates.periodic
byMonUpdates =
- List.map (\mu -> simUpdateView m False (Tuple.second mu) (RmUpdate mu)) monthUpdates.byMonth
+ List.map (\mu -> simUpdateView m False (Just <| RmUpdate mu) (Tuple.second mu)) monthUpdates.byMonth
yearField =
if modBy 12 (month - 1) == 0 then
@@ -1566,15 +1583,18 @@ quotaView m { updates } { month, payed, pending_principal } =
newUpdateBtn
updatesField =
- if modBy 12 (month - 1) == 0 && not monthInExpandedYear then
- text "..."
-
- else
- div [ class "flex flex-wrap items-start gap-1" ]
- (periodicUpdates
+ div [ class "flex flex-wrap items-start gap-1" ] <|
+ if modBy 12 (month - 1) == 0 && not monthInExpandedYear then
+ List.range month (month + 11)
+ |> List.map (updatesInMonth updates)
+ |> List.concatMap (\us -> List.map .upd us.periodic ++ List.map Tuple.second us.byMonth)
+ |> simUpdateFlatten
+ |> List.map (simUpdateView m False Nothing)
+
+ else
+ periodicUpdates
++ byMonUpdates
++ [ newUpdateBtnOrInput ]
- )
in
if modBy 12 (month - 1) == 0 || monthInExpandedYear then
tr []
@@ -1612,7 +1632,7 @@ mortgageView m sim =
[ tr []
(List.map
(\txt ->
- th [ class "px-3 py-1 border border-gray-300" ] txt
+ th [ class "px-3 py-1 border border-gray-300 min-w-[70px]" ] txt
)
titles
)