From 90fcc724d7c60484cd504df8b3dc1ae62d27104c Mon Sep 17 00:00:00 2001 From: Gregor Billing Date: Tue, 13 Feb 2024 20:20:53 +0100 Subject: [PATCH] Cloning fixes in new competition form (#8910) * Add cloning check to frontend to filter out main event * Compute staff and organizer IDs in a more cloning-friendly way * Extra requirements are not required as per WCRP --- WcaOnRails/app/models/competition.rb | 6 +++--- .../app/views/competitions/_competition_form.html.erb | 1 + .../CompetitionForm/FormSections/EventRestrictions.js | 9 +++++++-- .../CompetitionForm/FormSections/RegistrationDetails.js | 2 +- WcaOnRails/config/locales/en.yml | 6 ++++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/WcaOnRails/app/models/competition.rb b/WcaOnRails/app/models/competition.rb index d1a69538d7..4ad0d7dd4c 100644 --- a/WcaOnRails/app/models/competition.rb +++ b/WcaOnRails/app/models/competition.rb @@ -2135,9 +2135,9 @@ def to_form_data "reason" => competitor_limit_reason, }, "staff" => { - "staffDelegateIds" => staff_delegates.pluck(:id), - "traineeDelegateIds" => trainee_delegates.pluck(:id), - "organizerIds" => organizers.pluck(:id), + "staffDelegateIds" => staff_delegates.to_a.pluck(:id), + "traineeDelegateIds" => trainee_delegates.to_a.pluck(:id), + "organizerIds" => organizers.to_a.pluck(:id), "contact" => contact, }, "championships" => championships.map(&:championship_type), diff --git a/WcaOnRails/app/views/competitions/_competition_form.html.erb b/WcaOnRails/app/views/competitions/_competition_form.html.erb index a76af2613d..b43a0bad3d 100644 --- a/WcaOnRails/app/views/competitions/_competition_form.html.erb +++ b/WcaOnRails/app/views/competitions/_competition_form.html.erb @@ -6,4 +6,5 @@ isAdminView: @competition_admin_view, isPersisted: @competition.persisted?, isSeriesPersisted: @competition.competition_series&.persisted? || false, + isCloning: @competition.being_cloned_from.present?, }) %> diff --git a/WcaOnRails/app/webpacker/components/CompetitionForm/FormSections/EventRestrictions.js b/WcaOnRails/app/webpacker/components/CompetitionForm/FormSections/EventRestrictions.js index 6f9fd9e27a..be15eac962 100644 --- a/WcaOnRails/app/webpacker/components/CompetitionForm/FormSections/EventRestrictions.js +++ b/WcaOnRails/app/webpacker/components/CompetitionForm/FormSections/EventRestrictions.js @@ -20,6 +20,7 @@ export default function EventRestrictions() { eventLimitation, }, }, + isCloning, storedEvents, } = useStore(); @@ -63,9 +64,13 @@ export default function EventRestrictions() { - - + {!isCloning && ( + <> + + + + )} ); } diff --git a/WcaOnRails/app/webpacker/components/CompetitionForm/FormSections/RegistrationDetails.js b/WcaOnRails/app/webpacker/components/CompetitionForm/FormSections/RegistrationDetails.js index 2fcdcf7935..ed22067e71 100644 --- a/WcaOnRails/app/webpacker/components/CompetitionForm/FormSections/RegistrationDetails.js +++ b/WcaOnRails/app/webpacker/components/CompetitionForm/FormSections/RegistrationDetails.js @@ -42,7 +42,7 @@ export default function RegistrationDetails() { - + ); diff --git a/WcaOnRails/config/locales/en.yml b/WcaOnRails/config/locales/en.yml index b047af0591..67cae8f7f7 100644 --- a/WcaOnRails/config/locales/en.yml +++ b/WcaOnRails/config/locales/en.yml @@ -1534,7 +1534,8 @@ en: per_registration_limit: "Events per registration limit" main_event_id: "Main event" remarks: "Remarks" - clone_tabs: "I would like to clone all tabs with additional information as well" + cloning: + clone_tabs: "I would like to clone all tabs with additional information as well" #context: for a competition hints: admin: @@ -1614,7 +1615,8 @@ en: per_registration_limit: "Optionally enforce the total number of events a competitor can register for (commonly used for \"Favorites\" competitions). You should add events before using this field. Registrations with too many events will be blocked. Leave blank if there is no limit." main_event_id: "The winner of this event will be the winner of the competition." remarks: "Some additional information you want to pass on to the WCAT. For example, if there is something you are uncertain about, or if there are any special requests for the WCAT. Please fill this out in English!" - clone_tabs: "" + cloning: + clone_tabs: "" choices: #context: about guests guests_enabled: