ItemCharacteristicValueEditor
All checks were successful
E2E Testing / test (push) Successful in 1m34s

This commit is contained in:
Sebastian Böckelmann 2024-05-08 07:47:44 +02:00
parent 6e65cc3a6a
commit 3a1a9ba6ee
4 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1 @@
<p>inherited-item-characteristic-editor works!</p>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { InheritedItemCharacteristicEditorComponent } from './inherited-item-characteristic-editor.component';
describe('InheritedItemCharacteristicEditorComponent', () => {
let component: InheritedItemCharacteristicEditorComponent;
let fixture: ComponentFixture<InheritedItemCharacteristicEditorComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [InheritedItemCharacteristicEditorComponent]
})
.compileComponents();
fixture = TestBed.createComponent(InheritedItemCharacteristicEditorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,32 @@
import {Component, Input, OnInit} from '@angular/core';
import {ItemGroup} from "../../../../project/game-model/inventory/ItemGroup";
import {Item} from "../../../../project/game-model/inventory/Item";
import {MatTableDataSource} from "@angular/material/table";
import {ItemgroupCharacteristicValue} from "../../../../project/game-model/inventory/ItemgroupCharacteristicValue";
@Component({
selector: 'app-inherited-item-characteristic-editor',
templateUrl: './inherited-item-characteristic-editor.component.html',
styleUrl: './inherited-item-characteristic-editor.component.scss'
})
export class InheritedItemCharacteristicEditorComponent implements OnInit{
@Input() inheritedItemgroup: ItemGroup | undefined
@Input() item: Item | undefined
datasource: MatTableDataSource<ItemgroupCharacteristicValue> = new MatTableDataSource<ItemgroupCharacteristicValue>();
ngOnInit() {
this.item!.initializeItemCharacteristics();
this.datasource.data = this.findCharacteristicValuesByItemgroup(this.inheritedItemgroup!);
}
private findCharacteristicValuesByItemgroup(itemGroup: ItemGroup): ItemgroupCharacteristicValue[] {
const result = this.item?.itemCharacteristicValues.filter(value => value.key.itemgroup.componentName === itemGroup.componentName);
if(result != undefined) {
return result;
}
return []
}
}