inventory-items-2 #44

Closed
sebastian wants to merge 32 commits from inventory-items-2 into inventory
4 changed files with 56 additions and 0 deletions
Showing only changes of commit 3a1a9ba6ee - Show all commits

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 []
}
}