Add base addressbook to GUI #102
1 changed files with 50 additions and 3 deletions
|
@ -118,6 +118,8 @@ data AppEvent
|
||||||
| CheckValidAddress !T.Text
|
| CheckValidAddress !T.Text
|
||||||
| CheckValidDescrip !T.Text
|
| CheckValidDescrip !T.Text
|
||||||
| SaveNewABEntry
|
| SaveNewABEntry
|
||||||
|
| UpdateABEntry !T.Text !T.Text
|
||||||
|
| CloseUpdABEntry
|
||||||
| ShowMessage !T.Text
|
| ShowMessage !T.Text
|
||||||
| ShowABAddress !T.Text !T.Text
|
| ShowABAddress !T.Text !T.Text
|
||||||
| CloseShowABAddress
|
| CloseShowABAddress
|
||||||
|
@ -173,6 +175,7 @@ data AppModel = AppModel
|
||||||
, _abaddressList :: ![Entity AddressBook]
|
, _abaddressList :: ![Entity AddressBook]
|
||||||
, _msgAB :: !(Maybe T.Text)
|
, _msgAB :: !(Maybe T.Text)
|
||||||
, _showABAddress :: !Bool
|
, _showABAddress :: !Bool
|
||||||
|
, _updateABAddress :: !Bool
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
makeLenses ''AppModel
|
makeLenses ''AppModel
|
||||||
|
@ -219,6 +222,9 @@ buildUI wenv model = widgetTree
|
||||||
, showABAddressOverlay
|
, showABAddressOverlay
|
||||||
(model ^. abdescrip)
|
(model ^. abdescrip)
|
||||||
(model ^. abaddress) `nodeVisible` model ^. showABAddress
|
(model ^. abaddress) `nodeVisible` model ^. showABAddress
|
||||||
|
, updateABAddressOverlay
|
||||||
|
(model ^. abdescrip)
|
||||||
|
(model ^. abaddress) `nodeVisible` model ^. updateABAddress
|
||||||
, msgAdrBookOverlay `nodeVisible` isJust (model ^. msgAB)
|
, msgAdrBookOverlay `nodeVisible` isJust (model ^. msgAB)
|
||||||
]
|
]
|
||||||
mainWindow =
|
mainWindow =
|
||||||
|
@ -861,6 +867,33 @@ buildUI wenv model = widgetTree
|
||||||
, button "Cancel" CloseNewAdrBook `nodeEnabled` True
|
, 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 =
|
showABAddressOverlay abd aba =
|
||||||
alert CloseShowABAddress $
|
alert CloseShowABAddress $
|
||||||
vstack
|
vstack
|
||||||
|
@ -884,9 +917,11 @@ buildUI wenv model = widgetTree
|
||||||
, spacer
|
, spacer
|
||||||
, hstack
|
, hstack
|
||||||
[ filler
|
[ filler
|
||||||
, button "Edit Entry" NotImplemented
|
, button "Edit Description" $ UpdateABEntry abd aba
|
||||||
, spacer
|
, spacer
|
||||||
, button "Copy address" $ CopyABAdress aba
|
, button "Copy Address" $ CopyABAdress aba
|
||||||
|
, spacer
|
||||||
|
, button "Delete Entry" $ NotImplemented
|
||||||
, filler
|
, filler
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -1224,6 +1259,16 @@ handleEvent wenv node model evt =
|
||||||
[Model $ model & newAdrBkEntry .~ True & menuPopup .~ False]
|
[Model $ model & newAdrBkEntry .~ True & menuPopup .~ False]
|
||||||
CloseNewAdrBook -> do
|
CloseNewAdrBook -> do
|
||||||
[Model $ model & newAdrBkEntry .~ False]
|
[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 ->
|
SaveNewABEntry ->
|
||||||
[ Task $
|
[ Task $
|
||||||
saveAddrBook
|
saveAddrBook
|
||||||
|
@ -1561,6 +1606,7 @@ runZenithGUI config = do
|
||||||
abList
|
abList
|
||||||
Nothing
|
Nothing
|
||||||
False
|
False
|
||||||
|
False
|
||||||
startApp model handleEvent buildUI (params hD)
|
startApp model handleEvent buildUI (params hD)
|
||||||
Left e -> do
|
Left e -> do
|
||||||
initDb dbFilePath
|
initDb dbFilePath
|
||||||
|
@ -1616,6 +1662,7 @@ runZenithGUI config = do
|
||||||
[]
|
[]
|
||||||
Nothing
|
Nothing
|
||||||
False
|
False
|
||||||
|
False
|
||||||
startApp model handleEvent buildUI (params hD)
|
startApp model handleEvent buildUI (params hD)
|
||||||
where
|
where
|
||||||
params hd =
|
params hd =
|
||||||
|
|
Loading…
Reference in a new issue