Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split out editing venues from editing schedule #10028

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b5390c3
Duplicate "Manage Schedule" tab as "Manage Venues"
kr-matthews Aug 21, 2024
2e8c982
Duplicate EditSchedule forlder as EditVenues
kr-matthews Oct 4, 2024
d5cbc91
Add missing referenceTime
kr-matthews Oct 4, 2024
2a16a61
Use new (copied) EditVenues component in new tab
kr-matthews Oct 4, 2024
e5854ac
Remove schedule-related things from new EditVenues
kr-matthews Oct 4, 2024
c0a075a
Remove unused EditActivities folder in EditVenues
kr-matthews Oct 4, 2024
ec4f55f
Remove schedule actions from venues files
kr-matthews Oct 4, 2024
1b2ea1e
Remove unused utils from venues
kr-matthews Oct 4, 2024
2ba5e1d
Update text
kr-matthews Oct 4, 2024
52ba83b
Remove EditVenues component from EditSchedule
kr-matthews Oct 4, 2024
78b605f
Delete EditVenues folder from EditSchedule folder
kr-matthews Oct 4, 2024
604fb6e
Remove venue actions from schedule reducer
kr-matthews Oct 4, 2024
f6a2bc9
Remove unused schedule utils
kr-matthews Oct 4, 2024
35dc828
Rename folders
kr-matthews Oct 4, 2024
21cf617
Remove id from EditVenues react_component
kr-matthews Oct 4, 2024
fda75f2
Remove id from EditSchedule react_component
kr-matthews Oct 4, 2024
4ca7687
Remove edit_schedule.scss
kr-matthews Oct 4, 2024
aff6d0d
Rename new component to EditVenues
kr-matthews Oct 4, 2024
66333fd
eslint
kr-matthews Oct 5, 2024
c647542
Rename RSpec.feature
kr-matthews Oct 5, 2024
ba28af6
Duplicate manage schedule spec for manage venues
kr-matthews Oct 5, 2024
2850f24
Remove venue tests from schedule spec
kr-matthews Oct 5, 2024
bdb801c
Remove schedule tests from venues spec
kr-matthews Oct 5, 2024
dbaac69
Remove clicking accord from tests
kr-matthews Oct 5, 2024
ce58489
Remove extra empty line
kr-matthews Oct 5, 2024
8f0a4f6
Rename components to match folder name
kr-matthews Oct 6, 2024
a2a4934
Fix url in manage venues spec
kr-matthews Oct 6, 2024
30ff76e
Merge branch 'main' into task/split-venues-from-schedule-in-ui
gregorbg Jan 13, 2025
d715d93
Add backend param to prevent schedule updates in WCIF patch
gregorbg Jan 13, 2025
66cf8c6
Pull through skip_schedule param in frontend
gregorbg Jan 13, 2025
2f8af24
Add another parameter for venue details
gregorbg Jan 13, 2025
a7e9a8d
Split PATCH URL config between EditVenues and EditSchedules
gregorbg Jan 13, 2025
c198c7b
Move patchOptions in frontend to avoid rerender
gregorbg Jan 14, 2025
b2b1d11
Fix 'undefined' parameter in WCIF patch
gregorbg Jan 14, 2025
676a364
Merge branch 'main'
kr-matthews Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
@import "server_status";
@import "static_pages";
@import "edit_events";
@import "edit_schedule";
@import "media";
@import "incidents";
@import "translations";
Expand Down
194 changes: 0 additions & 194 deletions app/assets/stylesheets/edit_schedule.scss

This file was deleted.

8 changes: 6 additions & 2 deletions app/controllers/api/v0/competitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,13 @@ def show_wcif_public
def update_wcif
competition = competition_from_params
require_can_manage!(competition)
wcif = params.permit!.to_h
skip_schedule = params[:skipSchedule]
skip_schedule = ActiveRecord::Type::Boolean.new.cast(skip_schedule)
skip_venue_details = params[:skipVenueDetails]
skip_venue_details = ActiveRecord::Type::Boolean.new.cast(skip_venue_details)
wcif = params.except("skipSchedule", "skipVenueDetails").permit!.to_h
wcif = wcif["_json"] || wcif
competition.set_wcif!(wcif, require_user!)
competition.set_wcif!(wcif, require_user!, skip_schedule: skip_schedule, skip_venue_details: skip_venue_details)
render json: {
status: "Successfully saved WCIF",
}
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/competitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CompetitionsController < ApplicationController
before_action -> { redirect_to_root_unless_user(:can_manage_competition?, competition_from_params) }, only: [
:edit,
:edit_events,
:edit_venues,
:edit_schedule,
:payment_integration_setup,
]
Expand Down Expand Up @@ -253,6 +254,10 @@ def edit_events
@competition = competition_from_params(includes: associations)
end

def edit_venues
@competition = competition_from_params(includes: [competition_events: { rounds: { competition_event: [:event] } }, competition_venues: { venue_rooms: { schedule_activities: [:child_activities] } }])
end

def edit_schedule
@competition = competition_from_params(includes: [competition_events: { rounds: { competition_event: [:event] } }, competition_venues: { venue_rooms: { schedule_activities: [:child_activities] } }])
end
Expand Down
8 changes: 4 additions & 4 deletions app/models/competition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1963,13 +1963,13 @@ def schedule_wcif
}
end

def set_wcif!(wcif, current_user)
def set_wcif!(wcif, current_user, skip_schedule: false, skip_venue_details: false)
JSON::Validator.validate!(Competition.wcif_json_schema, wcif)

ActiveRecord::Base.transaction do
set_wcif_series!(wcif["series"], current_user) if wcif["series"]
set_wcif_events!(wcif["events"], current_user) if wcif["events"]
set_wcif_schedule!(wcif["schedule"], current_user) if wcif["schedule"]
set_wcif_schedule!(wcif["schedule"], current_user, skip_schedule: skip_schedule, skip_venue_details: skip_venue_details) if wcif["schedule"]
update_persons_wcif!(wcif["persons"], current_user) if wcif["persons"]
WcifExtension.update_wcif_extensions!(self, wcif["extensions"]) if wcif["extensions"]
set_wcif_competitor_limit!(wcif["competitorLimit"], current_user) if wcif["competitorLimit"]
Expand Down Expand Up @@ -2134,7 +2134,7 @@ def update_persons_wcif!(wcif_persons, current_user)
Assignment.upsert_all(new_assignments) if new_assignments.any?
end

def set_wcif_schedule!(wcif_schedule, current_user)
def set_wcif_schedule!(wcif_schedule, current_user, skip_schedule: false, skip_venue_details: false)
if wcif_schedule["startDate"] != start_date.strftime("%F")
raise WcaExceptions::BadApiParameter.new("Wrong start date for competition")
elsif wcif_schedule["numberOfDays"] != number_of_days
Expand All @@ -2153,7 +2153,7 @@ def set_wcif_schedule!(wcif_schedule, current_user)
# using this find instead of ActiveRecord's find_or_create_by avoid several queries
# (despite having the association included :()
venue = competition_venues.find { |v| v.wcif_id == venue_wcif["id"] } || competition_venues.build
venue.load_wcif!(venue_wcif)
venue.load_wcif!(venue_wcif, skip_schedule: skip_schedule, skip_venue_details: skip_venue_details)
end
self.competition_venues = new_venues

Expand Down
6 changes: 3 additions & 3 deletions app/models/competition_venue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def country
Country.find_by_iso2(self.country_iso2)
end

def load_wcif!(wcif)
update!(CompetitionVenue.wcif_to_attributes(wcif))
def load_wcif!(wcif, skip_schedule: false, skip_venue_details: false)
update!(CompetitionVenue.wcif_to_attributes(wcif)) unless skip_venue_details
new_rooms = wcif["rooms"].map do |room_wcif|
room = venue_rooms.find { |r| r.wcif_id == room_wcif["id"] } || venue_rooms.build
room.load_wcif!(room_wcif)
room.load_wcif!(room_wcif, skip_schedule: skip_schedule, skip_venue_details: skip_venue_details)
end
self.venue_rooms = new_rooms
WcifExtension.update_wcif_extensions!(self, wcif["extensions"]) if wcif["extensions"]
Expand Down
14 changes: 8 additions & 6 deletions app/models/venue_room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ def self.wcif_json_schema
}
end

def load_wcif!(wcif)
update!(VenueRoom.wcif_to_attributes(wcif))
new_activities = wcif["activities"].map do |activity_wcif|
activity = schedule_activities.find { |a| a.wcif_id == activity_wcif["id"] } || schedule_activities.build
activity.load_wcif!(activity_wcif)
def load_wcif!(wcif, skip_schedule: false, skip_venue_details: false)
update!(VenueRoom.wcif_to_attributes(wcif)) unless skip_venue_details
unless skip_schedule
new_activities = wcif["activities"].map do |activity_wcif|
activity = schedule_activities.find { |a| a.wcif_id == activity_wcif["id"] } || schedule_activities.build
activity.load_wcif!(activity_wcif)
end
self.schedule_activities = new_activities
end
self.schedule_activities = new_activities
WcifExtension.update_wcif_extensions!(self, wcif["extensions"]) if wcif["extensions"]
self
end
Expand Down
1 change: 1 addition & 0 deletions app/views/competitions/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
children: [
{ text: t('.menu.orga_view'), path: edit_competition_path(@competition), icon: "lock" },
{ text: t('.menu.event_view'), path: edit_events_path(@competition), icon: "cubes" },
{ text: t('.menu.venue_view'), path: edit_venues_path(@competition), icon: "building" },
{ text: t('.menu.schedule_view'), path: edit_schedule_path(@competition), icon: "calendar" },
{ text: t('.menu.payment_view'), path: competition_payment_integration_setup_path(@competition), icon: "money bill alternate" },
] +
Expand Down
3 changes: 0 additions & 3 deletions app/views/competitions/edit_schedule.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
competitionId: @competition.id,
wcifEvents: @competition.events_wcif,
wcifSchedule: @competition.schedule_wcif,
countryZones: @competition.country_zones,
referenceTime: @competition.start_date.to_fs,
calendarLocale: I18n.locale,
}, {
id: 'edit-schedule-area'
}) %>
<% end %>
<% end %>
25 changes: 25 additions & 0 deletions app/views/competitions/edit_venues.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<% provide(:title, "Manage venue for #{@competition.name}") %>
<% add_to_packs("wca_maps") %>

<%= render layout: 'nav' do %>
<% if [email protected]_defined_dates? %>
<div class="alert alert-danger">
There is no start and/or end date assigned to this competition yet.
Before you can manage your venues, you have to add them
<%= link_to "here", edit_competition_path(@competition, anchor: "competition_start_date") %>.
</div>
<% elsif @competition.country.blank? %>
<div class="alert alert-danger">
There is no country assigned to this competition yet.
Before you can manage your venues, you have to add one
<%= link_to "here", edit_competition_path(@competition, anchor: "competition_countryId") %>.
</div>
<% else %>
<%= react_component("EditVenues", {
competitionId: @competition.id,
wcifSchedule: @competition.schedule_wcif,
countryZones: @competition.country_zones,
referenceTime: @competition.start_date.to_fs,
}) %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import ActionsHeader from './ActionsHeader';
import { getTimeZoneDropdownLabel } from '../../../lib/utils/timezone';
import { earliestTimeOfDayWithBuffer } from '../../../lib/utils/activities';

function EditActivities({
function ManageActivities({
wcifEvents,
referenceTime,
calendarLocale,
Expand Down Expand Up @@ -504,4 +504,4 @@ function EditActivities({
);
}

export default EditActivities;
export default ManageActivities;
Loading
Loading