rvv041 - Address Book - Edit Address Book entry description in progress

- "Delete entry" button added (functionality not implemented yet)
This commit is contained in:
Rene V. Vergara A. 2024-09-07 17:09:33 -04:00
parent 87feab284e
commit 185738eccc

View file

@ -118,6 +118,8 @@ data AppEvent
| CheckValidAddress !T.Text
| CheckValidDescrip !T.Text
| SaveNewABEntry
| UpdateABEntry !T.Text !T.Text
| CloseUpdABEntry
| ShowMessage !T.Text
| ShowABAddress !T.Text !T.Text
| CloseShowABAddress
@ -173,6 +175,7 @@ data AppModel = AppModel
, _abaddressList :: ![Entity AddressBook]
, _msgAB :: !(Maybe T.Text)
, _showABAddress :: !Bool
, _updateABAddress :: !Bool
} deriving (Eq, Show)
makeLenses ''AppModel
@ -219,6 +222,9 @@ buildUI wenv model = widgetTree
, showABAddressOverlay
(model ^. abdescrip)
(model ^. abaddress) `nodeVisible` model ^. showABAddress
, updateABAddressOverlay
(model ^. abdescrip)
(model ^. abaddress) `nodeVisible` model ^. updateABAddress
, msgAdrBookOverlay `nodeVisible` isJust (model ^. msgAB)
]
mainWindow =
@ -861,6 +867,33 @@ buildUI wenv model = widgetTree
, button "Cancel" CloseNewAdrBook `nodeEnabled` True
]
]
updateABAddressOverlay abd aba =
alert CloseUpdABEntry $
vstack
[ box_
[]
(label "Edit Address Description" `styleBasic`
[textFont "Bold", textSize 10, textColor white]) `styleBasic`
[bgColor btnColor, radius 2, padding 3]
, spacer
, hstack
[ label "Description:" `styleBasic` [width 80]
, spacer
, textField_ abdescrip [onChange CheckValidDescrip] `styleBasic`
[ width 320
, styleIf (not $ model ^. abDescripValid) (textColor red)
]
]
, spacer
, hstack
[ filler
, button "Save" NotImplemented
-- ((model ^. abAddressValid) && (model ^. abDescripValid))
, spacer
, button "Cancel" CloseUpdABEntry `nodeEnabled` True
, filler
]
]
showABAddressOverlay abd aba =
alert CloseShowABAddress $
vstack
@ -884,9 +917,11 @@ buildUI wenv model = widgetTree
, spacer
, hstack
[ filler
, button "Edit Entry" NotImplemented
, button "Edit Description" $ UpdateABEntry abd aba
, spacer
, button "Copy address" $ CopyABAdress aba
, button "Copy Address" $ CopyABAdress aba
, spacer
, button "Delete Entry" $ NotImplemented
, filler
]
]
@ -1224,6 +1259,16 @@ handleEvent wenv node model evt =
[Model $ model & newAdrBkEntry .~ True & menuPopup .~ False]
CloseNewAdrBook -> do
[Model $ model & newAdrBkEntry .~ False]
UpdateABEntry d a ->
[ Model $
model & abdescrip .~ d
& abaddress .~ a
& updateABAddress .~ True
& abDescripValid .~ True
& menuPopup .~ False
]
CloseUpdABEntry -> do
[Model $ model & updateABAddress .~ False]
SaveNewABEntry ->
[ Task $
saveAddrBook
@ -1561,6 +1606,7 @@ runZenithGUI config = do
abList
Nothing
False
False
startApp model handleEvent buildUI (params hD)
Left e -> do
initDb dbFilePath
@ -1616,6 +1662,7 @@ runZenithGUI config = do
[]
Nothing
False
False
startApp model handleEvent buildUI (params hD)
where
params hd =