Skip to content

Commit

Permalink
Add sort by speed + runners must be at least 14 y/o
Browse files Browse the repository at this point in the history
  • Loading branch information
Goosly committed Dec 9, 2023
1 parent 05891ee commit 060cb29
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,20 @@ <h3>Competitors & group/task assignments</h3>
<td></td>
<td></td>
<td><button (click)="handleSortCompetitorsByName()">Sort by name</button></td>
<td *ngFor="let event of groupService.wcif.events"><button (click)="handleSortByEvent(event)">Sort</button></td>
<td *ngFor="let event of groupService.wcif.events"><button class="small" (click)="handleSortByEvent(event)">Sort by group</button></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td *ngFor="let event of groupService.wcif.events"><button class="small" (click)="handleSortBySpeedInEvent(event)">Sort by speed</button></td>
</tr>
<tr *ngIf="! importStrategy">
<td></td>
<td></td>
<td></td>
<td *ngFor="let event of groupService.wcif.events">
<button [disabled]="event.configuration.skip" class="small"(click)="handleGenerateOneEvent(event.id)">{{basicBySpeedStrategy ? 'By speed' : 'Randomize'}}</button></td>
<button [disabled]="event.configuration.skip" class="small" (click)="handleGenerateOneEvent(event.id)">{{basicBySpeedStrategy ? 'By speed' : 'Randomize'}}</button></td>
</tr>

<tr>
Expand All @@ -227,7 +233,7 @@ <h3>Competitors & group/task assignments</h3>
matTooltipClass="tooltip"
#tooltip="matTooltip"
[matTooltipPosition]="'right'"
matTooltip="C|J|R|S is short for Competitors|Judges|Runners|Scramblers. The numbers will be updated when you make a change to the assignments."></mat-icon>
matTooltip="C|J|R|S is short for Competitors| Judges| Runners| Scramblers. The numbers will be updated when you make a change to the assignments."></mat-icon>
C|J|R|S Group {{i + 1}}</td>
<td *ngFor="let event of groupService.wcif.events">{{ event.configuration.skip || ! event.groupCounters || event.groupCounters.length === 0 ? '' : event.groupCounters[i] }}</td>
</tr>
Expand Down
4 changes: 4 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ export class AppComponent {
Helpers.sortCompetitorsByGroupInEvent(this.wcif(), event.id);
}

handleSortBySpeedInEvent(event) {
Helpers.sortCompetitorsBySpeedInEvent(this.wcif(), event.id, false);
}

handleSortCompetitorsByName() {
Helpers.sortCompetitorsByName(this.wcif());
}
Expand Down
4 changes: 3 additions & 1 deletion src/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {Room} from '@wca/helpers/lib/models/room';

export class Helpers {

private static readonly _minimumAgeRequiredToRun = 14;

static sortCompetitorsByGroupInEvent(wcif: Wcif, eventId: string) {
wcif.persons = wcif.persons.sort(function(a, b) {
let textA = a[eventId].group;
Expand Down Expand Up @@ -262,7 +264,7 @@ export class Helpers {
const staffPerson: StaffPerson = new StaffPerson();
staffPerson.name = p.name;
staffPerson.wcaId = p.wcaId;
staffPerson.isAllowedTo = !p.age || p.age > 12 ? ['run'] : [];
staffPerson.isAllowedTo = !p.age || p.age >= this._minimumAgeRequiredToRun ? ['run'] : [];
return staffPerson;
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const environment = {
wcaAppId : 'd9db39d5fd0195bcdc212ead360c748592cd1fd1409b040dd790281da91ef10d',
wcaSecret : '305623ae24dd7c0789e811e7ae8b364f19e9109c976c0e5ba1c8add1a1773159',

version: '1.2.014',
version: '1.2.015',
testMode: false,
offlineMode: false
};

0 comments on commit 060cb29

Please sign in to comment.