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

Migrate Competition Overview Page to React #10418

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
43b53b0
Move Schedule and Event Tab to Tab Folder
FinnIckler Dec 11, 2024
51fb886
create new tab component
FinnIckler Dec 11, 2024
c0b81d1
use tab component in old erb template
FinnIckler Dec 11, 2024
cab1a19
registration requirements wip
FinnIckler Dec 11, 2024
f3ce4bb
needed competition attributes
FinnIckler Dec 11, 2024
119e063
move markdown.jsx to use fetch
FinnIckler Dec 12, 2024
ea94b2d
correctly display organizers and delegates
FinnIckler Dec 12, 2024
24a06fe
more registration requirements
FinnIckler Dec 12, 2024
077ebe7
move all registration requirements over
FinnIckler Dec 12, 2024
0c4caa6
move some registration requirements out of the component to avoid nes…
FinnIckler Dec 12, 2024
7b3db49
move to grid
FinnIckler Dec 12, 2024
39d63be
use a grid to build generalinfo
FinnIckler Dec 12, 2024
3c2f74e
move the rest to grid
FinnIckler Dec 12, 2024
baa7a71
implement setting active index by slug
FinnIckler Dec 13, 2024
956bed7
add TimeLimitCutoffInfo.jsx
FinnIckler Dec 13, 2024
ab51c84
add highlights
FinnIckler Dec 13, 2024
eae6e3d
implement media
FinnIckler Dec 16, 2024
fb1d4b4
add Winners table
FinnIckler Dec 16, 2024
70b7999
refactor and add mobile view
FinnIckler Dec 16, 2024
0b104a5
don't render media accordion if no media was supplied
FinnIckler Dec 17, 2024
6a8ba43
make Tab Title orange
FinnIckler Dec 17, 2024
f19bb6f
remove all <br>s by using List
FinnIckler Dec 17, 2024
274a5f6
make events hoverable
FinnIckler Dec 17, 2024
2143b9b
fix listing of Sibling Competitions
FinnIckler Dec 17, 2024
a8b0740
sort organizer and delegated correctly
FinnIckler Dec 17, 2024
2fdac4c
remove another br
FinnIckler Dec 17, 2024
9ec1300
delete now unused files and reuse components on other pages
FinnIckler Dec 17, 2024
6dbb5f2
add a seperate to_competition_overview_info method
FinnIckler Dec 17, 2024
0b31623
run rubocop
FinnIckler Dec 17, 2024
78b7b8d
fix tests
FinnIckler Dec 17, 2024
dfba267
migrate bookmark loading spinner to react
FinnIckler Dec 18, 2024
be5ef38
remove competition#show jquery
FinnIckler Dec 18, 2024
cffd70e
add popup i18n strings to bookmark
FinnIckler Dec 18, 2024
d985bb6
disable clicking on bookmark icon while it's fetching
FinnIckler Dec 19, 2024
0d19eb0
use three ifs in GuestRequirements
FinnIckler Dec 19, 2024
514dec6
Make general info grid stackable
gregorbg Jan 2, 2025
4f41105
Remove border around 'Schedule' and 'Events' tabs
gregorbg Jan 2, 2025
19eda8f
Add lodash import
gregorbg Jan 2, 2025
f8c1b35
Merge branch 'main' into react/tabs
gregorbg Jan 5, 2025
8ac1ba4
Refactor information grid to stylable list
gregorbg Jan 5, 2025
1fea0a9
Remove padding hack (and just bear the gaps)
gregorbg Jan 5, 2025
bbeac57
Merge information grid and grid entry file
gregorbg Jan 5, 2025
8704420
Get rid of stylesheet
gregorbg Jan 5, 2025
3ca288a
Use SemUI List-based information design
gregorbg Jan 5, 2025
37c208e
Provide (somewhat arbitrary) icons for DateAddressContact list
gregorbg Jan 5, 2025
75cee7d
Merge main event into events list
gregorbg Jan 5, 2025
e54730d
only show certain entries conditionally
FinnIckler Jan 6, 2025
9aeeccb
only show certain entries conditionally for the other column
FinnIckler Jan 6, 2025
2d49686
only show certain entries conditionally for the bottom items
FinnIckler Jan 6, 2025
69dfd4b
add main Event string to main event icon
FinnIckler Jan 6, 2025
5c9e98f
DateAddressContact review changes
FinnIckler Jan 7, 2025
be7b08e
Move Bookmarks, competitor limits and registrations to statistic group
FinnIckler Jan 7, 2025
480e607
don't show seconds in registration time
FinnIckler Jan 7, 2025
fe21c03
move Hide Requirements buttons to the top
FinnIckler Jan 7, 2025
eefa92f
review changes for registration requirements
FinnIckler Jan 7, 2025
7c28e14
fix results by event not rendering
FinnIckler Jan 7, 2025
22f5847
Merge branch 'main' into react/tabs
FinnIckler Jan 8, 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
4 changes: 4 additions & 0 deletions app/models/competition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,10 @@ def serializable_hash(options = nil)
)
end

def competitor_count
competitors.count
end

def to_ics
cal = Icalendar::Calendar.new
wcif_ids = rounds.to_h { |r| [r.wcif_id, r.to_string_map] }
Expand Down
45 changes: 0 additions & 45 deletions app/views/competitions/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -280,48 +280,3 @@
</div>
</div>
</div>

<script>
(function() {
var $nav = $('#competition-nav > .list-group');
$nav.affix({
offset: {
top: function() {
var parentTop = $nav.parent().offset().top;
var affixTopSpacing = 20; // From .bs-affix in wca.scss
return parentTop - affixTopSpacing;
},
bottom: function () {
return (this.bottom = $('.footer').outerHeight(true));
},
},
});

$('#not-bookmarked').click(function() {
window.wca.cancelPendingAjaxAndAjax('bookmark', {
url: '<%= bookmark_path %>',
method: 'POST',
data: {
'id': <%= @competition.id.to_json.html_safe %>,
},
success: function(data) {
$('#not-bookmarked').toggle();
$('#bookmarked').toggle();
}
});
});
$('#bookmarked').click(function() {
window.wca.cancelPendingAjaxAndAjax('bookmark', {
url: '<%= unbookmark_path %>',
method: 'POST',
data: {
'id': <%= @competition.id.to_json.html_safe %>,
},
success: function(data) {
$('#not-bookmarked').toggle();
$('#bookmarked').toggle();
}
});
});
})();
</script>
66 changes: 24 additions & 42 deletions app/views/competitions/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,45 +1,27 @@
<% provide(:title, @competition.display_name) %>
<%# We use this to hide the 'Events' information for competition which didn't declared rounds %>
<% options = { methods: %w[city has_event_change_deadline_date? allow_registration_edits? event_change_deadline_date
refund_policy_percent refund_policy_limit_date currency_code waiting_list_deadline_date organizers delegates
base_entry_fee_lowest_denomination registration_open registration_close extra_registration_requirements has_fees?
competition_events base_entry_fee using_payment_integrations? series_sibling_competitions main_event_id has_rounds?
external_registration_page part_of_competition_series? contact use_wca_registration is_probably_over?
registration_not_yet_opened? registration_past? competitor_limit competitor_limit_enabled venue_details
external_website venue_address latitude_degrees longitude_degrees website has_schedule? country_iso2 events
media number_of_bookmarks date_range information on_the_spot_registration? on_the_spot_entry_fee_lowest_denomination
guests_per_registration_limit_enabled? guests_per_registration_limit uses_qualification? allow_registration_without_qualification
events_per_registration_limit_enabled? events_per_registration_limit guests_entry_fee_lowest_denomination all_guests_allowed?
uses_cumulative? uses_cumulative_across_rounds? uses_cutoff? uses_qualification? results_posted? competitor_count]} %>
<%= render layout: 'nav' do %>
<ul class="nav nav-tabs">
<li><a href="#general-info" data-toggle="tab"><%=t 'competitions.show.general_info' %></a></li>
<% if @competition.has_rounds? %>
<li><a href="#competition-events" data-toggle="tab"><%=t 'competitions.show.events' %></a></li>
<% end %>
<% if @competition.has_schedule? %>
<li><a href="#competition-schedule" data-toggle="tab"><%=t 'competitions.show.schedule' %></a></li>
<% end %>
<% @competition.tabs.each do |tab| %>
<li><a href="#<%= tab.slug %>" data-toggle="tab"><%= tab.name %></a></li>
<% end %>
</ul>

<div class="tab-content" id="competition-tabs">
<div class="tab-pane" id="general-info">
<%= render layout: 'results_nav', locals: { layout_nav: false } do %>
<%= render "results_table", results: @competition.winning_results, hide_pos: true, hide_round: true %>
<% end %>
</div>
<% if @competition.has_rounds? %>
<div class="tab-pane" id="competition-events">
<%= render "events_tab" %>
</div>
<% end %>
<% if @competition.has_schedule? %>
<div class="tab-pane" id="competition-schedule">
<%= render "competition_schedule_tab", competition: @competition %>
</div>
<% end %>
<% @competition.tabs.each do |tab| %>
<div class="tab-pane" id="<%= tab.slug %>">
<%=md tab.content %>
<% if current_user&.can_manage_competition?(@competition) %>
<%= link_to edit_competition_tab_path(@competition, tab), class: "btn btn-primary" do %>
<%= ui_icon("edit") %> Edit
<% end %>
<% end %>
</div>
<% end %>
<%= render "time_limit_cutoff_format_info", competition: @competition %>
</div>
<%= react_component("CompetitionTabs", {
tabs: @competition.tabs.as_json,
competition: @competition.as_json(options),
wcifEvents: @competition.events_wcif, wcifSchedule: @competition.schedule_wcif, locale: I18n.locale,
userInfo: current_user.as_json({
only: %w[wca_id unconfirmed_wca_id],
methods: [],
include: [],
}),
winners: winners(@competition, @competition.main_event),
records: records(@competition),
media: @competition.media.accepted
}) %>
<% end %>
18 changes: 18 additions & 0 deletions app/webpacker/components/CompetitionTabs/CompetitionTab.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { Icon, TabPane } from 'semantic-ui-react';
import Markdown from '../Markdown';
import { editCompetitionTabUrl } from '../../lib/requests/routes.js.erb';

export default function CompetitionTab({ tab, canManage, competition }) {
return (
<TabPane>
<Markdown md={tab.content} id={tab.id} />
{ canManage && (
<a href={editCompetitionTabUrl(competition.id, tab.id)}>
<Icon name="edit" />
Edit
</a>
)}
</TabPane>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import {
TableHeaderCell,
TableRow,
} from 'semantic-ui-react';
import I18n from '../../lib/i18n';
import { events, formats } from '../../lib/wca-data.js.erb';
import I18n from '../../../lib/i18n';
import { events, formats } from '../../../lib/wca-data.js.erb';
import {
advancementConditionToString,
cutoffToString,
eventQualificationToString,
getRoundTypeId,
timeLimitToString,
} from '../../lib/utils/wcif';
} from '../../../lib/utils/wcif';

export default function EventsTable({ competitionInfo, wcifEvents }) {
return (
Expand Down
Loading
Loading