diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index afdd35037..7e4ffb532 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -198,12 +198,13 @@ makeCourseTable whereClause colChoices psValidator = do | Set.null criterias -> E.val True :: E.SqlExpr (E.Value Bool) | otherwise -> course E.^. CourseTerm `E.in_` E.valList (Set.toList criterias) ) --- , ( "school", FilterColumn $ \(_course `E.InnerJoin` school :: CourseTableExpr) criterias -> if --- | Set.null criterias -> E.val True :: E.SqlExpr (E.Value Bool) --- | otherwise -> school E.^. SchoolName `E.in_` E.valList (Set.toList criterias) --- ) + -- , ( "school", FilterColumn $ \(_course `E.InnerJoin` school :: CourseTableExpr) criterias -> if + -- | Set.null criterias -> E.val True :: E.SqlExpr (E.Value Bool) + -- | otherwise -> school E.^. SchoolName `E.in_` E.valList (Set.toList criterias) + -- ) , ( "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 | Set.null criterias -> E.val True :: E.SqlExpr (E.Value Bool) @@ -221,7 +222,9 @@ makeCourseTable whereClause colChoices psValidator = do ) ] , 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)) ] , dbtStyle = def diff --git a/src/Handler/Utils/Form.hs b/src/Handler/Utils/Form.hs index b7548543c..852bc1aa5 100644 --- a/src/Handler/Utils/Form.hs +++ b/src/Handler/Utils/Form.hs @@ -287,6 +287,9 @@ termsAllowedField = selectField $ do | otherwise = [TermActive ==. True] optionsPersistKey termFilter [Desc TermStart] termName +termField :: Field Handler TermId +termField = selectField $ optionsPersistKey [] [Asc TermName] termName + termsSetField :: [TermId] -> Field Handler TermId termsSetField tids = selectField $ optionsPersistKey [TermName <-. (unTermKey <$> tids)] [Desc TermStart] termName -- termsSetField tids = selectFieldList [(unTermKey t, t)| t <- tids ] diff --git a/src/Utils/Lens.hs b/src/Utils/Lens.hs index 9388bea0b..1c011ce2c 100644 --- a/src/Utils/Lens.hs +++ b/src/Utils/Lens.hs @@ -35,6 +35,9 @@ _InnerJoinRight f (E.InnerJoin l r) = (l `E.InnerJoin`) <$> f r _nullable :: MonoFoldable mono => Prism' mono (NonNull mono) _nullable = prism' toNullable fromNullable +_SchoolId :: Iso' SchoolId SchoolShorthand +_SchoolId = iso unSchoolKey SchoolKey + ----------------------------------- -- Lens Definitions for our Types