diff --git a/src/Zenith/GUI.hs b/src/Zenith/GUI.hs index 932c07e..1b430d7 100644 --- a/src/Zenith/GUI.hs +++ b/src/Zenith/GUI.hs @@ -20,7 +20,7 @@ import Data.Maybe (fromJust, fromMaybe, isJust, isNothing) import qualified Data.Text as T import qualified Data.Text.Encoding as E import Data.Time.Clock.POSIX (posixSecondsToUTCTime) -import Database.Esqueleto.Experimental (ConnectionPool) +import Database.Esqueleto.Experimental (ConnectionPool, fromSqlKey) import Database.Persist import Lens.Micro ((&), (+~), (.~), (?~), (^.), set) import Lens.Micro.TH @@ -60,6 +60,7 @@ import Zenith.Utils , validBarValue , validateAddressBool , isValidString + , padWithZero ) data AppEvent @@ -802,11 +803,14 @@ buildUI wenv model = widgetTree abookRow :: Int -> Entity AddressBook -> WidgetNode AppModel AppEvent abookRow idx ab = box_ - [onClick $ ShowTx idx, alignLeft] + [onClick $ ShowTx idx, alignLeft] (hstack - [ - (label "Descr: ") `styleBasic` [textFont "Bold"] - , spacer + [ + label + (T.pack $ + padWithZero 3 $ + show (fromSqlKey (entityKey ab))) `styleBasic` [textFont "Bold"] + , spacer , label (T.pack $ show (addressBookAbdescrip $ entityVal ab)) diff --git a/src/Zenith/Utils.hs b/src/Zenith/Utils.hs index 84b3ab9..b87d412 100644 --- a/src/Zenith/Utils.hs +++ b/src/Zenith/Utils.hs @@ -152,4 +152,9 @@ isValidString :: T.Text -> Bool isValidString c = do let a = T.unpack c isValidContent a + +padWithZero :: Int -> String -> String +padWithZero n s + | (length s) >= n = s + | otherwise = padWithZero n ("0" ++ s)