From 04ac80a8ba07892a1210d4cc8a7a2a0b4bead7f2 Mon Sep 17 00:00:00 2001 From: SJost Date: Thu, 2 Aug 2018 16:55:49 +0200 Subject: [PATCH 1/3] CourseDescription not working properly in CourseList --- src/Foundation.hs | 8 ++++++++ src/Handler/Course.hs | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Foundation.hs b/src/Foundation.hs index 6931f8eb7..58414a529 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -822,6 +822,14 @@ pageActions (TermCourseListR tid) = , menuItemAccessCallback' = return True } ] +pageActions (CourseListR) = + [ PageActionPrime $ MenuItem + { menuItemLabel = "Neuen Kurs anlegen" + , menuItemIcon = Just "book" + , menuItemRoute = CourseNewR + , menuItemAccessCallback' = return True + } + ] pageActions (CourseR tid csh CShowR) = [ PageActionPrime $ MenuItem { menuItemLabel = "Kurs Editieren" diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index 4ff4676a7..cfc236176 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -38,7 +38,15 @@ type CourseTableData = DBRow (Entity Course, Int64, Bool) colCourse :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a) colCourse = sortable (Just "course") (i18nCell MsgCourse) $ \DBRow{ dbrOutput=(Entity cid Course{..}, _, _) } -> - anchorCell (CourseR courseTerm courseShorthand CShowR) [whamlet|#{display courseName}|] + anchorCell (CourseR courseTerm courseShorthand CShowR) + [whamlet|#{display courseName}|] + +colDescription :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a) +colDescription = sortable Nothing (i18nCell MsgCourseDescription) + $ \DBRow{ dbrOutput=(Entity cid Course{..}, _, _) } -> + case courseDescription of + Nothing -> cell mempty + (Just d)-> cell [whamlet|

|] colCShort :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a) colCShort = sortable (Just "cshort") (i18nCell MsgCourseShort) @@ -139,6 +147,7 @@ getCourseListR = do -- TODO: Suchfunktion für Kurse und Kürzel!!! [ colCourse , colCShort , colTerm +-- , colDescription -- does not work as intended issue #80 , maybe mempty (const colRegistered) muid ] whereClause = const $ E.val True From 3cadf224afdfaf300fd45bfd19d1e1d14537f48a Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Thu, 2 Aug 2018 21:34:52 +0200 Subject: [PATCH 2/3] made tooltip-styles globally available --- templates/standalone/tooltip.lucius | 96 ++++++++++++++--------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/templates/standalone/tooltip.lucius b/templates/standalone/tooltip.lucius index fdd05afd0..b123609c6 100644 --- a/templates/standalone/tooltip.lucius +++ b/templates/standalone/tooltip.lucius @@ -2,59 +2,59 @@ position: relative; display: inline-block; - .tooltip__handle { - background-color: var(--color-dark); - border-radius: 50%; - height: 1.5rem; - width: 1.5rem; - line-height: 1.5rem; - font-size: 1.2rem; - color: white; - display: inline-block; - text-align: center; - cursor: default; - margin: 0 10px; - } - - .tooltip__content { - position: absolute; - top: -10px; - transform: translateY(-100%); - left: 3px; - width: 275px; - z-index: 10; - background-color: #fafafa; - border-radius: 4px; - padding: 13px 17px; - box-shadow: 0 0 20px 4px rgba(0, 0, 0, 0.1); - - &.to-left { - left: auto; - right: 3px; - - &::after { - left: auto; - right: 10px; - } - } - - &::after { - content: ''; - width: 16px; - height: 16px; - background-color: #fafafa; - transform: rotate(45deg); - position: absolute; - left: 10px; - bottom: -8px; - } - } - .hidden { display: none; } } +.tooltip__handle { + background-color: var(--color-dark); + border-radius: 50%; + height: 1.5rem; + width: 1.5rem; + line-height: 1.5rem; + font-size: 1.2rem; + color: white; + display: inline-block; + text-align: center; + cursor: default; + margin: 0 10px; +} + +.tooltip__content { + position: absolute; + top: -10px; + transform: translateY(-100%); + left: 3px; + width: 275px; + z-index: 10; + background-color: #fafafa; + border-radius: 4px; + padding: 13px 17px; + box-shadow: 0 0 20px 4px rgba(0, 0, 0, 0.1); + + &.to-left { + left: auto; + right: 3px; + + &::after { + left: auto; + right: 10px; + } + } + + &::after { + content: ''; + width: 16px; + height: 16px; + background-color: #fafafa; + transform: rotate(45deg); + position: absolute; + left: 10px; + bottom: -8px; + } +} + @media (max-width: 768px) { .js-tooltip { From 13b575b952d61b442e8c6108f318ba62f739c792 Mon Sep 17 00:00:00 2001 From: SJost Date: Fri, 3 Aug 2018 11:46:13 +0200 Subject: [PATCH 3/3] Course List features Course Descriptions now. fixes issue #80 now. fix #80 --- ChangeLog.md | 1 + src/Handler/Course.hs | 32 +++++++++++++++++++++++----- src/Handler/Utils/Templates.hs | 15 ++++++++++--- templates/widgets/modalStatic.hamlet | 2 ++ 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 templates/widgets/modalStatic.hamlet diff --git a/ChangeLog.md b/ChangeLog.md index a114345ce..c0392847e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,7 @@ * Version 01.08.2018 Verbesserter Campus-Login + (Ersatz einer C-Bibliothek mit undokumentierter Abhängigkeit durch selbst entwickelten Haskell-Code erlaubt nun auch Umlaute.) * Version 31.07.2018 diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index cfc236176..60c2af5a3 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -41,18 +41,37 @@ colCourse = sortable (Just "course") (i18nCell MsgCourse) anchorCell (CourseR courseTerm courseShorthand CShowR) [whamlet|#{display courseName}|] +colCourseDescr :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a) +colCourseDescr = sortable (Just "course") (i18nCell MsgCourse) + $ \DBRow{ dbrOutput=(Entity cid Course{..}, _, _) } -> mappend + ( anchorCell (CourseR courseTerm courseShorthand CShowR) [whamlet|#{display courseName}|] ) + ( case courseDescription of + Nothing -> mempty + (Just descr) -> cell [whamlet| ^{modalStatic descr} |] + ) + colDescription :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a) colDescription = sortable Nothing (i18nCell MsgCourseDescription) $ \DBRow{ dbrOutput=(Entity cid Course{..}, _, _) } -> case courseDescription of - Nothing -> cell mempty - (Just d)-> cell [whamlet|

|] + Nothing -> mempty + (Just descr) -> cell $ modalStatic descr colCShort :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a) colCShort = sortable (Just "cshort") (i18nCell MsgCourseShort) $ \DBRow{ dbrOutput=(Entity cid Course{..}, _, _) } -> anchorCell (CourseR courseTerm courseShorthand CShowR) [whamlet|#{display courseShorthand}|] +colCShortDescr :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a) +colCShortDescr = sortable (Just "cshort") (i18nCell MsgCourseShort) + $ \DBRow{ dbrOutput=(Entity cid Course{..}, _, _) } -> mappend + ( anchorCell (CourseR courseTerm courseShorthand CShowR) [whamlet|#{display courseShorthand}|] ) + ( case courseDescription of + Nothing -> mempty + (Just descr) -> cell + [whamlet| ^{modalStatic descr} |] + ) + colTerm :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a) colTerm = sortable (Just "term") (i18nCell MsgTerm) $ \DBRow{ dbrOutput=(Entity cid Course{..}, _, _) } -> @@ -144,10 +163,9 @@ getCourseListR :: Handler Html getCourseListR = do -- TODO: Suchfunktion für Kurse und Kürzel!!! muid <- maybeAuthId let colonnade = widgetColonnade $ mconcat - [ colCourse + [ colCourseDescr , colCShort , colTerm --- , colDescription -- does not work as intended issue #80 , maybe mempty (const colRegistered) muid ] whereClause = const $ E.val True @@ -158,6 +176,10 @@ getCourseListR = do -- TODO: Suchfunktion für Kurse und Kürzel!!! setTitleI MsgCourseListTitle [whamlet|TODO: Such-/Filterfunktion hier einbauen|] -- TODO $(widgetFile "courses") + [whamlet| + ^{modal "#UNIQUE_ID_98765" (Just "Test Inhalt für Modal")} +

? + |] getTermCurrentR :: Handler Html getTermCurrentR = do @@ -173,7 +195,7 @@ getTermCourseListR tid = do muid <- maybeAuthId let colonnade = widgetColonnade $ mconcat [ dbRow - , colCShort + , colCShortDescr , colRegFrom , colRegTo , colParticipants diff --git a/src/Handler/Utils/Templates.hs b/src/Handler/Utils/Templates.hs index 8bae783b0..e29d9e3f9 100644 --- a/src/Handler/Utils/Templates.hs +++ b/src/Handler/Utils/Templates.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE NoImplicitPrelude, TemplateHaskell #-} +{-# LANGUAGE NoImplicitPrelude, TemplateHaskell, QuasiQuotes #-} module Handler.Utils.Templates where @@ -7,8 +7,17 @@ import Import.NoFoundation lipsum :: WidgetT site IO () lipsum = $(widgetFile "widgets/lipsum") -modal :: [Char] -> Maybe [Char] -> WidgetT site IO () -modal modalTrigger (Just modalContent) = do +modalStatic :: Html -> WidgetT site IO () +modalStatic modalContent = do + uniqueId <- newIdent + let modalTrigger = cons '#' uniqueId -- SJ: I am confused why this is needed here? + modalId :: Int32 + modalId = 13 + $(widgetFile "widgets/modalStatic") + [whamlet|
?|] -- SJ: confused why ## is needed here either? + +modal :: Text -> Maybe [Char] -> WidgetT site IO () +modal modalTrigger (Just modalContent) = do -- WARNING: ModalContent should not have length 11. SJ: This is possibly bad. See Template! let modalId :: Int32 modalId = 13 diff --git a/templates/widgets/modalStatic.hamlet b/templates/widgets/modalStatic.hamlet new file mode 100644 index 000000000..a9b8e3587 --- /dev/null +++ b/templates/widgets/modalStatic.hamlet @@ -0,0 +1,2 @@ +
+ #{modalContent}