Skip to content

Commit d63b69a

Browse files
committed
Split tournaments into tournaments and seasons
1 parent 87a82ae commit d63b69a

File tree

5 files changed

+73
-42
lines changed

5 files changed

+73
-42
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ A preview of major changes can be found in the Wiki ([Latest Changes](https://gi
55
#### Feature
66
- Option to see `All` or `Unique` tournament statistics per player
77
- Ability to "Remote Start" matches on a selected venue
8+
- Split tournaments into "Tournaments" and "Seasons"
89

910
#### Changed
1011
- Updated to latest version of dependencies

src/components/navbar/components/configure-kcapp-modal/configure-kcapp-modal.component.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ module.exports = {
7474
this.state.venueId = parseInt(document.getElementById("venueSelect").value);
7575
if (this.state.venueId === -1) {
7676
localStorage.remove('venue_id');
77+
localStorage.set('remote-control', false);
7778
} else {
7879
localStorage.set('venue_id', this.state.venueId);
80+
localStorage.set('remote-control', this.state.remoteControl);
7981
}
80-
8182
localStorage.set('confirm-busts', this.state.confirmBusts);
8283
localStorage.set('auto-finish-legs', this.state.autoFinishLegs);
8384
localStorage.set('auto-finish-time', this.state.autoFinishTime);
8485
localStorage.set('volume', this.state.volume / 100);
85-
localStorage.set('remote-control', this.state.remoteControl);
8686
},
8787
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<div class="table table-responsive">
2+
<table id="table-tournaments-list">
3+
<thead>
4+
<tr>
5+
<th class="pl-10">Name</th>
6+
<th class="text-center hidden-xs">Short Name</th>
7+
<th class="text-center">Office</th>
8+
<th class="text-center">Start Time</th>
9+
<th class="text-center">End Time</th>
10+
<th class="text-center">Overview</th>
11+
</tr>
12+
</thead>
13+
<tbody>
14+
<for|tournament| of=input.tournaments>
15+
<tr>
16+
<td style='width: 20%; white-space: nowrap;' class="pl-10">${tournament.name}</td>
17+
<td class="text-center hidden-xs">
18+
<div style="display: inline-block; padding-right: 6px">${tournament.short_name}</div>
19+
</td>
20+
<td style='width: 10%; white-space: nowrap;' class="pl-10">${input.offices[tournament.office_id].name}</td>
21+
<td class="text-center">
22+
<div style="display: inline-block; padding-right: 6px">${tournament.start_time}</div>
23+
</td>
24+
<td class="text-center">${tournament.end_time}</td>
25+
<td class="text-center">
26+
<a href=`/tournaments/${tournament.id}`>
27+
<i class="fas fa-eye fas-option-button" data-toggle="tooltip" data-placement="top" title="View"/>
28+
</a>
29+
</td>
30+
</tr>
31+
</for>
32+
</tbody>
33+
</table>
34+
</div>

src/pages/tournaments/components/tournaments/tournaments.component.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,36 @@ const moment = require("moment");
33

44
module.exports = {
55
onCreate(input) {
6-
const tournaments = input.tournaments;
7-
for (let i = 0; i < tournaments.length; i++) {
8-
const tournament = tournaments[i];
6+
const tournaments = [];
7+
const seasons = [];
8+
for (let i = 0; i < input.tournaments.length; i++) {
9+
const tournament = input.tournaments[i];
910
tournament.start_time = moment(tournament.start_time).format('YYYY-MM-DD HH:mm');
1011
tournament.end_time = moment(tournament.end_time).format('YYYY-MM-DD HH:mm');
12+
13+
if (tournament.is_season) {
14+
seasons.push(tournament);
15+
} else {
16+
tournaments.push(tournament);
17+
}
1118
}
19+
1220
this.state = {
13-
tournaments: tournaments
21+
tournaments: tournaments,
22+
seasons: seasons
1423
}
1524
},
1625

1726
officeChanged(officeId) {
1827
if (officeId == 0) {
19-
this.state.tournaments = this.input.tournaments;
28+
this.state.tournaments = this.state.tournaments;
29+
this.state.seasons = this.state.seasons;
2030
} else {
2131
this.state.tournaments = _.reject(this.input.tournaments, (tournament) => {
2232
return tournament.office_id != officeId ;
2333
});
2434
}
2535
this.setStateDirty("tournaments");
36+
this.setStateDirty("seasons");
2637
}
2738
};
Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,29 @@
1+
$ const hasSeasons = state.seasons.length > 0;
12
<page-header heading="Tournaments" subheading="List of tournaments"/>
23
<if(input.locals.kcapp.local_admin)>
34
<options-panel />
45
</if>
56
<div class="block-container no-padding">
67
<office-selector offices=input.offices clazz="float-right" on-office-changed("officeChanged")/>
7-
<div class="table table-responsive">
8-
<table id="table-tournaments-list">
9-
<thead>
10-
<tr>
11-
<th class="pl-10">Name</th>
12-
<th class="text-center hidden-xs">Short Name</th>
13-
<th class="text-center">Office</th>
14-
<th class="text-center">Start Time</th>
15-
<th class="text-center">End Time</th>
16-
<th class="text-center">Overview</th>
17-
</tr>
18-
</thead>
19-
<tbody>
20-
<for|tournament| of=state.tournaments>
21-
<tr>
22-
<td style='width: 20%; white-space: nowrap;' class="pl-10">${tournament.name}</td>
23-
<td class="text-center hidden-xs">
24-
<div style="display: inline-block; padding-right: 6px">${tournament.short_name}</div>
25-
</td>
26-
<td style='width: 10%; white-space: nowrap;' class="pl-10">${input.offices[tournament.office_id].name}</td>
27-
<td class="text-center">
28-
<div style="display: inline-block; padding-right: 6px">${tournament.start_time}</div>
29-
</td>
30-
<td class="text-center">${tournament.end_time}</td>
31-
<td class="text-center">
32-
<a href=`/tournaments/${tournament.id}`>
33-
<i class="fas fa-eye fas-option-button" data-toggle="tooltip" data-placement="top" title="View"/>
34-
</a>
35-
</td>
36-
</tr>
37-
</for>
38-
</tbody>
39-
</table>
40-
<if(state.tournaments.length === 0)>
41-
<div class='text-center pt-20'>No Tournaments yet</div>
8+
<div class="block-container no-padding">
9+
<if(hasSeasons)>
10+
<ul class="nav nav-tabs">
11+
<li role="presentation" class="active"><a href="#seasons" data-toggle="tab">Seasons</a></li>
12+
<li role="presentation"><a href="#tournaments" data-toggle="tab">Tournaments</a></li>
13+
</ul>
4214
</if>
4315
</div>
16+
<div class="tab-content" style="width: 100%;">
17+
<if(hasSeasons)>
18+
<div class=`tab-pane ${hasSeasons ? "active" : ""}` role="tabpanel" id="seasons">
19+
<tournament-table tournaments=state.seasons offices=input.offices />
20+
</div>
21+
</if>
22+
<div class=`tab-pane ${!hasSeasons ? "active" : ""}` role="tabpanel" id="tournaments">
23+
<tournament-table tournaments=state.tournaments offices=input.offices />
24+
</div>
25+
</div>
26+
<if(input.tournaments.length === 0)>
27+
<div class='text-center font-24'>No Tournaments yet</div>
28+
</if>
4429
</div>

0 commit comments

Comments
 (0)