feat(course-teaser-filter): working filters for semester and institute
This commit is contained in:
parent
68b8d24681
commit
3b419b3366
@ -198,12 +198,13 @@ makeCourseTable whereClause colChoices psValidator = do
|
|||||||
| Set.null criterias -> E.val True :: E.SqlExpr (E.Value Bool)
|
| Set.null criterias -> E.val True :: E.SqlExpr (E.Value Bool)
|
||||||
| otherwise -> course E.^. CourseTerm `E.in_` E.valList (Set.toList criterias)
|
| otherwise -> course E.^. CourseTerm `E.in_` E.valList (Set.toList criterias)
|
||||||
)
|
)
|
||||||
-- , ( "school", FilterColumn $ \(_course `E.InnerJoin` school :: CourseTableExpr) criterias -> if
|
-- , ( "school", FilterColumn $ \(_course `E.InnerJoin` school :: CourseTableExpr) criterias -> if
|
||||||
-- | Set.null criterias -> E.val True :: E.SqlExpr (E.Value Bool)
|
-- | Set.null criterias -> E.val True :: E.SqlExpr (E.Value Bool)
|
||||||
-- | otherwise -> school E.^. SchoolName `E.in_` E.valList (Set.toList criterias)
|
-- | otherwise -> school E.^. SchoolName `E.in_` E.valList (Set.toList criterias)
|
||||||
-- )
|
-- )
|
||||||
, ( "school", FilterColumn $ \(_course `E.InnerJoin` school :: CourseTableExpr) ->
|
, ( "school", FilterColumn $ \(_course `E.InnerJoin` school :: CourseTableExpr) ->
|
||||||
emptyOrIn $ school E.^. SchoolName -- TODO: Refactor all?!
|
emptyOrIn $ school E.^. SchoolId -- TODO: Refactor all?!
|
||||||
|
-- mkExactFilter $ $(sqlIJProj 2 2) >>> (E.^. SchoolId)
|
||||||
)
|
)
|
||||||
, ( "schoolshort", FilterColumn $ \(_course `E.InnerJoin` school :: CourseTableExpr) criterias -> if
|
, ( "schoolshort", FilterColumn $ \(_course `E.InnerJoin` school :: CourseTableExpr) criterias -> if
|
||||||
| Set.null criterias -> E.val True :: E.SqlExpr (E.Value Bool)
|
| Set.null criterias -> E.val True :: E.SqlExpr (E.Value Bool)
|
||||||
@ -221,7 +222,9 @@ makeCourseTable whereClause colChoices psValidator = do
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
, dbtFilterUI = \mPrev -> mconcat $ catMaybes
|
, dbtFilterUI = \mPrev -> mconcat $ catMaybes
|
||||||
[ Just $ prismAForm (singletonFilter "search") mPrev $ aopt textField (fslI MsgCourseFilterSearch)
|
[ Just $ prismAForm (singletonFilter "term" . maybePrism _PathPiece) mPrev $ aopt (hoistField lift termField) (fslI MsgTerm)
|
||||||
|
, Just $ prismAForm (singletonFilter "schoolshort" . maybePrism (_PathPiece . from _SchoolId)) mPrev $ aopt (hoistField lift schoolField) (fslI MsgCourseSchool)
|
||||||
|
, Just $ prismAForm (singletonFilter "search") mPrev $ aopt textField (fslI MsgCourseFilterSearch)
|
||||||
, muid $> prismAForm (singletonFilter "registered" . maybePrism _PathPiece) mPrev (aopt boolField (fslI MsgCourseFilterRegistered))
|
, muid $> prismAForm (singletonFilter "registered" . maybePrism _PathPiece) mPrev (aopt boolField (fslI MsgCourseFilterRegistered))
|
||||||
]
|
]
|
||||||
, dbtStyle = def
|
, dbtStyle = def
|
||||||
|
|||||||
@ -287,6 +287,9 @@ termsAllowedField = selectField $ do
|
|||||||
| otherwise = [TermActive ==. True]
|
| otherwise = [TermActive ==. True]
|
||||||
optionsPersistKey termFilter [Desc TermStart] termName
|
optionsPersistKey termFilter [Desc TermStart] termName
|
||||||
|
|
||||||
|
termField :: Field Handler TermId
|
||||||
|
termField = selectField $ optionsPersistKey [] [Asc TermName] termName
|
||||||
|
|
||||||
termsSetField :: [TermId] -> Field Handler TermId
|
termsSetField :: [TermId] -> Field Handler TermId
|
||||||
termsSetField tids = selectField $ optionsPersistKey [TermName <-. (unTermKey <$> tids)] [Desc TermStart] termName
|
termsSetField tids = selectField $ optionsPersistKey [TermName <-. (unTermKey <$> tids)] [Desc TermStart] termName
|
||||||
-- termsSetField tids = selectFieldList [(unTermKey t, t)| t <- tids ]
|
-- termsSetField tids = selectFieldList [(unTermKey t, t)| t <- tids ]
|
||||||
|
|||||||
@ -35,6 +35,9 @@ _InnerJoinRight f (E.InnerJoin l r) = (l `E.InnerJoin`) <$> f r
|
|||||||
_nullable :: MonoFoldable mono => Prism' mono (NonNull mono)
|
_nullable :: MonoFoldable mono => Prism' mono (NonNull mono)
|
||||||
_nullable = prism' toNullable fromNullable
|
_nullable = prism' toNullable fromNullable
|
||||||
|
|
||||||
|
_SchoolId :: Iso' SchoolId SchoolShorthand
|
||||||
|
_SchoolId = iso unSchoolKey SchoolKey
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
-- Lens Definitions for our Types
|
-- Lens Definitions for our Types
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user