fix db columns for files

This commit is contained in:
Steffen Jost 2019-05-03 08:27:11 +02:00
parent 88fc32e13f
commit 126381a409
2 changed files with 6 additions and 9 deletions

View File

@ -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)
]
}

View File

@ -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"]