feat(course-teaser): incomplete course teaser for course list
Unfinished version of the course teaser. TODO: define lens to access lecturer list for each course, fix js for displaying description
This commit is contained in:
parent
40f382d74c
commit
9a9792578d
6569
package-lock.json
generated
6569
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -52,7 +52,7 @@
|
|||||||
"@babel/plugin-proposal-class-properties": "^7.4.4",
|
"@babel/plugin-proposal-class-properties": "^7.4.4",
|
||||||
"@babel/plugin-proposal-decorators": "^7.4.4",
|
"@babel/plugin-proposal-decorators": "^7.4.4",
|
||||||
"@babel/preset-env": "^7.4.5",
|
"@babel/preset-env": "^7.4.5",
|
||||||
"@commitlint/cli": "^8.0.0",
|
"@commitlint/cli": "^8.1.0",
|
||||||
"@commitlint/config-conventional": "^8.0.0",
|
"@commitlint/config-conventional": "^8.0.0",
|
||||||
"autoprefixer": "^9.6.0",
|
"autoprefixer": "^9.6.0",
|
||||||
"babel-core": "^6.26.3",
|
"babel-core": "^6.26.3",
|
||||||
@ -88,6 +88,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"flatpickr": "^4.5.7",
|
"flatpickr": "^4.5.7",
|
||||||
"npm": "^6.9.2"
|
"npm": "^6.10.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import Handler.Utils.Delete
|
|||||||
import Handler.Utils.Database
|
import Handler.Utils.Database
|
||||||
import Handler.Utils.Table.Cells
|
import Handler.Utils.Table.Cells
|
||||||
import Handler.Utils.Table.Columns
|
import Handler.Utils.Table.Columns
|
||||||
|
import Handler.Utils.Table.Pagination (DBSTemplateMode(..))
|
||||||
import Handler.Utils.Invitations
|
import Handler.Utils.Invitations
|
||||||
import Database.Persist.Sql (deleteWhereCount)
|
import Database.Persist.Sql (deleteWhereCount)
|
||||||
import qualified Database.Esqueleto.Utils as E
|
import qualified Database.Esqueleto.Utils as E
|
||||||
@ -205,7 +206,8 @@ makeCourseTable whereClause colChoices psValidator = do
|
|||||||
, dbtStyle = def
|
, dbtStyle = def
|
||||||
{ dbsFilterLayout = defaultDBSFilterLayout
|
{ dbsFilterLayout = defaultDBSFilterLayout
|
||||||
-- DBSTCourse :: Lens' r (Entity Course) -> Traversal' r (Entity User) -> Lens' r Bool -> DBSTemplateMode r
|
-- DBSTCourse :: Lens' r (Entity Course) -> Traversal' r (Entity User) -> Lens' r Bool -> DBSTemplateMode r
|
||||||
-- , dbsCellTemplate = DBSTCourse undefined undefined undefined
|
, dbsCellTemplate = DBSTCourse (_dbrOutput . _1) ignored (_dbrOutput . _3)
|
||||||
|
-- ^ course lens ^ lecturers traversal ^ isRegistered lens
|
||||||
}
|
}
|
||||||
, dbtParams = def
|
, dbtParams = def
|
||||||
, dbtIdent = "courses" :: Text
|
, dbtIdent = "courses" :: Text
|
||||||
|
|||||||
@ -31,6 +31,7 @@ module Handler.Utils.Table.Pagination
|
|||||||
, (&)
|
, (&)
|
||||||
, module Control.Monad.Trans.Maybe
|
, module Control.Monad.Trans.Maybe
|
||||||
, module Colonnade
|
, module Colonnade
|
||||||
|
, DBSTemplateMode(..)
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Handler.Utils.Table.Pagination.Types
|
import Handler.Utils.Table.Pagination.Types
|
||||||
@ -850,23 +851,15 @@ dbTable PSValidator{..} dbtable@DBTable{ dbtIdent = dbtIdent'@(toPathPiece -> db
|
|||||||
columnCount :: Int64
|
columnCount :: Int64
|
||||||
columnCount = olength64 $ getColonnade dbtColonnade
|
columnCount = olength64 $ getColonnade dbtColonnade
|
||||||
|
|
||||||
-- TODO: better name
|
wRows <- forM rows $ \row' -> let
|
||||||
htmlToCourseDescriptionText :: Maybe Html -> Html
|
|
||||||
htmlToCourseDescriptionText (Just html) = html
|
|
||||||
htmlToCourseDescriptionText Nothing = "No description available."
|
|
||||||
|
|
||||||
utcTimeToWidget :: Maybe UTCTime -> Widget
|
|
||||||
utcTimeToWidget (Just t) = formatTimeW SelFormatDateTime t
|
|
||||||
utcTimeToWidget Nothing = mempty -- TODO: Fallunterscheidung in hamlet (andere Darstellung)
|
|
||||||
wRows <- forM rows $ \row' -> forM (oneColonnadeEncode <$> getColonnade dbtColonnade) $ \(($ row') -> _cell') -> let
|
|
||||||
Course{..} = row' ^. c . _entityVal
|
Course{..} = row' ^. c . _entityVal
|
||||||
lecturers = toListOf l row'
|
lecturers = toListOf l row'
|
||||||
courseLecturers = intercalate ", " $ userSurname . entityVal <$> lecturers
|
courseLecturers = intercalate ", " $ userSurname . entityVal <$> lecturers
|
||||||
isRegistered = row' ^. r
|
isRegistered = row' ^. r
|
||||||
courseSchoolName = unSchoolKey courseSchool
|
courseSchoolName = unSchoolKey courseSchool
|
||||||
in return $(widgetFile "table/cell/course-teaser")
|
in return $(widgetFile "table/course/course-teaser")
|
||||||
|
|
||||||
return $(widgetFile "table/colonnade-course")
|
return $(widgetFile "table/course/colonnade")
|
||||||
DBSTDefault -> do
|
DBSTDefault -> do
|
||||||
let
|
let
|
||||||
genHeaders SortableP{..} = forM (toSortable . oneColonnadeHead <$> getColonnade dbtColonnade) $ \Sortable{..} -> do
|
genHeaders SortableP{..} = forM (toSortable . oneColonnadeHead <$> getColonnade dbtColonnade) $ \Sortable{..} -> do
|
||||||
|
|||||||
@ -9,5 +9,4 @@ $newline never
|
|||||||
$else
|
$else
|
||||||
$forall row <- wRows
|
$forall row <- wRows
|
||||||
<tr .table__row>
|
<tr .table__row>
|
||||||
$forall widget <- row
|
^{row}
|
||||||
^{widget}
|
|
||||||
@ -7,7 +7,13 @@
|
|||||||
<div .course-teaser__lecturer-label>_{MsgLecturerFor}
|
<div .course-teaser__lecturer-label>_{MsgLecturerFor}
|
||||||
<div .course-teaser__lecturer-value>_{courseLecturers}
|
<div .course-teaser__lecturer-value>_{courseLecturers}
|
||||||
<div .course-teaser__duedate-label>_{MsgRegisterTo}
|
<div .course-teaser__duedate-label>_{MsgRegisterTo}
|
||||||
<div .course-teaser__duedate-value>^{utcTimeToWidget courseRegisterTo}
|
$maybe regTo <- courseRegisterTo
|
||||||
|
<div .course-teaser__duedate-value>^{formatTimeW SelFormatDateTime regTo}
|
||||||
|
$nothing
|
||||||
<div .course-teaser__school-label>_{MsgCourseSchool}
|
<div .course-teaser__school-label>_{MsgCourseSchool}
|
||||||
<div .course-teaser__school-value>_{courseSchoolName}
|
<div .course-teaser__school-value>_{courseSchoolName}
|
||||||
<div .course-teaser__description>#{htmlToCourseDescriptionText courseDescription}
|
<div .course-teaser__description>
|
||||||
|
$maybe desc <- courseDescription
|
||||||
|
#{desc}
|
||||||
|
$nothing
|
||||||
|
No description available.
|
||||||
Reference in New Issue
Block a user