main #48

Closed
sebastian wants to merge 44 commits from main into inventory
8 changed files with 70 additions and 10 deletions
Showing only changes of commit 1266e4b53d - Show all commits

View File

@ -110,7 +110,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
CharacterEditorComponent,
TemplateSpecificatorComponent,
StateInitialCellComponent,
ItemOverviewComponent
ItemOverviewComponent,
ItemGroupEditorComponent
],
imports: [
BrowserModule,
@ -173,8 +174,7 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
MatExpansionPanel,
MatExpansionPanelTitle,
MatCardTitle,
MatExpansionPanelHeader,
ItemGroupEditorComponent
MatExpansionPanelHeader
],
providers: [],
bootstrap: [AppComponent]

View File

@ -20,6 +20,6 @@
>
</app-character-editor>
<app-item-group-editor *ngIf="modelComponent.type === ModelComponentType.ITEMGROUP"></app-item-group-editor>
<app-item-group-editor *ngIf="modelComponent.type === ModelComponentType.ITEMGROUP" [itemgroup]="convertModelComponentToItemGroup(modelComponent)"></app-item-group-editor>
</mat-tab>
</mat-tab-group>

View File

@ -7,6 +7,7 @@ import {State} from "../project/game-model/gamesystems/states/State";
import {Transition} from "../project/game-model/gamesystems/transitions/Transition";
import {ModelComponentType} from "../project/game-model/ModelComponentType";
import {Character} from "../project/game-model/characters/Character";
import {ItemGroup} from "../project/game-model/inventory/ItemGroup";
@Component({
@ -57,4 +58,11 @@ export class EditorComponent {
return modelComponent as Character
return undefined;
}
convertModelComponentToItemGroup(modelComponent: ModelComponent) {
if(modelComponent instanceof ItemGroup) {
return modelComponent as ItemGroup
}
return undefined;
}
}

View File

@ -1 +1,21 @@
<p>item-group-editor works!</p>
<table mat-table [dataSource]="itemQualityDatasource" class="mat-elevation-z8">
<ng-container matColumnDef="Characteristic">
<th mat-header-cell *matHeaderCellDef> Characteristic </th>
<td mat-cell *matCellDef="let element"> {{element.characteristicName}} </td>
</ng-container>
<ng-container matColumnDef="Description">
<th mat-header-cell *matHeaderCellDef> Description </th>
<td mat-cell *matCellDef="let element"> {{element.characteristicDescription}} </td>
</ng-container>
<ng-container matColumnDef="edit">
<th mat-header-cell *matHeaderCellDef> </th>
<td mat-cell *matCellDef="let element"><button mat-icon-button><mat-icon>edit</mat-icon></button></td>
</ng-container>
<ng-container matColumnDef="delete">
<th mat-header-cell *matHeaderCellDef> <button mat-icon-button><mat-icon>add</mat-icon></button> </th>
<td mat-cell *matCellDef="let element"><button mat-icon-button color="warn" (click)="deleteItemgroupCharacteristic(element)"><mat-icon>delete</mat-icon></button></td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>

View File

@ -0,0 +1,3 @@
.mat-column-edit, .mat-column-delete {
width: 32px;
}

View File

@ -1,12 +1,29 @@
import { Component } from '@angular/core';
import {Component, Input, OnInit} from '@angular/core';
import {ItemGroup} from "../../../project/game-model/inventory/ItemGroup";
import {MatColumnDef, MatTable, MatTableDataSource} from "@angular/material/table";
import {ItemQuality} from "../../../project/game-model/inventory/ItemQuality";
import {ItemGroupCharacteristic} from "../../../project/game-model/inventory/ItemgroupCharacteristic";
@Component({
selector: 'app-item-group-editor',
standalone: true,
imports: [],
templateUrl: './item-group-editor.component.html',
styleUrl: './item-group-editor.component.scss'
})
export class ItemGroupEditorComponent {
export class ItemGroupEditorComponent implements OnInit{
@Input() itemgroup: ItemGroup | undefined
itemQualityDatasource: MatTableDataSource<ItemGroupCharacteristic> = new MatTableDataSource<ItemGroupCharacteristic>();
displayedColumns: string[] = ["Characteristic", "Description", 'edit', 'delete']
ngOnInit(): void {
this.itemgroup!.itemGroupCharacteristics.push(new ItemGroupCharacteristic("Inventory", "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."))
this.itemQualityDatasource.data = this.itemgroup!.itemGroupCharacteristics;
}
deleteItemgroupCharacteristic(characteristic: ItemGroupCharacteristic) {
this.itemgroup!.itemGroupCharacteristics = this.itemgroup!.itemGroupCharacteristics.filter(igc => igc.characteristicName !== characteristic.characteristicName);
this.itemQualityDatasource.data = this.itemgroup!.itemGroupCharacteristics;
}
}

View File

@ -1,7 +1,9 @@
import {ModelComponent} from "../ModelComponent";
import {ItemQuality} from "./ItemQuality";
import {ItemGroupCharacteristic} from "./ItemgroupCharacteristic";
export abstract class ItemGroup extends ModelComponent {
requiredItemQualities: ItemQuality[] = []
itemGroupCharacteristics: ItemGroupCharacteristic[] = []
}

View File

@ -0,0 +1,10 @@
export class ItemGroupCharacteristic {
characteristicName: string;
characteristicDescription: string
constructor(characteristicName: string, characteristicDescription: string) {
this.characteristicName = characteristicName;
this.characteristicDescription = characteristicDescription;
}
}