rvv041 #82
1 changed files with 34 additions and 5 deletions
|
@ -162,6 +162,7 @@ data DisplayType
|
|||
| TxDisplay
|
||||
| SyncDisplay
|
||||
| SendDisplay
|
||||
| AdrBookEntryDisplay
|
||||
| BlankDisplay
|
||||
|
||||
data Tick
|
||||
|
@ -194,6 +195,9 @@ data State = State
|
|||
, _abaddresses :: !(L.List Name (Entity AddressBook))
|
||||
pitmutt marked this conversation as resolved
Outdated
|
||||
, _abForm :: !(Form AdrBookEntry () Name)
|
||||
, _abCurAdrs :: !T.Text
|
||||
pitmutt marked this conversation as resolved
Outdated
pitmutt
commented
What is this field for? What is this field for?
|
||||
, _abTxt :: !T.Text
|
||||
pitmutt marked this conversation as resolved
Outdated
pitmutt
commented
What is this field for? What is this field for?
|
||||
, _showConfirm :: Bool
|
||||
, _confirmResult :: Maybe Bool
|
||||
}
|
||||
|
||||
makeLenses ''State
|
||||
|
@ -411,7 +415,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
(renderForm (st ^. abForm) <=>
|
||||
C.hCenter
|
||||
(hBox [capCommand "↲" " Delete", capCommand3 "" "<Esc>" " Cancel"]))
|
||||
|
||||
--
|
||||
|
||||
splashDialog :: State -> Widget Name
|
||||
splashDialog st =
|
||||
|
@ -547,6 +551,14 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
(strWrapWith
|
||||
(WrapSettings False True NoFill FillAfterFirst)
|
||||
(st ^. msg)))
|
||||
AdrBookEntryDisplay ->
|
||||
withBorderStyle unicodeBold $
|
||||
D.renderDialog
|
||||
(D.dialog (Just $ txt " Address Book Entry ") Nothing 60)
|
||||
(padAll 1 $
|
||||
txtWrapWith (WrapSettings False True NoFill FillAfterFirst) $
|
||||
(st ^. abTxt))
|
||||
|
||||
BlankDisplay -> emptyWidget
|
||||
|
||||
mkInputForm :: DialogInput -> Form DialogInput e Name
|
||||
|
@ -749,6 +761,7 @@ appEvent (BT.AppEvent t) = do
|
|||
TxDisplay -> return ()
|
||||
SyncDisplay -> return ()
|
||||
SendDisplay -> BT.modify $ set msg m
|
||||
AdrBookEntryDisplay -> return ()
|
||||
BlankDisplay -> return ()
|
||||
TickVal v -> do
|
||||
case s ^. displayBox of
|
||||
|
@ -757,6 +770,7 @@ appEvent (BT.AppEvent t) = do
|
|||
PhraseDisplay -> return ()
|
||||
TxDisplay -> return ()
|
||||
SendDisplay -> return ()
|
||||
AdrBookEntryDisplay -> return ()
|
||||
SyncDisplay -> do
|
||||
if s ^. barValue == 1.0
|
||||
then do
|
||||
|
@ -880,6 +894,7 @@ appEvent (BT.VtyEvent e) = do
|
|||
TxDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||
SendDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||
SyncDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||
AdrBookEntryDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||
BlankDisplay -> do
|
||||
case s ^. dialogBox of
|
||||
WName -> do
|
||||
|
@ -1084,6 +1099,18 @@ appEvent (BT.VtyEvent e) = do
|
|||
V.EvKey (V.KChar 'n') [] -> do
|
||||
BT.modify $ set abForm $ mkNewABForm (AdrBookEntry "" "")
|
||||
BT.modify $ set dialogBox AdrBookForm
|
||||
-- Show AddressBook entry data
|
||||
V.EvKey V.KEnter [] -> do
|
||||
case L.listSelectedElement $ s ^. abaddresses of
|
||||
Just (_, a) -> do
|
||||
BT.modify $ set abTxt $ T.pack $
|
||||
" Descr: " ++
|
||||
T.unpack (addressBookDescrip (entityVal a)) ++
|
||||
"\n Address: " ++
|
||||
T.unpack (addressBookAddress (entityVal a))
|
||||
BT.modify $ set displayBox AdrBookEntryDisplay
|
||||
_ -> do
|
||||
BT.modify $ set dialogBox Blank
|
||||
-- Process any other event
|
||||
ev -> BT.zoom abaddresses $ L.handleListEvent ev
|
||||
-- Process new address book entry
|
||||
|
@ -1106,8 +1133,8 @@ appEvent (BT.VtyEvent e) = do
|
|||
BT.modify $ set msg ("New AddressBook entry created!!\n" ++ T.unpack (fs ^.address))
|
||||
BT.modify $ set displayBox MsgDisplay
|
||||
-- case end
|
||||
ab <- liftIO $ refreshAddressBook s
|
||||
BT.put ab
|
||||
s' <- liftIO $ refreshAddressBook s
|
||||
BT.put s'
|
||||
BT.modify $ set dialogBox AdrBook
|
||||
else do
|
||||
BT.modify $ set msg "Invalid or missing data!!: "
|
||||
|
@ -1134,7 +1161,6 @@ appEvent (BT.VtyEvent e) = do
|
|||
BT.modify $ set msg ("AddressBook entry modified!!\n" ++ T.unpack (fs ^.address))
|
||||
BT.modify $ set displayBox MsgDisplay
|
||||
-- case end
|
||||
-- BT.modify $ set dialogBox AdrBook
|
||||
s' <- liftIO $ refreshAddressBook s
|
||||
BT.put s'
|
||||
BT.modify $ set dialogBox AdrBook
|
||||
|
@ -1149,7 +1175,7 @@ appEvent (BT.VtyEvent e) = do
|
|||
setFieldValid
|
||||
(isRecipientValid (fs ^. address))
|
||||
AddressField
|
||||
-- Process new address book entry
|
||||
-- Process delete AddresBook entry
|
||||
AdrBookDelForm -> do
|
||||
case e of
|
||||
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox AdrBook
|
||||
|
@ -1306,6 +1332,9 @@ runZenithCLI config = do
|
|||
(L.list ABList (Vec.fromList abookList) 1)
|
||||
(mkNewABForm (AdrBookEntry "" ""))
|
||||
" "
|
||||
""
|
||||
False
|
||||
Nothing
|
||||
Left e -> print $
|
||||
"No Zebra node available on port " <>
|
||||
show port <> ". Check your configuration."
|
||||
|
|
Loading…
Reference in a new issue
The field should be named
_abAddresses