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

Update feet rank and UI #5099

Merged
merged 1 commit into from Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions WcaOnRails/app/javascript/edit-events/index.jsx
Expand Up @@ -13,9 +13,17 @@ export function rootRender() {
}

function normalizeWcifEvents(wcifEvents) {
return events.official.map(event => {
return _.find(wcifEvents, { id: event.id }) || { id: event.id, rounds: null };
// Since we want to support deprecated events and be able to edit their rounds,
// we want to show deprecated events if they exist in the WCIF, but not if they
// don't.
// Therefore we first build the list of events from the official one, updating
// it with WCIF data if any.
// And then we add all events that are still in the WCIF (which means they are
// not official anymore).
let ret = events.official.map(event => {
return _.remove(wcifEvents, { id: event.id })[0] || { id: event.id, rounds: null };
});
return ret.concat(wcifEvents);
}

wca.initializeEventsForm = (competitionId, canAddAndRemoveEvents, wcifEvents) => {
Expand Down
24 changes: 10 additions & 14 deletions WcaOnRails/app/views/competitions/edit_events.html.erb
Expand Up @@ -2,18 +2,14 @@
<%= javascript_pack_tag 'edit_events' %>

<%= render layout: 'nav' do %>
<% if @competition.events.deprecated.count > 0 %>
<%= t('competitions.competition_form.deprecated_events') %>
<% else %>
<div id="events-edit-area"></div>
<script>
$(function() {
wca.initializeEventsForm(
<%= @competition.id.to_json.html_safe %>,
<%= current_user.can_add_and_remove_events?(@competition).to_json.html_safe %>,
<%= @competition.events_wcif.to_json.html_safe %>
);
});
</script>
<% end %>
<div id="events-edit-area"></div>
<script>
$(function() {
wca.initializeEventsForm(
<%= @competition.id.to_json.html_safe %>,
<%= current_user.can_add_and_remove_events?(@competition).to_json.html_safe %>,
<%= @competition.events_wcif.to_json.html_safe %>
);
});
</script>
<% end %>
1 change: 0 additions & 1 deletion WcaOnRails/config/locales/en.yml
Expand Up @@ -1298,7 +1298,6 @@ en:
venue_details_html: "Details about the venue (e.g., On the first floor far in the back, follow the signs). %{md}"
contact_html: "Optional contact information. If you do not fill this in, organizer emails will be shown to the public. %{md}. Example: [Text to display](mailto:some@email.com)"
events: "Events"
deprecated_events: "This competition has events that are no longer official, we do not support editing them."
public_and_locked_html: "This competition is publicly visible and locked for editing. If you need to make a change, please reply to the email thread where the competition was confirmed."
confirmed_but_not_visible_html: "You've confirmed this competition, but it is not yet visible to the public. Wait for the %{contact} to make it visible."
is_visible: "This competition is publicly visible, any changes you make will show up to the public!"
Expand Down
9 changes: 9 additions & 0 deletions WcaOnRails/db/migrate/20200125180554_update_feet_rank.rb
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class UpdateFeetRank < ActiveRecord::Migration[5.2]
def change
# This change goes along updating the feet's rank in the seeds file.
Event.delete_all
load "#{Rails.root}/db/seeds/events.seeds.rb"
end
end
2 changes: 1 addition & 1 deletion WcaOnRails/db/seeds/events.seeds.rb
Expand Up @@ -10,7 +10,6 @@
('333bf', '3x3x3 Blindfolded', 70, 'time', '3x3x3 Blindfolded'),
('333fm', '3x3x3 Fewest Moves', 80, 'number', '3x3x3 Fewest Moves'),
('333oh', '3x3x3 One-Handed', 90, 'time', '3x3x3 One-Handed'),
('333ft', '3x3x3 With Feet', 100, 'time', '3x3x3 With Feet'),
('clock', 'Clock', 110, 'time', 'Clock'),
('minx', 'Megaminx', 120, 'time', 'Megaminx'),
('pyram', 'Pyraminx', 130, 'time', 'Pyraminx'),
Expand All @@ -19,6 +18,7 @@
('444bf', '4x4x4 Blindfolded', 160, 'time', '4x4x4 Blindfolded'),
('555bf', '5x5x5 Blindfolded', 170, 'time', '5x5x5 Blindfolded'),
('333mbf', '3x3x3 Multi-Blind', 180, 'multi', '3x3x3 Multi-Blind'),
('333ft', '3x3x3 With Feet', 996, 'time', '3x3x3 With Feet'),
('magic', 'Magic', 997, 'time', 'Magic'),
('mmagic', 'Master Magic', 998, 'time', 'Master Magic'),
('333mbo', '3x3x3 Multi-Blind Old Style', 999, 'multi', '3x3x3 Multi-Blind Old Style');"
Expand Down
3 changes: 2 additions & 1 deletion WcaOnRails/db/structure.sql
Expand Up @@ -1625,4 +1625,5 @@ INSERT INTO `schema_migrations` (version) VALUES
('20190916133253'),
('20191005203556'),
('20191013211511'),
('20191107212356');
('20191107212356'),
('20200125180554');