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-dialog-content>
<mat-form-field appearance="outline" class="long-form"> <mat-form-field appearance="outline" class="long-form">
<mat-label>Slot-Name</mat-label> <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 {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {InventorySlot} from "../../../../project/game-model/inventory/intentory-slots/InventorySlot"; import {InventorySlot} from "../../../../project/game-model/inventory/intentory-slots/InventorySlot";
import {FormControl, Validators} from "@angular/forms"; import {FormControl, Validators} from "@angular/forms";
@ -8,19 +8,31 @@ import {FormControl, Validators} from "@angular/forms";
templateUrl: './inventory-slot-creator.component.html', templateUrl: './inventory-slot-creator.component.html',
styleUrl: './inventory-slot-creator.component.scss' styleUrl: './inventory-slot-creator.component.scss'
}) })
export class InventorySlotCreatorComponent { export class InventorySlotCreatorComponent implements OnInit{
slotNameCtrl = new FormControl('', [Validators.required]); slotNameCtrl = new FormControl('', [Validators.required]);
constructor(private dialogRef: MatDialogRef<InventorySlotCreatorComponent>, constructor(private dialogRef: MatDialogRef<InventorySlotCreatorComponent>,
@Inject(MAT_DIALOG_DATA) public data: InventorySlot | undefined) { @Inject(MAT_DIALOG_DATA) public data: InventorySlot | undefined) {
} }
ngOnInit() {
if(this.data != undefined) {
this.slotNameCtrl.setValue(this.data.slotName);
}
}
submit() { submit() {
if(this.data != undefined) {
this.data.slotName = this.slotNameCtrl.value!;
this.dialogRef.close(this.data);
} else {
this.dialogRef.close(new InventorySlot(this.slotNameCtrl.value!)) this.dialogRef.close(new InventorySlot(this.slotNameCtrl.value!))
} }
}
cancel() { cancel() {
this.dialogRef.close() this.dialogRef.close()
} }

View File

@ -4,7 +4,7 @@
<mat-panel-title>{{slot.slotName}}</mat-panel-title> <mat-panel-title>{{slot.slotName}}</mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div class="panel-actions"> <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> <button mat-raised-button color="warn">Delete</button>
</div> </div>
</mat-expansion-panel> </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;
} }