Skip to content

Commit

Permalink
fix:ui: Fixed #2284 -- valuation and cost flags now reset each other …
Browse files Browse the repository at this point in the history
…on toggle.
  • Loading branch information
GLakovnik authored and simonmichael committed Nov 18, 2024
1 parent 21d8044 commit 255dc01
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hledger-ui/Hledger/UI/UIState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,16 @@ toggleEmpty = over empty__ not

-- | Toggle between showing the primary amounts or costs.
toggleConversionOp :: UIState -> UIState
toggleConversionOp = over conversionop toggleCostMode
toggleConversionOp ui = (over value valOff) (over conversionop toggleCostMode ui)
where
toggleCostMode Nothing = Just ToCost
toggleCostMode (Just NoConversionOp) = Just ToCost
toggleCostMode (Just ToCost) = Just NoConversionOp
valOff _ = Nothing

-- | Toggle between showing primary amounts or values (using valuation specified at startup, or a default).
toggleValue :: UIState -> UIState
toggleValue ui = over value (valuationToggleValue mstartupvaluation0) ui
toggleValue ui = (over conversionop costOff) (over value (valuationToggleValue mstartupvaluation0) ui)
where
mstartupvaluation0 = value_ $ _rsReportOpts $ reportspec_ $ uoCliOpts $ astartupopts ui
mdefvaluation = Just (AtEnd Nothing)
Expand All @@ -166,6 +167,7 @@ toggleValue ui = over value (valuationToggleValue mstartupvaluation0) ui
valuationToggleValue Nothing (Just _) = Nothing
valuationToggleValue mstartupvaluation Nothing = mstartupvaluation
valuationToggleValue _ (Just _) = Nothing
costOff _ = Just NoConversionOp

-- | Set hierarchic account tree mode.
setTree :: UIState -> UIState
Expand Down

0 comments on commit 255dc01

Please sign in to comment.