From 6a68e1de7980959bd0c6021f0e9268bc3548128e Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Thu, 9 May 2019 19:58:03 +0200 Subject: [PATCH] show archive link on material show --- src/Handler/Material.hs | 5 ++++- src/Handler/Utils.hs | 3 +++ templates/material-show.hamlet | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Handler/Material.hs b/src/Handler/Material.hs index 2c6c98c65..54a130c79 100644 --- a/src/Handler/Material.hs +++ b/src/Handler/Material.hs @@ -127,7 +127,7 @@ getMaterialListR tid ssh csh = do $ liftA2 anchorCell matLink toWgt . materialName . row2material , sortable (toNothingS "description") mempty $ foldMap modalCell . materialDescription . row2material - , sortable (toNothingS "zip-archive") mempty + , sortable (toNothingS "zip-archive") mempty -- TODO: don't show if there are no files! $ zipCell . zipLink . materialName . row2material , sortable (Just "visible-from") (i18nCell MsgAccessibleSince) $ foldMap (dateTimeCellVisible now) . materialVisibleFrom . row2material @@ -179,6 +179,9 @@ getMShowR tid ssh csh mnm = do let matLink :: FilePath -> Route UniWorX matLink = CourseR tid ssh csh . MaterialR mnm . MFileR + zipLink :: Route UniWorX + zipLink = CMaterialR tid ssh csh mnm MArchiveR + seeAllModificationTimestamps <- hasReadAccessTo $ CourseR tid ssh csh CNotesR -- ordinary users should not see modification dates older than visibility ( Entity _mid material@Material{materialType, materialDescription} diff --git a/src/Handler/Utils.hs b/src/Handler/Utils.hs index 8e2a595e2..f5a7be596 100644 --- a/src/Handler/Utils.hs +++ b/src/Handler/Utils.hs @@ -69,6 +69,9 @@ tidFromText = fmap TermKey . maybeRight . termFromText simpleLink :: Widget -> Route UniWorX -> Widget simpleLink lbl url = [whamlet|^{lbl}|] +simpleLinkI :: SomeMessage UniWorX -> Route UniWorX -> Widget +simpleLinkI lbl url = [whamlet|_{lbl}|] + -- | toWidget-Version of @nameHtml@, for convenience nameWidget :: Text -- ^ userDisplayName -> Text -- ^ userSurname diff --git a/templates/material-show.hamlet b/templates/material-show.hamlet index 92dba855e..c3e00bc22 100644 --- a/templates/material-show.hamlet +++ b/templates/material-show.hamlet @@ -16,7 +16,7 @@ $maybe descr <- materialDescription
_{MsgFileModified}
#{materialLastEdit} -$if hasFiles || True +$if hasFiles
-

_{MsgMaterialFiles} +

^{simpleLinkI (SomeMessage MsgMaterialFiles) zipLink} ^{fileTable}