From 3b8e5145c33eec3462968f8d3c343014a860a608 Mon Sep 17 00:00:00 2001 From: eneller Date: Fri, 30 Jan 2026 22:51:09 +0100 Subject: [PATCH] wip: player modal --- src/app/app.component.html | 2 +- src/app/app.component.ts | 3 +- .../modal-rotations.component.html | 85 +++++++++++++++++++ .../modal-rotations.component.less | 0 .../modal-rotations.component.spec.ts | 23 +++++ .../modal-rotations.component.ts | 21 +++++ src/app/model.ts | 11 +++ .../screen-basic/screen-basic.component.ts | 2 +- .../screen-rotations.component.html | 33 +++++++ .../screen-rotations.component.less | 0 .../screen-rotations.component.spec.ts | 23 +++++ .../screen-rotations.component.ts | 38 +++++++++ 12 files changed, 238 insertions(+), 3 deletions(-) create mode 100644 src/app/modal-rotations/modal-rotations.component.html create mode 100644 src/app/modal-rotations/modal-rotations.component.less create mode 100644 src/app/modal-rotations/modal-rotations.component.spec.ts create mode 100644 src/app/modal-rotations/modal-rotations.component.ts create mode 100644 src/app/model.ts create mode 100644 src/app/screen-rotations/screen-rotations.component.html create mode 100644 src/app/screen-rotations/screen-rotations.component.less create mode 100644 src/app/screen-rotations/screen-rotations.component.spec.ts create mode 100644 src/app/screen-rotations/screen-rotations.component.ts diff --git a/src/app/app.component.html b/src/app/app.component.html index 14367f7..5174957 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,5 +1,5 @@
- +
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index aa06ab2..34167db 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -6,10 +6,11 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { CommonModule } from '@angular/common'; import { filter, take } from 'rxjs'; import { ScreenBasicComponent } from "./screen-basic/screen-basic.component"; +import { ScreenRotationsComponent } from './screen-rotations/screen-rotations.component'; @Component({ selector: 'app-root', - imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, ScreenBasicComponent], + imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, ScreenBasicComponent, ScreenRotationsComponent], templateUrl: './app.component.html', styleUrl: './app.component.less' }) diff --git a/src/app/modal-rotations/modal-rotations.component.html b/src/app/modal-rotations/modal-rotations.component.html new file mode 100644 index 0000000..1e4eaba --- /dev/null +++ b/src/app/modal-rotations/modal-rotations.component.html @@ -0,0 +1,85 @@ + + + + + + diff --git a/src/app/modal-rotations/modal-rotations.component.less b/src/app/modal-rotations/modal-rotations.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/app/modal-rotations/modal-rotations.component.spec.ts b/src/app/modal-rotations/modal-rotations.component.spec.ts new file mode 100644 index 0000000..111191d --- /dev/null +++ b/src/app/modal-rotations/modal-rotations.component.spec.ts @@ -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; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ModalRotationsComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ModalRotationsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/modal-rotations/modal-rotations.component.ts b/src/app/modal-rotations/modal-rotations.component.ts new file mode 100644 index 0000000..1530d7a --- /dev/null +++ b/src/app/modal-rotations/modal-rotations.component.ts @@ -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); + } +} diff --git a/src/app/model.ts b/src/app/model.ts new file mode 100644 index 0000000..f3dedb9 --- /dev/null +++ b/src/app/model.ts @@ -0,0 +1,11 @@ +export class Player{ + name: string; + outside: boolean = false; + middle: boolean = false; + opposite: boolean = false; + setter: boolean = false; + libero: boolean = false; + constructor( name: string){ + this.name = name; + } +} diff --git a/src/app/screen-basic/screen-basic.component.ts b/src/app/screen-basic/screen-basic.component.ts index 0d19843..39be8b4 100644 --- a/src/app/screen-basic/screen-basic.component.ts +++ b/src/app/screen-basic/screen-basic.component.ts @@ -6,7 +6,7 @@ import { CommonModule } from '@angular/common'; @Component({ selector: 'app-screen-basic', - imports: [NgbModule, RouterOutlet, CommonModule, FormsModule, ScreenBasicComponent], + imports: [NgbModule, RouterOutlet, CommonModule, FormsModule], templateUrl: './screen-basic.component.html', styleUrl: './screen-basic.component.less' }) diff --git a/src/app/screen-rotations/screen-rotations.component.html b/src/app/screen-rotations/screen-rotations.component.html new file mode 100644 index 0000000..616f40a --- /dev/null +++ b/src/app/screen-rotations/screen-rotations.component.html @@ -0,0 +1,33 @@ +
+
+

Players

+
    + @for (player of players; track $index) { +
  • {{ player.name }}
  • + + } +
+
+ + +
+
+ +
diff --git a/src/app/screen-rotations/screen-rotations.component.less b/src/app/screen-rotations/screen-rotations.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/app/screen-rotations/screen-rotations.component.spec.ts b/src/app/screen-rotations/screen-rotations.component.spec.ts new file mode 100644 index 0000000..0998926 --- /dev/null +++ b/src/app/screen-rotations/screen-rotations.component.spec.ts @@ -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; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ScreenRotationsComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ScreenRotationsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/screen-rotations/screen-rotations.component.ts b/src/app/screen-rotations/screen-rotations.component.ts new file mode 100644 index 0000000..98aad41 --- /dev/null +++ b/src/app/screen-rotations/screen-rotations.component.ts @@ -0,0 +1,38 @@ +import { Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { Player } from '../model'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { ModalRotationsComponent } from '../modal-rotations/modal-rotations.component'; + +@Component({ + selector: 'app-screen-rotations', + imports: [FormsModule], + templateUrl: './screen-rotations.component.html', + styleUrl: './screen-rotations.component.less' +}) +export class ScreenRotationsComponent { + players: Player[] = []; + newItem: string = ""; + + constructor(private modalService: NgbModal) {} + + addItem() { + if (this.newItem.trim()) { + this.players.push( new Player(this.newItem)); + this.newItem = ""; + } + } + + openPlayerDialog(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'); + }); + } + +} \ No newline at end of file