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 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 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
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
28 changes: 0 additions & 28 deletions app/assets/javascripts/competition_tabs.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
onPage("competitions#show", function() {
showTabFromHash();

$('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
window.location.hash = $(e.target).attr('href');
});

// Update the displayed tab when the back/forward is clicked changing the hash.
$(window).on('hashchange', showTabFromHash);

function showTabFromHash() {
var id = window.location.hash || '#general-info';
$('a[href="' + id + '"]').tab('show');
$(id).find("iframe").each(function () {
$iframe = $(this);
if ($iframe.attr("src") === undefined) {
$iframe.attr("src", $iframe.data("src"));
}
});
// The FullCalendar implementation that lives inside React (rendered client-side!)
// does not go well with the Bootstrap Tabs that are rendered server-side :(
// So we "fake" a resize fo React FullCalendar to compute its own dimensions correctly.
if (id === '#competition-schedule') {
window.dispatchEvent(new Event('resize'));
}
}
});

onPage("competition_tabs#index", function() {
$('.reorder-up').on('click', function() {
var $thisRow = $(this).closest('tr');
Expand Down
21 changes: 21 additions & 0 deletions app/models/competition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,23 @@ def to_wcif(authorized: false)
}
end

def to_competition_overview_info(include_results: true)
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
competition_series] }
options[:methods].append("winning_results") if include_results
self.as_json(options)
end

def to_competition_info
options = {
only: %w[id name website start_date registration_open registration_close announced_at cancelled_at end_date competitor_limit
Expand Down Expand Up @@ -2238,6 +2255,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
246 changes: 0 additions & 246 deletions app/views/competitions/_competition_info.html.erb

This file was deleted.

6 changes: 0 additions & 6 deletions app/views/competitions/_competition_schedule_tab.html.erb

This file was deleted.

4 changes: 0 additions & 4 deletions app/views/competitions/_events_tab.html.erb

This file was deleted.

52 changes: 1 addition & 51 deletions app/views/competitions/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,7 @@
<div id="competition-data">
<h3>
<% if current_user && @competition.upcoming? %>
<span class="bookmark-icon" id="not-bookmarked" data-toggle="tooltip" data-placement="bottom" title="<%= I18n.t('competitions.competition_info.bookmark') %>" <% if current_user.is_bookmarked?(@competition) %>style="display: none;"<% end %>>
<%= ui_icon('bookmark') %>
</span>
<span class="bookmark-icon" id="bookmarked" data-toggle="tooltip" data-placement="bottom" title="<%= I18n.t('competitions.competition_info.is_bookmarked') %>" <% if !current_user.is_bookmarked?(@competition) %>style="display: none;"<% end %>>
<%= ui_icon('bookmark') %>
</span>
<%= react_component("BookmarkIcon", { competitionIsBookmarked: current_user.is_bookmarked?(@competition), competitionId: @competition.id }, { style: "display: inline" }) %>
<% end %>
<% if @competition.championships.any? %>
<span class="championship-trophy" data-toggle="tooltip" data-placement="bottom" title="<%= @competition.championships.sort.map { |championship| championship.name }.join(", ") %>">
Expand Down Expand Up @@ -280,48 +275,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>
Loading
Loading