From bd243fc0803483b77805b2138a039bf029a0f8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 11 May 2024 11:02:37 +0200 Subject: [PATCH] Validate SlotCharacteristic before finish Editing --- .../inventory-slot-characteristic-editor.component.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-characteristic-editor/inventory-slot-characteristic-editor.component.ts b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-characteristic-editor/inventory-slot-characteristic-editor.component.ts index 12ed5b4..ce6640e 100644 --- a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-characteristic-editor/inventory-slot-characteristic-editor.component.ts +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-characteristic-editor/inventory-slot-characteristic-editor.component.ts @@ -6,6 +6,7 @@ import {MatTable, MatTableDataSource} from "@angular/material/table"; import { InventoryCharacteristic } from "../../../../project/game-model/inventory/intentory-slots/InventoryCharacteristic"; +import {MatSnackBar} from "@angular/material/snack-bar"; @Component({ selector: 'app-inventory-slot-characteristic-editor', @@ -23,6 +24,9 @@ export class InventorySlotCharacteristicEditorComponent implements OnInit{ displayedColumns: string[] = ['increasing', 'decreasing', 'edit', 'delete'] editedCharacteristic: InventoryCharacteristic | null = null; + constructor(private snackbar: MatSnackBar) { + } + ngOnInit() { this.itemgroups.forEach(itemgroup => { this.availableCharacteristics = this.availableCharacteristics.concat(itemgroup.itemGroupCharacteristics); @@ -38,7 +42,11 @@ export class InventorySlotCharacteristicEditorComponent implements OnInit{ } finishEditing() { - this.editedCharacteristic = null; + if(this.editedCharacteristic != null && this.editedCharacteristic.isValid()) { + this.editedCharacteristic = null; + } else if(this.editedCharacteristic != null) { + this.snackbar.open("Please select a valid increasing and decreasing Characterstic", "", {duration: 2000}); + } } onSelectIncreasingCharacteristic(selectedCharacteristic: ItemGroupCharacteristic, slotCharacteristic: InventoryCharacteristic) {