diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index c0845cf30..5e09e2b7e 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -59,7 +59,7 @@ colDescription = sortable Nothing (i18nCell MsgCourseDescription) $ \DBRow{ dbrOutput=(Entity cid Course{..}, _, _, _) } -> case courseDescription of Nothing -> mempty - (Just descr) -> cell $ modalStatic "Beschreibung" descr False + (Just descr) -> cell $ modal "Beschreibung" (Right $ toWidget descr) colCShort :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a) colCShort = sortable (Just "cshort") (i18nCell MsgCourseShort) @@ -73,7 +73,11 @@ colCShortDescr = sortable (Just "cshort") (i18nCell MsgCourseShort) ( case courseDescription of Nothing -> mempty (Just descr) -> cell - [whamlet| ^{modalStatic "Beschreibung" descr False} |] + [whamlet| + $newline never + + ^{modal "Beschreibung" (Right $ toWidget descr)} + |] ) colTerm :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a) diff --git a/src/Handler/Utils/Table/Cells.hs b/src/Handler/Utils/Table/Cells.hs index ea3487088..65bc11452 100644 --- a/src/Handler/Utils/Table/Cells.hs +++ b/src/Handler/Utils/Table/Cells.hs @@ -76,7 +76,11 @@ courseCell (Course {..}) = anchorCell link name `mappend` desc name = citext2widget courseName desc = case courseDescription of Nothing -> mempty - (Just descr) -> cell [whamlet| ^{modalStatic "Beschreibung" descr False} |] + (Just descr) -> cell [whamlet| + $newline never + + ^{modal "Beschreibung" (Right $ toWidget descr)} + |] sheetCell :: IsDBTable m a => CourseLink -> SheetName -> DBCell m a sheetCell crse shn = diff --git a/src/Handler/Utils/Templates.hs b/src/Handler/Utils/Templates.hs index c98084962..752d2a68e 100644 --- a/src/Handler/Utils/Templates.hs +++ b/src/Handler/Utils/Templates.hs @@ -2,26 +2,19 @@ module Handler.Utils.Templates where +import Data.Either (isLeft) + import Import.NoFoundation lipsum :: WidgetT site IO () lipsum = $(widgetFile "widgets/lipsum") -modalStatic :: Html -> Html -> Bool -> WidgetT site IO () -modalStatic modalTrigger modalContent modalDynamic = do - modalId <- newIdent - triggerId <- newIdent - $(widgetFile "widgets/modalStatic") - [whamlet|
#{modalTrigger}|] -- TODO: modalDynamic - -modalWidget :: Html -> WidgetT site IO () -> Bool -> WidgetT site IO () -modalWidget modalTrigger modalContent modalDynamic = do +modal :: WidgetT site IO () -> Either (Route site) (WidgetT site IO ()) -> WidgetT site IO () +modal modalTrigger modalContent = do + let modalDynamic = isLeft modalContent modalId <- newIdent triggerId <- newIdent $(widgetFile "widgets/modalWidget") - [whamlet|
#{modalTrigger}|] - -modal :: Html -> [Char] -> Bool -> WidgetT site IO () -modal triggerId modalContent modalDynamic = do - modalId <- newIdent - $(widgetFile "widgets/modal") + case modalContent of + Left route -> [whamlet|^{modalTrigger}|] + Right content -> [whamlet|
^{modalTrigger}|] diff --git a/templates/adminTest.hamlet b/templates/adminTest.hamlet index 6fbc3ce06..651d6b6e0 100644 --- a/templates/adminTest.hamlet +++ b/templates/adminTest.hamlet @@ -32,9 +32,5 @@ ^{btnWdgt}

  • Modals: - ^{modal "toggler1" "" True} -
    Klick mich für Ajax-Test - - ^{modal "toggler2" "Test Inhalt für Modal" False} -
    Klick mich für Content-Test - + ^{modal "Klick mich für Ajax-Test" (Left UsersR)} + ^{modal "Klick mich für Content-Test" (Right "Test Inhalt für Modal")} diff --git a/templates/profileData.hamlet b/templates/profileData.hamlet index bf7419342..8d2b42a71 100644 --- a/templates/profileData.hamlet +++ b/templates/profileData.hamlet @@ -51,7 +51,7 @@ .

    - ^{modalWidget "Alle Benutzerbezogenen Daten löschen" delWdgt False} + ^{modal "Alle Benutzerbezogenen Daten löschen" (Right delWdgt)}

    Hinweise:
      diff --git a/templates/widgets/modal.hamlet b/templates/widgets/modal.hamlet deleted file mode 100644 index ae09cb507..000000000 --- a/templates/widgets/modal.hamlet +++ /dev/null @@ -1,2 +0,0 @@ -
      - #{modalContent} diff --git a/templates/widgets/modalStatic.hamlet b/templates/widgets/modalStatic.hamlet deleted file mode 100644 index ae09cb507..000000000 --- a/templates/widgets/modalStatic.hamlet +++ /dev/null @@ -1,2 +0,0 @@ -
      - #{modalContent} diff --git a/templates/widgets/modalWidget.hamlet b/templates/widgets/modalWidget.hamlet index 80154aaba..a971aab83 100644 --- a/templates/widgets/modalWidget.hamlet +++ b/templates/widgets/modalWidget.hamlet @@ -1,2 +1,5 @@
      - ^{modalContent} + $case modalContent + $of Right content + ^{content} + $of Left _