feat: 3 screens for rotations
commit563116331fAuthor: eneller <erikneller@gmx.de> Date: Sun Feb 1 10:28:19 2026 +0100 fix: edit list items commit1946c599beAuthor: eneller <erikneller@gmx.de> Date: Sun Feb 1 10:19:16 2026 +0100 fix: minor misc ui and data commit7c7762515bAuthor: eneller <erikneller@gmx.de> Date: Sat Jan 31 23:02:01 2026 +0100 feat: navbar commitaaa0ab0638Author: eneller <erikneller@gmx.de> Date: Sat Jan 31 21:05:23 2026 +0100 feat: remove players commit4082932095Author: eneller <erikneller@gmx.de> Date: Sat Jan 31 20:36:49 2026 +0100 feat: dataservice commitb6d34ce262Author: eneller <erikneller@gmx.de> Date: Sat Jan 31 17:12:37 2026 +0100 wip: rotations accordion commit764ce43138Author: eneller <erikneller@gmx.de> Date: Sat Jan 31 16:29:11 2026 +0100 refactor: basic screen commit1bc97df0daAuthor: eneller <erikneller@gmx.de> Date: Sat Jan 31 15:52:06 2026 +0100 feat: deduplicated player adding commit5408a8d9b6Author: eneller <erikneller@gmx.de> Date: Sat Jan 31 00:31:01 2026 +0100 central players list commit665cb25d34Author: eneller <erikneller@gmx.de> Date: Fri Jan 30 23:15:16 2026 +0100 feat: modal commit3b8e5145c3Author: eneller <erikneller@gmx.de> Date: Fri Jan 30 22:51:09 2026 +0100 wip: player modal commit51414f5a99Author: eneller <erikneller@gmx.de> Date: Fri Jan 30 22:03:48 2026 +0100 refactor: extract randomizer to component
This commit is contained in:
33
src/app/screen-edit/screen-edit.component.html
Normal file
33
src/app/screen-edit/screen-edit.component.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<div class="justify-content-md-center">
|
||||
<h1>Players: {{ data.getPlayers().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 data.getPlayers(); track $index) {
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<a (click)="openPlayerModal(player)" style="display: block; cursor: pointer; flex-grow: 1; text-align: left;">{{ player.name }}</a>
|
||||
<button (click)="removeItem(player)" class="btn btn-secondary btn-sm p-0 ms-2" style="width: 24px; height: 24px" >
|
||||
<i class="bi bi-x"></i>
|
||||
</button>
|
||||
</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();
|
||||
});
|
||||
});
|
||||
67
src/app/screen-edit/screen-edit.component.ts
Normal file
67
src/app/screen-edit/screen-edit.component.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { Component, inject, 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';
|
||||
import { DataService } from '../data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-screen-edit',
|
||||
imports: [FormsModule, NgbAlert],
|
||||
templateUrl: './screen-edit.component.html',
|
||||
styleUrl: './screen-edit.component.less'
|
||||
})
|
||||
export class ScreenEditComponent {
|
||||
data = inject(DataService);
|
||||
@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(this.data.addPlayer(newPlayer)){
|
||||
this.newItem = '';
|
||||
return
|
||||
}
|
||||
else{
|
||||
this.setAlertMessage(newPlayer.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
removeItem(player: Player){
|
||||
this.data.removePlayer(player);
|
||||
}
|
||||
|
||||
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.`);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user