From ec318a209629232009e5c52309fe039b31477973 Mon Sep 17 00:00:00 2001 From: Gregor Billing Date: Fri, 3 Jan 2025 21:34:09 +0900 Subject: [PATCH] Make filters box collapsible in React competitions overview (#10461) * Make filters box collapsible * Move reset button into filter view * Move filter open/close action to floated button * Make ESLint happy * Make time filter buttons more compact * Turn year-gap into header in cell break lines --- .../CompetitionsFilters.js | 96 ++++--------------- .../CompetitionsOverview/CompetitionsView.js | 86 +++++++++++++---- .../CompetitionsOverview/ListViewSection.js | 4 +- config/locales/en.yml | 2 + 4 files changed, 95 insertions(+), 93 deletions(-) diff --git a/app/webpacker/components/CompetitionsOverview/CompetitionsFilters.js b/app/webpacker/components/CompetitionsOverview/CompetitionsFilters.js index 0350eede08..9145b98a90 100644 --- a/app/webpacker/components/CompetitionsOverview/CompetitionsFilters.js +++ b/app/webpacker/components/CompetitionsOverview/CompetitionsFilters.js @@ -16,10 +16,6 @@ import UtcDatePicker from '../wca/UtcDatePicker'; function CompetitionsFilters({ filterState, dispatchFilter, - displayMode, - setDisplayMode, - shouldShowRegStatus, - setShouldShowRegStatus, shouldShowAdminDetails, canViewAdminDetails, }) { @@ -53,18 +49,6 @@ function CompetitionsFilters({ - - - - {canViewAdminDetails && shouldShowAdminDetails && ( @@ -72,13 +56,6 @@ function CompetitionsFilters({ )} - - - - ); } @@ -263,48 +240,39 @@ function TimeOrderButtonGroup({ filterState, dispatchFilter }) { return ( <> - - + @@ -318,42 +286,39 @@ function AdminStatusButtonGroup({ filterState, dispatchFilter }) { return ( <> - + @@ -364,26 +329,24 @@ function AdminStatusButtonGroup({ filterState, dispatchFilter }) { function PastCompYearSelector({ filterState, dispatchFilter }) { return ( ); @@ -464,7 +425,7 @@ function CustomDateSelector({ filterState, dispatchFilter }) { ); } -function CompDisplayCheckboxes({ +export function CompDisplayCheckboxes({ shouldIncludeCancelled, dispatchFilter, shouldShowRegStatus, @@ -520,7 +481,7 @@ function CompDisplayCheckboxes({ ); } -function ToggleListOrMapDisplay({ displayMode, setDisplayMode }) { +export function ToggleListOrMapDisplay({ displayMode, setDisplayMode }) { return ( - ); -} - export default CompetitionsFilters; diff --git a/app/webpacker/components/CompetitionsOverview/CompetitionsView.js b/app/webpacker/components/CompetitionsOverview/CompetitionsView.js index 740dd16b4a..859df26b0c 100644 --- a/app/webpacker/components/CompetitionsOverview/CompetitionsView.js +++ b/app/webpacker/components/CompetitionsOverview/CompetitionsView.js @@ -2,13 +2,21 @@ import React, { useEffect, useMemo, useReducer, useState, } from 'react'; import { keepPreviousData, useInfiniteQuery, useQuery } from '@tanstack/react-query'; -import { Container, Header } from 'semantic-ui-react'; +import { + Button, + Container, + Form, + Header, + Icon, + Segment, + Transition, +} from 'semantic-ui-react'; import I18n from '../../lib/i18n'; import { apiV0Urls, WCA_API_PAGINATION } from '../../lib/requests/routes.js.erb'; import { fetchJsonOrError } from '../../lib/requests/fetchWithAuthenticityToken'; -import CompetitionsFilters, { ResetFilters } from './CompetitionsFilters'; +import CompetitionsFilters, { CompDisplayCheckboxes, ToggleListOrMapDisplay } from './CompetitionsFilters'; import ListView from './ListView'; import MapView from './MapView'; import { @@ -106,24 +114,70 @@ function CompetitionsView({ canViewAdminDetails = false }) { }) ) : baseCompetitions), [baseCompetitions, compRegistrationData, shouldShowRegStatus]); + const [showFilters, setShowFilters] = useState(true); + return (
+ {I18n.t('competitions.index.title')} -
- - - + + + + + + + +
+ + + + + + +
+ + { displayMode === 'list' && ( @@ -156,7 +210,7 @@ function CompetitionsView({ canViewAdminDetails = false }) { /> ) } -
+
); } diff --git a/app/webpacker/components/CompetitionsOverview/ListViewSection.js b/app/webpacker/components/CompetitionsOverview/ListViewSection.js index afab4b731a..0d1999cbe0 100644 --- a/app/webpacker/components/CompetitionsOverview/ListViewSection.js +++ b/app/webpacker/components/CompetitionsOverview/ListViewSection.js @@ -429,7 +429,9 @@ function ConditionalYearHeader({ ) { return ( - {startYear(competitions[index])} + +
{startYear(competitions[index])}
+
); } diff --git a/config/locales/en.yml b/config/locales/en.yml index fe2bca7cb9..507be0e9d7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1528,6 +1528,8 @@ en: danger: "Danger" from_date: "From" to_date: "To" + show_filters: "Show Filters" + hide_filters: "Hide Filters" reset_filters: "Reset Filters" #context: selecting a specific year ('year' is a number) past_from: "Past from %{year}"