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:
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