Add base addressbook to GUI #102

Merged
pitmutt merged 21 commits from rvv041 into milestone3 2024-09-13 11:39:59 +00:00
2 changed files with 14 additions and 5 deletions
Showing only changes of commit 73ad2f0eb3 - Show all commits

View file

@ -20,7 +20,7 @@ import Data.Maybe (fromJust, fromMaybe, isJust, isNothing)
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Text.Encoding as E import qualified Data.Text.Encoding as E
import Data.Time.Clock.POSIX (posixSecondsToUTCTime) import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
import Database.Esqueleto.Experimental (ConnectionPool) import Database.Esqueleto.Experimental (ConnectionPool, fromSqlKey)
import Database.Persist import Database.Persist
import Lens.Micro ((&), (+~), (.~), (?~), (^.), set) import Lens.Micro ((&), (+~), (.~), (?~), (^.), set)
import Lens.Micro.TH import Lens.Micro.TH
@ -60,6 +60,7 @@ import Zenith.Utils
, validBarValue , validBarValue
, validateAddressBool , validateAddressBool
, isValidString , isValidString
, padWithZero
) )
data AppEvent data AppEvent
@ -802,11 +803,14 @@ buildUI wenv model = widgetTree
abookRow :: Int -> Entity AddressBook -> WidgetNode AppModel AppEvent abookRow :: Int -> Entity AddressBook -> WidgetNode AppModel AppEvent
abookRow idx ab = abookRow idx ab =
box_ box_
[onClick $ ShowTx idx, alignLeft] [onClick $ ShowTx idx, alignLeft]
(hstack (hstack
[ [
(label "Descr: ") `styleBasic` [textFont "Bold"] label
, spacer (T.pack $
padWithZero 3 $
show (fromSqlKey (entityKey ab))) `styleBasic` [textFont "Bold"]
, spacer
, label , label
(T.pack $ (T.pack $
show (addressBookAbdescrip $ entityVal ab)) show (addressBookAbdescrip $ entityVal ab))

View file

@ -152,4 +152,9 @@ isValidString :: T.Text -> Bool
isValidString c = do isValidString c = do
let a = T.unpack c let a = T.unpack c
isValidContent a isValidContent a
padWithZero :: Int -> String -> String
padWithZero n s
| (length s) >= n = s
| otherwise = padWithZero n ("0" ++ s)