diff --git a/src/Handler/Profile.hs b/src/Handler/Profile.hs index 8429c04c7..ee965626e 100644 --- a/src/Handler/Profile.hs +++ b/src/Handler/Profile.hs @@ -605,10 +605,8 @@ makeProfileData usrEnt@(Entity uid User{..}) = do E.on $ usrComp E.^. UserCompanyCompany E.==. comp E.^. CompanyId E.where_ $ usrComp E.^. UserCompanyUser E.==. E.val uid E.orderBy [E.asc (comp E.^. CompanyName)] -- E.desc (usrComp E.^. UserCompanySupervisor), - return (comp E.^. CompanyName, usrComp E.^. UserCompanySupervisor) - let companies = intersperse (text2markup ", ") $ - (\(E.Value cmpName, E.Value cmpSpr) -> text2markup (CI.original cmpName) <> bool mempty icnSuper cmpSpr) <$> companies' - icnSuper = text2markup " " <> icon IconSupervisor + return (comp E.^. CompanyShorthand, comp E.^. CompanyName, usrComp E.^. UserCompanySupervisor) + let companies = intersperse (text2widget ", ") $ companyWidget . $(E.unValueN 3) <$> companies' supervisors' <- E.select $ E.from $ \(spvr `E.InnerJoin` usrSpvr) -> do E.on $ spvr E.^. UserSupervisorSupervisor E.==. usrSpvr E.^. UserId E.where_ $ spvr E.^. UserSupervisorUser E.==. E.val uid diff --git a/src/Handler/Utils/Table/Cells.hs b/src/Handler/Utils/Table/Cells.hs index 48c2e4444..18b2186fb 100644 --- a/src/Handler/Utils/Table/Cells.hs +++ b/src/Handler/Utils/Table/Cells.hs @@ -356,10 +356,11 @@ courseCell Course{..} = anchorCell link name `mappend` desc ^{modal "Beschreibung" (Right $ toWidget descr)} |] +-- also see Handler.Utils.Widgets.companyWidget companyCell :: IsDBTable m a => CompanyShorthand -> CompanyName -> Bool -> DBCell m a -companyCell csh cname isSupervisor = anchorCell link name +companyCell csh cname isSupervisor = anchorCell curl name where - link = FirmUsersR csh + curl = FirmUsersR csh corg = ciOriginal cname name | isSupervisor = text2markup (corg <> " ") <> icon IconSupervisor diff --git a/src/Handler/Utils/Widgets.hs b/src/Handler/Utils/Widgets.hs index 1e5f6bdc2..3f6b1fe89 100644 --- a/src/Handler/Utils/Widgets.hs +++ b/src/Handler/Utils/Widgets.hs @@ -14,6 +14,7 @@ import Handler.Utils.DateTime import qualified Data.Char as Char import qualified Data.HashMap.Strict as Aeson -- ON UPDATE replace with: import qualified Data.Aeson.KeyMap as Aeson +import Data.Scientific --------- -- Simple utilities for consistent display @@ -131,6 +132,16 @@ modalAccess wdgtNo wdgtYes writeAccess route = do then modal wdgtYes (Left $ SomeRoute route) else wdgtNo +-- also see Handler.Utils.Table.Cells.companyCell +companyWidget :: (CompanyShorthand, CompanyName, Bool) -> Widget +companyWidget (csh, cname, isSupervisor) = simpleLink (toWgt name) curl + where + curl = FirmUsersR csh + corg = ciOriginal cname + name + | isSupervisor = text2markup (corg <> " ") <> icon IconSupervisor + | otherwise = text2markup corg + ---------- -- HEAT -- ---------- @@ -253,7 +264,9 @@ jsonWidget x = jsonWidgetAux $ toJSON x jsonWidgetAux Null = [whamlet|Null|] jsonWidgetAux (Bool b) = toWidget $ boolSymbol b jsonWidgetAux (String s) = [whamlet|#{s}|] - jsonWidgetAux (Number n) = [whamlet|#{show n}|] + jsonWidgetAux (Number n) + | isInteger n = [whamlet|#{formatScientific Fixed (Just 0) n}|] + | otherwise = [whamlet|#{formatScientific Generic Nothing n}|] jsonWidgetAux (Array l) | 1 >= length l = foldMap jsonWidgetAux l -- empty arrays don't show | otherwise = diff --git a/src/Utils/Avs.hs b/src/Utils/Avs.hs index c54b80864..704459f51 100644 --- a/src/Utils/Avs.hs +++ b/src/Utils/Avs.hs @@ -102,7 +102,7 @@ mkAvsQuery _ _ _ = AvsQuery AvsQueryPerson{avsPersonQueryCardNo=Just (AvsCardNo "00006666"), avsPersonQueryVersionNo=Just "4"} -> AvsResponsePerson $ sumpfi1 <> sumpfi2 <> sumpfi3 AvsQueryPerson{avsPersonQueryCardNo=Just (AvsCardNo "00007777"), avsPersonQueryVersionNo=Just "4"} -> AvsResponsePerson $ sumpfi1 <> sumpfi2 <> sumpfi3 AvsQueryPerson{avsPersonQueryCardNo=Just (AvsCardNo "00008888"), avsPersonQueryVersionNo=Just "4"} -> AvsResponsePerson $ sumpfi1 <> sumpfi2 <> sumpfi3 - _ -> AvsResponsePerson mempty + _ -> AvsResponsePerson steffen fakeStatus :: AvsQueryStatus -> AvsResponseStatus fakeStatus (AvsQueryStatus (Set.toList -> (api:_))) = AvsResponseStatus $ Set.singleton $ AvsStatusPerson api $ Set.fromList diff --git a/src/Utils/Icon.hs b/src/Utils/Icon.hs index 0ec91a144..db18d2772 100644 --- a/src/Utils/Icon.hs +++ b/src/Utils/Icon.hs @@ -118,7 +118,7 @@ data Icon | IconCompany | IconEdit | IconUserEdit - | IconMagic -- indicates automatic updates + -- | IconMagic -- indicates automatic updates deriving (Eq, Ord, Enum, Bounded, Show, Read, Generic) deriving anyclass (Universe, Finite, NFData) @@ -215,7 +215,7 @@ iconText = \case IconCompany -> "building" IconEdit -> "edit" IconUserEdit -> "user-edit" - IconMagic -> "wand-magic" + -- IconMagic -> "wand-magic" nullaryPathPiece ''Icon $ camelToPathPiece' 1 deriveLift ''Icon @@ -298,10 +298,10 @@ isNew :: Bool -> Markup isNew True = icon IconNew isNew False = mempty --- ^ Maybe display an icon that denotes that something™ is automagically updated or derived +-- ^ Maybe display an icon that denotes that something™ is NOT automagically updated or derived, but had been edited isAutomatic :: Bool -> Markup -isAutomatic True = icon IconMagic -isAutomatic False = mempty +isAutomatic True = mempty -- icon IconMagic +isAutomatic False = icon IconLocked -- IconEdit boolSymbol :: Bool -> Markup boolSymbol True = icon IconOK diff --git a/templates/profileData.hamlet b/templates/profileData.hamlet index b33419227..2c51809a5 100644 --- a/templates/profileData.hamlet +++ b/templates/profileData.hamlet @@ -37,7 +37,7 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later