From 126381a409541503e60ad848a010ff42ab4521be Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Fri, 3 May 2019 08:27:11 +0200 Subject: [PATCH] fix db columns for files --- src/Handler/Material.hs | 4 ++-- src/Handler/Utils/Table/Columns.hs | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Handler/Material.hs b/src/Handler/Material.hs index 528e06d84..cf5c46aca 100644 --- a/src/Handler/Material.hs +++ b/src/Handler/Material.hs @@ -127,8 +127,8 @@ getMShowR tid ssh csh mnm = do , dbtFilterUI = mempty , dbtIdent = "material-files" :: Text , dbtSorting = Map.fromList - [ sortFilePath $ $(sqlIJproj 2 2) E.^. FileTitle - , sortFileModification $ $(sqlIJproj 2 2) E.^. FileModified + [ sortFilePath $(sqlIJproj 2 2) + , sortFileModification $(sqlIJproj 2 2) ] } diff --git a/src/Handler/Utils/Table/Columns.hs b/src/Handler/Utils/Table/Columns.hs index f3be69490..30d2e6a4a 100644 --- a/src/Handler/Utils/Table/Columns.hs +++ b/src/Handler/Utils/Table/Columns.hs @@ -60,14 +60,11 @@ colFilePathSimple row2path row2link = sortable (Just "path") (i18nCell MsgFileTi colFileModification :: (IsDBTable m c) => (t -> E.Value UTCTime) -> Colonnade Sortable t (DBCell m c) colFileModification row2time = sortable (Just "time") (i18nCell MsgFileModified) (timeCell . E.unValue . row2time) --- sortFilePath :: IsString a => (t -> E.SqlExpr (Entity ???)) -> (a, SortColumn t) -sortFilePath :: (PersistField a2, IsString a1) => - (t -> E.SqlExpr (E.Value a2)) -> (a1, SortColumn t) -sortFilePath queryPath = ("path", SortColumn queryPath) +sortFilePath :: IsString s => (r -> E.SqlExpr (Entity File)) -> (s, SortColumn r) +sortFilePath queryPath = ("path", SortColumn $ queryPath >>> (E.^. FileTitle)) -sortFileModification :: (PersistField a2, IsString a1) => - (t -> E.SqlExpr (E.Value a2)) -> (a1, SortColumn t) -sortFileModification queryModification = ("time", SortColumn queryModification) +sortFileModification :: IsString s => (r -> E.SqlExpr (Entity File)) -> (s, SortColumn r) +sortFileModification queryModification = ("time", SortColumn $ queryModification >>> (E.^. FileModified)) defaultSortingByFileTitle :: PSValidator m x -> PSValidator m x defaultSortingByFileTitle = defaultSorting [SortAscBy "path"]