kinosaal designer
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { computed, Injectable, signal } from '@angular/core';
|
||||
import { Sitzplatz } from '@infinimotion/model-frontend';
|
||||
import { Sitzplatz, Sitzreihe } from '@infinimotion/model-frontend';
|
||||
import { TheaterLayoutDesignerComponent } from './theater-layout-designer/theater-layout-designer.component';
|
||||
import { TheaterSeatState } from './model/theater-seat-state.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SelectedSeatsService {
|
||||
|
||||
private selectedSeatsSignal = signal<Sitzplatz[]>([]);
|
||||
private seatIsSelectableSignal = signal(true);
|
||||
private committedSignal = signal(false);
|
||||
@@ -23,20 +24,26 @@ export class SelectedSeatsService {
|
||||
readonly hadConflict = this.hadConflictSignal.asReadonly();
|
||||
|
||||
readonly totalSeats = computed(() => this.selectedSeats().length);
|
||||
readonly totalPrice = computed(() => this.selectedSeats().reduce((sum, seat) => sum + seat.row.category.price, 0));
|
||||
readonly totalPrice = computed(() =>
|
||||
this.selectedSeats().reduce((sum, seat) => sum + seat.row.category.price, 0)
|
||||
);
|
||||
|
||||
pushSelectedSeat(selectedSeat: Sitzplatz): void {
|
||||
this.selectedSeatsSignal.update(seats => [...seats, selectedSeat]);
|
||||
if (selectedSeat.id < 0) {
|
||||
TheaterLayoutDesignerComponent.interceptSeatSelection(selectedSeat);
|
||||
return;
|
||||
}
|
||||
this.selectedSeatsSignal.update((seats) => [...seats, selectedSeat]);
|
||||
this.hadConflictSignal.set(false);
|
||||
}
|
||||
|
||||
removeSelectedSeat(selectedSeat: Sitzplatz): void {
|
||||
this.selectedSeatsSignal.update(seats => seats.filter(seat => seat.id !== selectedSeat.id));
|
||||
this.selectedSeatsSignal.update((seats) => seats.filter((seat) => seat.id !== selectedSeat.id));
|
||||
this.hadConflictSignal.set(false);
|
||||
}
|
||||
|
||||
getSeatsByCategory(categoryId: number): Sitzplatz[] {
|
||||
return this.selectedSeats().filter(seat => seat.row.category.id === categoryId);
|
||||
return this.selectedSeats().filter((seat) => seat.row.category.id === categoryId);
|
||||
}
|
||||
|
||||
clearSelection(): void {
|
||||
@@ -47,7 +54,7 @@ export class SelectedSeatsService {
|
||||
this.hadConflictSignal.set(false);
|
||||
}
|
||||
|
||||
getSeatIsSelectable(): boolean{
|
||||
getSeatIsSelectable(): boolean {
|
||||
return this.seatIsSelectable();
|
||||
}
|
||||
|
||||
@@ -75,11 +82,11 @@ export class SelectedSeatsService {
|
||||
}
|
||||
|
||||
toggleDebug(): void {
|
||||
this.debugSignal.update(debug => !debug);
|
||||
this.debugSignal.update((debug) => !debug);
|
||||
}
|
||||
|
||||
isSeatSelected(seatId: number): boolean {
|
||||
return this.selectedSeats().some(seat => seat.id === seatId);
|
||||
return this.selectedSeats().some((seat) => seat.id === seatId);
|
||||
}
|
||||
|
||||
setConflict(value: boolean): void {
|
||||
|
||||
Reference in New Issue
Block a user