diff --git a/app/models/event.rb b/app/models/event.rb index 33a283e8a3c..c953cb5f394 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -77,17 +77,22 @@ def self.dump_static ) end + def blindfolded_event? + ['333bf', '444bf', '555bf', '333mbf', '333mbo'].include?(self.id) + end + alias_method :can_change_time_limit, :can_change_time_limit? alias_method :can_have_cutoff, :can_have_cutoff? alias_method :is_timed_event, :timed_event? alias_method :is_fewest_moves, :fewest_moves? alias_method :is_multiple_blindfolded, :multiple_blindfolded? alias_method :is_official, :official? + alias_method :is_blindfolded, :blindfolded_event? DEFAULT_SERIALIZE_OPTIONS = { only: ["id"], methods: ["name", "can_change_time_limit", "can_have_cutoff", "is_timed_event", - "is_fewest_moves", "is_multiple_blindfolded", "is_official", "format_ids"], + "is_fewest_moves", "is_multiple_blindfolded", "is_official", "format_ids","is_blindfolded"], }.freeze def serializable_hash(options = nil) diff --git a/app/webpacker/components/RegistrationsV2/Registrations/RegistrationList.jsx b/app/webpacker/components/RegistrationsV2/Registrations/RegistrationList.jsx index ec570b7b58f..4a60234fdc5 100644 --- a/app/webpacker/components/RegistrationsV2/Registrations/RegistrationList.jsx +++ b/app/webpacker/components/RegistrationsV2/Registrations/RegistrationList.jsx @@ -21,6 +21,7 @@ import { formatAttemptResult } from '../../../lib/wca-live/attempts'; import I18n from '../../../lib/i18n'; import { countries } from '../../../lib/wca-data.js.erb'; import { EventSelector } from '../../wca/EventSelector'; +import { events } from '../../../lib/wca-data.js.erb'; const sortReducer = createSortReducer(['name', 'country', 'total']); @@ -39,11 +40,15 @@ export default function RegistrationList({ competitionInfo }) { const changeSortColumn = (name) => sortDispatch({ type: 'CHANGE_SORT', sortColumn: name }); const [psychSheetEvent, setPsychSheetEvent] = useState(); - const [psychSheetSortBy, setPsychSheetSortBy] = useState('single'); + const [psychSheetSortBy, setPsychSheetSortBy] = useState(); const isPsychSheet = psychSheetEvent !== undefined const isAllCompetitors = !isPsychSheet const handleEventSelection = ({ type, eventId }) => { setPsychSheetEvent(type === 'toggle_event' ? eventId : undefined); + if (type === 'toggle_event' ) { + const sortBy = events.byId[eventId].isBlindfolded? 'single' : 'average'; + setPsychSheetSortBy(sortBy); + } }; const { isLoading: isLoadingPsychSheet, data: psychSheet } = useQuery({ diff --git a/lib/static_data/events.json b/lib/static_data/events.json index cbe0f79e817..e202c1cb472 100644 --- a/lib/static_data/events.json +++ b/lib/static_data/events.json @@ -12,7 +12,8 @@ "is_official": true, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "222", @@ -27,7 +28,8 @@ "is_official": true, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "444", @@ -42,7 +44,8 @@ "is_official": true, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "555", @@ -57,7 +60,8 @@ "is_official": true, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "666", @@ -72,7 +76,8 @@ "is_official": true, "format_ids": [ "m" - ] + ], + "is_blindfolded": false }, { "id": "777", @@ -87,7 +92,8 @@ "is_official": true, "format_ids": [ "m" - ] + ], + "is_blindfolded": false }, { "id": "333bf", @@ -102,7 +108,8 @@ "is_official": true, "format_ids": [ "3" - ] + ], + "is_blindfolded": true }, { "id": "333fm", @@ -119,7 +126,8 @@ "m", "2", "1" - ] + ], + "is_blindfolded": false }, { "id": "333oh", @@ -134,7 +142,8 @@ "is_official": true, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "clock", @@ -149,7 +158,8 @@ "is_official": true, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "minx", @@ -164,7 +174,8 @@ "is_official": true, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "pyram", @@ -179,7 +190,8 @@ "is_official": true, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "skewb", @@ -194,7 +206,8 @@ "is_official": true, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "sq1", @@ -209,7 +222,8 @@ "is_official": true, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "444bf", @@ -224,7 +238,8 @@ "is_official": true, "format_ids": [ "3" - ] + ], + "is_blindfolded": true }, { "id": "555bf", @@ -239,7 +254,8 @@ "is_official": true, "format_ids": [ "3" - ] + ], + "is_blindfolded": true }, { "id": "333mbf", @@ -256,7 +272,8 @@ "1", "2", "3" - ] + ], + "is_blindfolded": true }, { "id": "333ft", @@ -274,7 +291,8 @@ "3", "2", "1" - ] + ], + "is_blindfolded": false }, { "id": "magic", @@ -289,7 +307,8 @@ "is_official": false, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "mmagic", @@ -304,7 +323,8 @@ "is_official": false, "format_ids": [ "a" - ] + ], + "is_blindfolded": false }, { "id": "333mbo", @@ -321,6 +341,7 @@ "3", "2", "1" - ] + ], + "is_blindfolded": true } -] \ No newline at end of file +]