inventory-slots #49

Merged
sebastian merged 13 commits from inventory-slots into main 2024-05-11 15:36:10 +02:00
5 changed files with 29 additions and 5 deletions
Showing only changes of commit 0e954f1b48 - Show all commits

View File

@ -1,4 +1,4 @@
<h1 mat-dialog-title>Create Inventory Slot</h1>
<h1 mat-dialog-title>{{data == undefined ? 'Create New Inventory Slot':'Rename Inventory Slot'}}</h1>
<mat-dialog-content>
<mat-form-field appearance="outline" class="long-form">
<mat-label>Slot-Name</mat-label>

View File

@ -1,4 +1,4 @@
import {Component, Inject} from '@angular/core';
import {Component, Inject, OnInit} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {InventorySlot} from "../../../../project/game-model/inventory/intentory-slots/InventorySlot";
import {FormControl, Validators} from "@angular/forms";
@ -8,17 +8,29 @@ import {FormControl, Validators} from "@angular/forms";
templateUrl: './inventory-slot-creator.component.html',
styleUrl: './inventory-slot-creator.component.scss'
})
export class InventorySlotCreatorComponent {
export class InventorySlotCreatorComponent implements OnInit{
slotNameCtrl = new FormControl('', [Validators.required]);
constructor(private dialogRef: MatDialogRef<InventorySlotCreatorComponent>,
@Inject(MAT_DIALOG_DATA) public data: InventorySlot | undefined) {
}
ngOnInit() {
if(this.data != undefined) {
this.slotNameCtrl.setValue(this.data.slotName);
}
}
submit() {
this.dialogRef.close(new InventorySlot(this.slotNameCtrl.value!))
if(this.data != undefined) {
this.data.slotName = this.slotNameCtrl.value!;
this.dialogRef.close(this.data);
} else {
this.dialogRef.close(new InventorySlot(this.slotNameCtrl.value!))
}
}
cancel() {

View File

@ -4,7 +4,7 @@
<mat-panel-title>{{slot.slotName}}</mat-panel-title>
</mat-expansion-panel-header>
<div class="panel-actions">
<button mat-raised-button color="primary">Edit</button>
<button mat-raised-button color="primary" (click)="renameInventorySlot(slot)">Rename</button>
<button mat-raised-button color="warn">Delete</button>
</div>
</mat-expansion-panel>

View File

@ -29,4 +29,13 @@ export class InventorySlotEditorComponent {
}
})
}
renameInventorySlot(inventorySlot: InventorySlot) {
this.dialog.open(InventorySlotCreatorComponent, {
minWidth: "400px",
data: inventorySlot
})
}
protected readonly indexedDB = indexedDB;
}