Compare commits
7 Commits
master
...
b6d34ce262
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6d34ce262 | ||
|
|
764ce43138 | ||
|
|
1bc97df0da | ||
|
|
5408a8d9b6 | ||
|
|
665cb25d34 | ||
|
|
3b8e5145c3 | ||
|
|
51414f5a99 |
@@ -1,59 +1,5 @@
|
|||||||
<main class="main">
|
<main class="main">
|
||||||
<div class="row justify-content-md-center">
|
<app-screen-rotations [players]="players"></app-screen-rotations>
|
||||||
<h1>Please select the number of teams:</h1>
|
|
||||||
<div class="btn-toolbar mb-3 col justify-content-center" role="toolbar">
|
|
||||||
<div class="btn-group me-2" id="numTeamsSelector" role="group"
|
|
||||||
value="2">
|
|
||||||
<input value="2" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
|
|
||||||
<label class="btn btn-outline-primary" for="btnradio1">Two</label>
|
|
||||||
|
|
||||||
<input value="3" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-primary" for="btnradio2">Three</label>
|
|
||||||
|
|
||||||
<input value="n" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio3" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-primary" for="btnradio3">n</label>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="numTeamsSelectorValue === 'n'" id="nTeamsText" class="col-md-auto">
|
|
||||||
<label for="nTeamsField">n Teams</label>
|
|
||||||
<input type="number" pattern="\d*" [(ngModel)]="nTeamsValue" id="nTeamsField" class="form-control" >
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form>
|
|
||||||
<div class="container">
|
|
||||||
<label for="playerNames">Names</label>
|
|
||||||
<textarea [(ngModel)]="playerNamesValue"
|
|
||||||
class="form-control mb-3"
|
|
||||||
rows="18"
|
|
||||||
cols="30"
|
|
||||||
style="text-align: left;"
|
|
||||||
name="playerNames"
|
|
||||||
#playerNames
|
|
||||||
id="playerNames"
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
<button type="button" (click)="onButtonGenerate(playerNames.value)" class="btn btn-primary">Generate</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<table class="table table-striped custom-table">
|
|
||||||
<caption *ngIf="duplicateNames.length >0">Removed: {{ duplicateNames }}</caption>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Size</th>
|
|
||||||
<th scope="col">Names</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@for (team of teamsArray; track $index) {
|
|
||||||
<tr>
|
|
||||||
<td style="text-wrap: wrap;">{{ team.length | number }}</td>
|
|
||||||
<td class="wrap-cell">{{ team }}</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<router-outlet />
|
<router-outlet />
|
||||||
|
|||||||
@@ -5,21 +5,20 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
|||||||
|
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { filter, take } from 'rxjs';
|
import { filter, take } from 'rxjs';
|
||||||
|
import { ScreenBasicComponent } from "./screen-basic/screen-basic.component";
|
||||||
|
import { ScreenRotationsComponent } from './screen-rotations/screen-rotations.component';
|
||||||
|
import { Player } from './model';
|
||||||
|
import { ScreenEditComponent } from './screen-edit/screen-edit.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule],
|
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, ScreenBasicComponent, ScreenRotationsComponent, ScreenEditComponent],
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrl: './app.component.less'
|
styleUrl: './app.component.less'
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
title = 'vb';
|
title = 'vb';
|
||||||
playerNamesValue = "";
|
players : Player[] = [];
|
||||||
numTeamsSelectorValue = "2";
|
|
||||||
numTeamsSelected = 2;
|
|
||||||
nTeamsValue = "4";
|
|
||||||
teamsArray: string[][] = [];
|
|
||||||
duplicateNames: string[] = [];
|
|
||||||
|
|
||||||
constructor(private activatedRoute: ActivatedRoute){}
|
constructor(private activatedRoute: ActivatedRoute){}
|
||||||
|
|
||||||
@@ -28,50 +27,11 @@ export class AppComponent implements OnInit {
|
|||||||
filter(params => Object.keys(params).length > 0), // Only proceed if params are not empty
|
filter(params => Object.keys(params).length > 0), // Only proceed if params are not empty
|
||||||
take(1)
|
take(1)
|
||||||
).subscribe(params => {
|
).subscribe(params => {
|
||||||
const names = params['names']?.replaceAll(',', '\n');
|
if (params['names']){
|
||||||
if (names) {
|
this.players = params['names'].split(',').map((name: string) => new Player(name));
|
||||||
this.playerNamesValue = names;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onButtonGenerate(textinput: string): void{
|
|
||||||
if(this.numTeamsSelectorValue === 'n'){
|
|
||||||
this.numTeamsSelected = Number(this.nTeamsValue);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
this.numTeamsSelected = Number(this.numTeamsSelectorValue);
|
|
||||||
}
|
|
||||||
let nameslist = this.playerNamesValue
|
|
||||||
.split('\n')
|
|
||||||
.map(function(str){return str.trim();})
|
|
||||||
.filter(function(str){return str}); // boolean interpretation is same as non-empty
|
|
||||||
// remove duplicates by using a Set
|
|
||||||
let namesset = new Set(nameslist);
|
|
||||||
let names = [...namesset];
|
|
||||||
|
|
||||||
|
|
||||||
let teams = Array.from({ length: this.numTeamsSelected }, () => []);
|
|
||||||
let playersPerTeam = Math.floor(names.length / this.numTeamsSelected);
|
|
||||||
|
|
||||||
let nameslen = names.length;
|
|
||||||
function* iter(list: any[]){
|
|
||||||
let index = 0;
|
|
||||||
while(true){
|
|
||||||
yield list[index % list.length];
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let iterator = iter(teams);
|
|
||||||
for(let i =0; i < nameslen; i++){
|
|
||||||
let index = Math.floor(Math.random()* names.length);
|
|
||||||
let n = names[index];
|
|
||||||
names.splice(index,1);
|
|
||||||
let team = iterator.next().value;
|
|
||||||
team.push(n);
|
|
||||||
|
|
||||||
}
|
|
||||||
this.teamsArray = teams;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
73
src/app/modal-rotations/modal-rotations.component.html
Normal file
73
src/app/modal-rotations/modal-rotations.component.html
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title">{{ player.name }}</h4>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn-close"
|
||||||
|
(click)="activeModal.dismiss()"
|
||||||
|
aria-label="Close"
|
||||||
|
></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form>
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
[(ngModel)]="player.outside"
|
||||||
|
name="outside"
|
||||||
|
id="outside"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="outside">Outside</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
[(ngModel)]="player.middle"
|
||||||
|
name="middle"
|
||||||
|
id="middle"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="middle">Middle</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
[(ngModel)]="player.opposite"
|
||||||
|
name="opposite"
|
||||||
|
id="opposite"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="opposite">Opposite</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
[(ngModel)]="player.setter"
|
||||||
|
name="setter"
|
||||||
|
id="setter"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="setter">Setter</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
[(ngModel)]="player.libero"
|
||||||
|
name="libero"
|
||||||
|
id="libero"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label" for="libero">Libero</label>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-primary"
|
||||||
|
(click)="savePlayer(); activeModal.close()"
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
23
src/app/modal-rotations/modal-rotations.component.spec.ts
Normal file
23
src/app/modal-rotations/modal-rotations.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ModalRotationsComponent } from './modal-rotations.component';
|
||||||
|
|
||||||
|
describe('ModalRotationsComponent', () => {
|
||||||
|
let component: ModalRotationsComponent;
|
||||||
|
let fixture: ComponentFixture<ModalRotationsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ModalRotationsComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ModalRotationsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
21
src/app/modal-rotations/modal-rotations.component.ts
Normal file
21
src/app/modal-rotations/modal-rotations.component.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Component, Input } from '@angular/core';
|
||||||
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { Player} from '../model';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-modal-rotations',
|
||||||
|
imports: [FormsModule],
|
||||||
|
templateUrl: './modal-rotations.component.html',
|
||||||
|
styleUrl: './modal-rotations.component.less'
|
||||||
|
})
|
||||||
|
export class ModalRotationsComponent {
|
||||||
|
@Input() player!: Player;
|
||||||
|
|
||||||
|
constructor(public activeModal: NgbActiveModal) {}
|
||||||
|
|
||||||
|
savePlayer() {
|
||||||
|
// You can emit an event or handle the save logic here
|
||||||
|
this.activeModal.close(this.player);
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/app/model.ts
Normal file
42
src/app/model.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
export class Player{
|
||||||
|
name: string;
|
||||||
|
outside: boolean;
|
||||||
|
middle: boolean;
|
||||||
|
opposite: boolean; // dia
|
||||||
|
setter: boolean;
|
||||||
|
libero: boolean;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
name:string,
|
||||||
|
outside: boolean = false,
|
||||||
|
middle: boolean = false,
|
||||||
|
opposite: boolean = false, // dia
|
||||||
|
setter: boolean = false,
|
||||||
|
libero: boolean = false,
|
||||||
|
){
|
||||||
|
this.name = name;
|
||||||
|
this.outside = outside;
|
||||||
|
this.middle = middle;
|
||||||
|
this.opposite = opposite;
|
||||||
|
this.setter = setter;
|
||||||
|
this.libero = libero;
|
||||||
|
}
|
||||||
|
serialize(): string[] {
|
||||||
|
const values = 'OOOO'
|
||||||
|
return [this.name, values];
|
||||||
|
}
|
||||||
|
|
||||||
|
valueOf(): string{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
static deSerialize(name: string, values: string): Player{
|
||||||
|
return new Player(name);
|
||||||
|
}
|
||||||
|
static isNew(newplayer:Player, players: Player[]): boolean {
|
||||||
|
const seen = new Set<string>(players.map(p => p.name));
|
||||||
|
if (seen.has(newplayer.name)){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/app/screen-basic/screen-basic.component.html
Normal file
42
src/app/screen-basic/screen-basic.component.html
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<div class="justify-content-md-center">
|
||||||
|
<div class="btn-toolbar mb-3 col justify-content-center" role="toolbar">
|
||||||
|
<div class="btn-group me-2" id="numTeamsSelector" role="group"
|
||||||
|
value="2">
|
||||||
|
<input value="2" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
|
||||||
|
<label class="btn btn-outline-primary" for="btnradio1">Two</label>
|
||||||
|
|
||||||
|
<input value="3" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off">
|
||||||
|
<label class="btn btn-outline-primary" for="btnradio2">Three</label>
|
||||||
|
|
||||||
|
<input value="n" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio3" autocomplete="off">
|
||||||
|
<label class="btn btn-outline-primary" for="btnradio3">n</label>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="numTeamsSelectorValue === 'n'" id="nTeamsText" class="col-md-auto">
|
||||||
|
<label for="nTeamsField">n Teams</label>
|
||||||
|
<input type="number" pattern="\d*" [(ngModel)]="nTeamsValue" id="nTeamsField" class="form-control" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h1>Random Teams</h1>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<button type="button" (click)="onButtonGenerate()" class="btn btn-primary">Generate</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<table class="table table-striped custom-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Size</th>
|
||||||
|
<th scope="col">Names</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@for (team of teamsArray; track $index) {
|
||||||
|
<tr>
|
||||||
|
<td style="text-wrap: wrap;">{{ team.length | number }}</td>
|
||||||
|
<td class="wrap-cell">{{ team }}</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
0
src/app/screen-basic/screen-basic.component.less
Normal file
0
src/app/screen-basic/screen-basic.component.less
Normal file
23
src/app/screen-basic/screen-basic.component.spec.ts
Normal file
23
src/app/screen-basic/screen-basic.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ScreenBasicComponent } from './screen-basic.component';
|
||||||
|
|
||||||
|
describe('ScreenBasicComponent', () => {
|
||||||
|
let component: ScreenBasicComponent;
|
||||||
|
let fixture: ComponentFixture<ScreenBasicComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ScreenBasicComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ScreenBasicComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
48
src/app/screen-basic/screen-basic.component.ts
Normal file
48
src/app/screen-basic/screen-basic.component.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
// Original Team Generation Screen for arbitrary size and number of teams
|
||||||
|
import { Component, Input, OnInit} from '@angular/core';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { RouterOutlet, ActivatedRoute } from '@angular/router';
|
||||||
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { Player } from '../model';
|
||||||
|
import { iter } from '../util';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-screen-basic',
|
||||||
|
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule],
|
||||||
|
templateUrl: './screen-basic.component.html',
|
||||||
|
styleUrl: './screen-basic.component.less'
|
||||||
|
})
|
||||||
|
export class ScreenBasicComponent {
|
||||||
|
@Input() players!: Player[];
|
||||||
|
numTeamsSelectorValue = "2";
|
||||||
|
numTeamsSelected = 2;
|
||||||
|
nTeamsValue = "4";
|
||||||
|
teamsArray: string[][] = [];
|
||||||
|
|
||||||
|
onButtonGenerate(): void{
|
||||||
|
if(this.numTeamsSelectorValue === 'n'){
|
||||||
|
this.numTeamsSelected = Number(this.nTeamsValue);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.numTeamsSelected = Number(this.numTeamsSelectorValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
let teams = Array.from({ length: this.numTeamsSelected }, () => []);
|
||||||
|
// clone array here
|
||||||
|
let localPlayers: Player[] = Object.assign([],this.players);
|
||||||
|
|
||||||
|
let nameslen = localPlayers.length;
|
||||||
|
let iterator = iter(teams);
|
||||||
|
for(let i =0; i < nameslen; i++){
|
||||||
|
let index = Math.floor(Math.random()* localPlayers.length);
|
||||||
|
let n = localPlayers[index];
|
||||||
|
localPlayers.splice(index,1);
|
||||||
|
let team = iterator.next().value;
|
||||||
|
team.push(n.name);
|
||||||
|
|
||||||
|
}
|
||||||
|
this.teamsArray = teams;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
30
src/app/screen-edit/screen-edit.component.html
Normal file
30
src/app/screen-edit/screen-edit.component.html
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<div class="justify-content-md-center">
|
||||||
|
<h1>Players: {{ players.length }}</h1>
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
[(ngModel)]="newItem"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="Enter a name..."
|
||||||
|
(keyup.enter)="addItem()"
|
||||||
|
/>
|
||||||
|
<button class="btn btn-primary" type="button" (click)="addItem()" >
|
||||||
|
<i class="bi bi-plus-lg"></i> Add
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@if (alertMessage) {
|
||||||
|
<ngb-alert #selfClosingAlert type="danger" (closed)="alertMessage = ''">{{ alertMessage }}</ngb-alert>
|
||||||
|
}
|
||||||
|
<div class="container mt-4">
|
||||||
|
<ul class="list-group mb-3">
|
||||||
|
@for (player of players; track $index) {
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a (click)="openPlayerModal(player)" style="display: block; cursor: pointer;">{{ player.name }}</a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
0
src/app/screen-edit/screen-edit.component.less
Normal file
0
src/app/screen-edit/screen-edit.component.less
Normal file
23
src/app/screen-edit/screen-edit.component.spec.ts
Normal file
23
src/app/screen-edit/screen-edit.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ScreenEditComponent } from './screen-edit.component';
|
||||||
|
|
||||||
|
describe('ScreenEditComponent', () => {
|
||||||
|
let component: ScreenEditComponent;
|
||||||
|
let fixture: ComponentFixture<ScreenEditComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ScreenEditComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ScreenEditComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
63
src/app/screen-edit/screen-edit.component.ts
Normal file
63
src/app/screen-edit/screen-edit.component.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import { Component, Input, ViewChild } from '@angular/core';
|
||||||
|
import { NgbAlert, NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { Player } from '../model';
|
||||||
|
import { ModalRotationsComponent } from '../modal-rotations/modal-rotations.component';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { Subject } from 'rxjs/internal/Subject';
|
||||||
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||||
|
import { debounceTime, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-screen-edit',
|
||||||
|
imports: [FormsModule, NgbAlert],
|
||||||
|
templateUrl: './screen-edit.component.html',
|
||||||
|
styleUrl: './screen-edit.component.less'
|
||||||
|
})
|
||||||
|
export class ScreenEditComponent {
|
||||||
|
@Input() players!: Player[];
|
||||||
|
@ViewChild('selfClosingAlert', { static: false })selfClosingAlert!: NgbAlert;
|
||||||
|
private _message$ = new Subject<string>();
|
||||||
|
newItem: string = "";
|
||||||
|
alertMessage = '';
|
||||||
|
|
||||||
|
constructor(private modalService: NgbModal) {
|
||||||
|
this._message$
|
||||||
|
.pipe(
|
||||||
|
takeUntilDestroyed(),
|
||||||
|
tap((message) => (this.alertMessage = message)),
|
||||||
|
debounceTime(5000),
|
||||||
|
)
|
||||||
|
.subscribe(() => this.selfClosingAlert?.close());
|
||||||
|
}
|
||||||
|
|
||||||
|
addItem() {
|
||||||
|
const name = this.newItem.trim()
|
||||||
|
if (name) {
|
||||||
|
let newPlayer = new Player(name);
|
||||||
|
if (Player.isNew(newPlayer, this.players)){
|
||||||
|
this.players.push(newPlayer);
|
||||||
|
this.newItem = '';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.setAlertMessage(newPlayer.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
openPlayerModal(player: Player){
|
||||||
|
const modalRef = this.modalService.open(ModalRotationsComponent);
|
||||||
|
modalRef.componentInstance.player = player;
|
||||||
|
/*
|
||||||
|
modalRef.result.then((updatedPlayer) => {
|
||||||
|
// Handle the updated player data if needed
|
||||||
|
console.log('Player updated:', updatedPlayer);
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log('Modal dismissed');
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
public setAlertMessage(s: string) {
|
||||||
|
this._message$.next(`"${s}" already exists. Please choose a unique name.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
65
src/app/screen-rotations/screen-rotations.component.html
Normal file
65
src/app/screen-rotations/screen-rotations.component.html
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<div class="justify-content-md-center">
|
||||||
|
<h1>Rotations</h1>
|
||||||
|
<div ngbAccordion>
|
||||||
|
<div ngbAccordionItem>
|
||||||
|
<h2 ngbAccordionHeader>
|
||||||
|
<button ngbAccordionButton>Outside</button>
|
||||||
|
</h2>
|
||||||
|
<div ngbAccordionCollapse>
|
||||||
|
<div ngbAccordionBody>
|
||||||
|
@for (player of outsidePlayers; track $index) {
|
||||||
|
{{ player.name }}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ngbAccordion>
|
||||||
|
<div ngbAccordionItem>
|
||||||
|
<h2 ngbAccordionHeader>
|
||||||
|
<button ngbAccordionButton>Middle</button>
|
||||||
|
</h2>
|
||||||
|
<div ngbAccordionCollapse>
|
||||||
|
<div ngbAccordionBody>
|
||||||
|
<ng-template>Content for the first item</ng-template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ngbAccordion>
|
||||||
|
<div ngbAccordionItem>
|
||||||
|
<h2 ngbAccordionHeader>
|
||||||
|
<button ngbAccordionButton>Opposite</button>
|
||||||
|
</h2>
|
||||||
|
<div ngbAccordionCollapse>
|
||||||
|
<div ngbAccordionBody>
|
||||||
|
<ng-template>Content for the first item</ng-template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ngbAccordion>
|
||||||
|
<div ngbAccordionItem>
|
||||||
|
<h2 ngbAccordionHeader>
|
||||||
|
<button ngbAccordionButton>Setter</button>
|
||||||
|
</h2>
|
||||||
|
<div ngbAccordionCollapse>
|
||||||
|
<div ngbAccordionBody>
|
||||||
|
<ng-template>Content for the first item</ng-template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ngbAccordion>
|
||||||
|
<div ngbAccordionItem>
|
||||||
|
<h2 ngbAccordionHeader>
|
||||||
|
<button ngbAccordionButton>Libero</button>
|
||||||
|
</h2>
|
||||||
|
<div ngbAccordionCollapse>
|
||||||
|
<div ngbAccordionBody>
|
||||||
|
<ng-template>Content for the first item</ng-template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
23
src/app/screen-rotations/screen-rotations.component.spec.ts
Normal file
23
src/app/screen-rotations/screen-rotations.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ScreenRotationsComponent } from './screen-rotations.component';
|
||||||
|
|
||||||
|
describe('ScreenRotationsComponent', () => {
|
||||||
|
let component: ScreenRotationsComponent;
|
||||||
|
let fixture: ComponentFixture<ScreenRotationsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ScreenRotationsComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ScreenRotationsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
30
src/app/screen-rotations/screen-rotations.component.ts
Normal file
30
src/app/screen-rotations/screen-rotations.component.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
// Team Generation Screen respecting volleyball roles as defined by `../model/Player`
|
||||||
|
import { Component, Input } from '@angular/core';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { Player } from '../model';
|
||||||
|
import { NgbAccordionBody, NgbAccordionCollapse, NgbAccordionHeader, NgbAccordionItem, NgbAccordionButton, NgbAccordionDirective, NgbAccordionToggle } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-screen-rotations',
|
||||||
|
imports: [FormsModule, NgbAccordionButton, NgbAccordionDirective, NgbAccordionItem, NgbAccordionHeader, NgbAccordionToggle, NgbAccordionBody, NgbAccordionCollapse,],
|
||||||
|
templateUrl: './screen-rotations.component.html',
|
||||||
|
styleUrl: './screen-rotations.component.less'
|
||||||
|
})
|
||||||
|
export class ScreenRotationsComponent {
|
||||||
|
@Input() players!: Player[];
|
||||||
|
get outsidePlayers(): Player[] {
|
||||||
|
return this.players.filter(player => !player.outside);
|
||||||
|
}
|
||||||
|
get middlePlayers(): Player[] {
|
||||||
|
return this.players.filter(player => player.middle);
|
||||||
|
}
|
||||||
|
get oppositePlayers(): Player[] {
|
||||||
|
return this.players.filter(player => player.opposite);
|
||||||
|
}
|
||||||
|
get SetterPlayers(): Player[] {
|
||||||
|
return this.players.filter(player => player.setter);
|
||||||
|
}
|
||||||
|
get LiberoPlayers(): Player[] {
|
||||||
|
return this.players.filter(player => player.libero);
|
||||||
|
}
|
||||||
|
}
|
||||||
7
src/app/util.ts
Normal file
7
src/app/util.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export function* iter(list: any[]){
|
||||||
|
let index = 0;
|
||||||
|
while(true){
|
||||||
|
yield list[index % list.length];
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user