Grand unification of modals
This commit is contained in:
parent
57c313702c
commit
7068b3462e
@ -59,7 +59,7 @@ colDescription = sortable Nothing (i18nCell MsgCourseDescription)
|
|||||||
$ \DBRow{ dbrOutput=(Entity cid Course{..}, _, _, _) } ->
|
$ \DBRow{ dbrOutput=(Entity cid Course{..}, _, _, _) } ->
|
||||||
case courseDescription of
|
case courseDescription of
|
||||||
Nothing -> mempty
|
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 :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a)
|
||||||
colCShort = sortable (Just "cshort") (i18nCell MsgCourseShort)
|
colCShort = sortable (Just "cshort") (i18nCell MsgCourseShort)
|
||||||
@ -73,7 +73,11 @@ colCShortDescr = sortable (Just "cshort") (i18nCell MsgCourseShort)
|
|||||||
( case courseDescription of
|
( case courseDescription of
|
||||||
Nothing -> mempty
|
Nothing -> mempty
|
||||||
(Just descr) -> cell
|
(Just descr) -> cell
|
||||||
[whamlet|<span style="float:right"> ^{modalStatic "Beschreibung" descr False} |]
|
[whamlet|
|
||||||
|
$newline never
|
||||||
|
<span style="float:right">
|
||||||
|
^{modal "Beschreibung" (Right $ toWidget descr)}
|
||||||
|
|]
|
||||||
)
|
)
|
||||||
|
|
||||||
colTerm :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a)
|
colTerm :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a)
|
||||||
|
|||||||
@ -76,7 +76,11 @@ courseCell (Course {..}) = anchorCell link name `mappend` desc
|
|||||||
name = citext2widget courseName
|
name = citext2widget courseName
|
||||||
desc = case courseDescription of
|
desc = case courseDescription of
|
||||||
Nothing -> mempty
|
Nothing -> mempty
|
||||||
(Just descr) -> cell [whamlet| <span style="float:right"> ^{modalStatic "Beschreibung" descr False} |]
|
(Just descr) -> cell [whamlet|
|
||||||
|
$newline never
|
||||||
|
<span style="float:right">
|
||||||
|
^{modal "Beschreibung" (Right $ toWidget descr)}
|
||||||
|
|]
|
||||||
|
|
||||||
sheetCell :: IsDBTable m a => CourseLink -> SheetName -> DBCell m a
|
sheetCell :: IsDBTable m a => CourseLink -> SheetName -> DBCell m a
|
||||||
sheetCell crse shn =
|
sheetCell crse shn =
|
||||||
|
|||||||
@ -2,26 +2,19 @@
|
|||||||
|
|
||||||
module Handler.Utils.Templates where
|
module Handler.Utils.Templates where
|
||||||
|
|
||||||
|
import Data.Either (isLeft)
|
||||||
|
|
||||||
import Import.NoFoundation
|
import Import.NoFoundation
|
||||||
|
|
||||||
lipsum :: WidgetT site IO ()
|
lipsum :: WidgetT site IO ()
|
||||||
lipsum = $(widgetFile "widgets/lipsum")
|
lipsum = $(widgetFile "widgets/lipsum")
|
||||||
|
|
||||||
modalStatic :: Html -> Html -> Bool -> WidgetT site IO ()
|
modal :: WidgetT site IO () -> Either (Route site) (WidgetT site IO ()) -> WidgetT site IO ()
|
||||||
modalStatic modalTrigger modalContent modalDynamic = do
|
modal modalTrigger modalContent = do
|
||||||
modalId <- newIdent
|
let modalDynamic = isLeft modalContent
|
||||||
triggerId <- newIdent
|
|
||||||
$(widgetFile "widgets/modalStatic")
|
|
||||||
[whamlet|<div ##{triggerId}>#{modalTrigger}|] -- TODO: modalDynamic
|
|
||||||
|
|
||||||
modalWidget :: Html -> WidgetT site IO () -> Bool -> WidgetT site IO ()
|
|
||||||
modalWidget modalTrigger modalContent modalDynamic = do
|
|
||||||
modalId <- newIdent
|
modalId <- newIdent
|
||||||
triggerId <- newIdent
|
triggerId <- newIdent
|
||||||
$(widgetFile "widgets/modalWidget")
|
$(widgetFile "widgets/modalWidget")
|
||||||
[whamlet|<div .btn ##{triggerId}>#{modalTrigger}|]
|
case modalContent of
|
||||||
|
Left route -> [whamlet|<a .btn ##{triggerId} href=@{route}>^{modalTrigger}|]
|
||||||
modal :: Html -> [Char] -> Bool -> WidgetT site IO ()
|
Right content -> [whamlet|<div .btn ##{triggerId}>^{modalTrigger}|]
|
||||||
modal triggerId modalContent modalDynamic = do
|
|
||||||
modalId <- newIdent
|
|
||||||
$(widgetFile "widgets/modal")
|
|
||||||
|
|||||||
@ -32,9 +32,5 @@
|
|||||||
^{btnWdgt}
|
^{btnWdgt}
|
||||||
<li><br>
|
<li><br>
|
||||||
Modals:
|
Modals:
|
||||||
^{modal "toggler1" "" True}
|
^{modal "Klick mich für Ajax-Test" (Left UsersR)}
|
||||||
<a href=@{UsersR} .btn #toggler1>Klick mich für Ajax-Test
|
^{modal "Klick mich für Content-Test" (Right "Test Inhalt für Modal")}
|
||||||
<noscript>(Für Modals bitte JS aktivieren)</noscript>
|
|
||||||
^{modal "toggler2" "Test Inhalt für Modal" False}
|
|
||||||
<div .btn #toggler2>Klick mich für Content-Test
|
|
||||||
<noscript>(Für Modals bitte JS aktivieren)</noscript>
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@
|
|||||||
.
|
.
|
||||||
|
|
||||||
<h2>
|
<h2>
|
||||||
^{modalWidget "Alle Benutzerbezogenen Daten löschen" delWdgt False}
|
^{modal "Alle Benutzerbezogenen Daten löschen" (Right delWdgt)}
|
||||||
<p>
|
<p>
|
||||||
<h4>Hinweise:
|
<h4>Hinweise:
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@ -1,2 +0,0 @@
|
|||||||
<div .modal.js-modal #modal-#{modalId} data-trigger=#{triggerId} data-closeable=true data-dynamic=#{modalDynamic}>
|
|
||||||
#{modalContent}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
<div .modal.js-modal #modal-#{modalId} data-trigger=#{triggerId} data-closeable=true data-dynamic=#{modalDynamic}>
|
|
||||||
#{modalContent}
|
|
||||||
@ -1,2 +1,5 @@
|
|||||||
<div .modal.js-modal #modal-#{modalId} data-trigger=#{triggerId} data-closeable=true data-dynamic=#{modalDynamic}>
|
<div .modal.js-modal #modal-#{modalId} data-trigger=#{triggerId} data-closeable=true data-dynamic=#{modalDynamic}>
|
||||||
^{modalContent}
|
$case modalContent
|
||||||
|
$of Right content
|
||||||
|
^{content}
|
||||||
|
$of Left _
|
||||||
|
|||||||
Reference in New Issue
Block a user