From 5ff0cfcd0b8eda30c8de351ed5e0eb409821fa5d Mon Sep 17 00:00:00 2001 From: alnasir7 Date: Sun, 4 Apr 2021 11:01:48 -0400 Subject: [PATCH 1/5] add exclusive-view --- frontend/pages/index.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index d93b1ce95..194d448e0 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -257,21 +257,25 @@ const Splash = (props: SplashProps): ReactElement => { const [clubs, setClubs] = useState(props.clubs) const [isLoading, setLoading] = useState(false) const [searchInput, setSearchInput] = useState({}) + const [viewType, setViewType] = useState("general") const [display, setDisplay] = useState<'cards' | 'list'>('cards') useEffect((): void => { if (equal(searchInput, currentSearch.current)) { return } - currentSearch.current = { ...searchInput } - setLoading(true) const params = new URLSearchParams() params.set('format', 'json') params.set('page', '1') + if (SITE_ID === "fyh" ) { + //params.set('viewType', viewType) + } + + Object.entries(searchInput).forEach(([key, value]) => { params.set(key, value) }) @@ -513,6 +517,16 @@ const Splash = (props: SplashProps): ReactElement => { {' '} {clubs.count} result{clubs.count === 1 ? '' : 's'} + {SITE_ID === "fyh" && +
+ + +
+ } Date: Sun, 4 Apr 2021 11:53:22 -0400 Subject: [PATCH 2/5] Updated small styling and uncommented param --- frontend/pages/index.tsx | 46 ++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index 194d448e0..482d101f9 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -35,6 +35,7 @@ import { CLUBS_PURPLE, FOCUS_GRAY, H1_TEXT, + HUB_WHITE, SNOW, TAG_BACKGROUND_COLOR_MAP, TAG_TEXT_COLOR_MAP, @@ -257,7 +258,7 @@ const Splash = (props: SplashProps): ReactElement => { const [clubs, setClubs] = useState(props.clubs) const [isLoading, setLoading] = useState(false) const [searchInput, setSearchInput] = useState({}) - const [viewType, setViewType] = useState("general") + const [viewType, setViewType] = useState('general') const [display, setDisplay] = useState<'cards' | 'list'>('cards') useEffect((): void => { @@ -271,11 +272,10 @@ const Splash = (props: SplashProps): ReactElement => { params.set('format', 'json') params.set('page', '1') - if (SITE_ID === "fyh" ) { - //params.set('viewType', viewType) + if (SITE_ID === 'fyh') { + params.set('viewType', viewType) } - Object.entries(searchInput).forEach(([key, value]) => { params.set(key, value) }) @@ -517,16 +517,34 @@ const Splash = (props: SplashProps): ReactElement => { {' '} {clubs.count} result{clubs.count === 1 ? '' : 's'} - {SITE_ID === "fyh" && -
- - -
- } + {SITE_ID === 'fyh' && ( +
+ + +
+ )} Date: Sun, 4 Apr 2021 12:30:37 -0400 Subject: [PATCH 3/5] checkboxes --- frontend/pages/index.tsx | 57 +++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index 482d101f9..23d2fddd3 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -1,7 +1,13 @@ import { CLUB_RECRUITMENT_CYCLES } from 'components/ClubEditPage/ClubEditCard' import ListRenewalDialog from 'components/ClubPage/ListRenewalDialog' import LiveEventsDialog from 'components/ClubPage/LiveEventsDialog' -import { Icon, Metadata, Title, WideContainer } from 'components/common' +import { + Checkbox, + Icon, + Metadata, + Title, + WideContainer, +} from 'components/common' import DisplayButtons from 'components/DisplayButtons' import { FuseTag } from 'components/FilterSearch' import { ActionLink } from 'components/Header/Feedback' @@ -35,7 +41,6 @@ import { CLUBS_PURPLE, FOCUS_GRAY, H1_TEXT, - HUB_WHITE, SNOW, TAG_BACKGROUND_COLOR_MAP, TAG_TEXT_COLOR_MAP, @@ -259,10 +264,14 @@ const Splash = (props: SplashProps): ReactElement => { const [isLoading, setLoading] = useState(false) const [searchInput, setSearchInput] = useState({}) const [viewType, setViewType] = useState('general') + const [currentViewType, setCurrentViewType] = useState('general') const [display, setDisplay] = useState<'cards' | 'list'>('cards') useEffect((): void => { - if (equal(searchInput, currentSearch.current)) { + if ( + equal(searchInput, currentSearch.current) && + currentViewType === viewType + ) { return } currentSearch.current = { ...searchInput } @@ -274,6 +283,7 @@ const Splash = (props: SplashProps): ReactElement => { if (SITE_ID === 'fyh') { params.set('viewType', viewType) + setCurrentViewType(viewType) } Object.entries(searchInput).forEach(([key, value]) => { @@ -290,7 +300,11 @@ const Splash = (props: SplashProps): ReactElement => { setLoading(false) } }) - }, [searchInput]) + }, [searchInput, viewType]) + + const handleViewTypeChange = () => { + setViewType(viewType === 'general' ? 'exclusive' : 'general') + } const tagOptions = useMemo( () => @@ -519,30 +533,31 @@ const Splash = (props: SplashProps): ReactElement => { {SITE_ID === 'fyh' && (
- - + General View + +
)} From 30509d24199c62a9e9b7a5a421b472c29ce1db01 Mon Sep 17 00:00:00 2001 From: Yufei Xia Date: Sun, 4 Apr 2021 16:50:57 -0400 Subject: [PATCH 4/5] Exclusive view backend --- backend/clubs/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/clubs/views.py b/backend/clubs/views.py index c16f49457..fb9dd4632 100644 --- a/backend/clubs/views.py +++ b/backend/clubs/views.py @@ -325,7 +325,7 @@ def parse_many_to_many(label, field, value, operation, queryset): if tags[0].isdigit() or operation == "id": tags = [int(tag) for tag in tags if tag] - if settings.BRANDING == "fyh" and ( + if settings.BRANDING == "fyh" and request.GET.get("viewType", "") == "exclusive" and ( field == "target_years" or field == "student_types" or field == "target_schools" From 63b146956ecb6a1098c11d6dfc8d0f56eb24dadd Mon Sep 17 00:00:00 2001 From: Yufei Xia Date: Sun, 4 Apr 2021 16:51:31 -0400 Subject: [PATCH 5/5] style fix --- backend/clubs/views.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/clubs/views.py b/backend/clubs/views.py index fb9dd4632..7e6bb175f 100644 --- a/backend/clubs/views.py +++ b/backend/clubs/views.py @@ -325,10 +325,14 @@ def parse_many_to_many(label, field, value, operation, queryset): if tags[0].isdigit() or operation == "id": tags = [int(tag) for tag in tags if tag] - if settings.BRANDING == "fyh" and request.GET.get("viewType", "") == "exclusive" and ( - field == "target_years" - or field == "student_types" - or field == "target_schools" + if ( + settings.BRANDING == "fyh" + and request.GET.get("viewType", "") == "exclusive" + and ( + field == "target_years" + or field == "student_types" + or field == "target_schools" + ) ): queryset = queryset.annotate( num_tags=Count(f"{field}", distinct=True)