New Angular based web version #1
@@ -25,6 +25,7 @@ import {
|
||||
throwError
|
||||
} from 'rxjs';
|
||||
import { CarCardComponent } from './components/car-card/car-card.component';
|
||||
import { SelectedCarService } from '@vegasco-web/modules/entries/services/selected-car.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entries',
|
||||
@@ -52,6 +53,7 @@ import { CarCardComponent } from './components/car-card/car-card.component';
|
||||
export class CarsComponent {
|
||||
private readonly carClient = inject(CarClient);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly selectedCarService = inject(SelectedCarService);
|
||||
|
||||
protected readonly nonDeletedCars$: Observable<Car[]>;
|
||||
|
||||
@@ -78,13 +80,21 @@ export class CarsComponent {
|
||||
);
|
||||
}
|
||||
|
||||
onCarDeleted(entry: Car): void {
|
||||
this.deletedCars$.next([...this.deletedCars$.value, entry.id]);
|
||||
onCarDeleted(car: Car): void {
|
||||
this.deletedCars$.next([...this.deletedCars$.value, car.id]);
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Auto gelöscht',
|
||||
detail: 'Das Auto wurde erfolgreich gelöscht.',
|
||||
});
|
||||
this.resetSelectedCarIfDeleted(car);
|
||||
}
|
||||
|
||||
private resetSelectedCarIfDeleted(car: Car) {
|
||||
const selectedCarId = this.selectedCarService.getSelectedCarId();
|
||||
if (selectedCarId === car.id) {
|
||||
this.selectedCarService.setSelectedCarId(null);
|
||||
}
|
||||
}
|
||||
|
||||
private handleGetCarsError(error: unknown): Observable<never> {
|
||||
|
||||
Reference in New Issue
Block a user