inventory-items-2 #44
| @ -0,0 +1 @@ | |||||||
|  | <p>inherited-item-characteristic-editor works!</p> | ||||||
| @ -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(); | ||||||
|  |   }); | ||||||
|  | }); | ||||||
| @ -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 [] | ||||||
|  |   } | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user