main #48

Closed
sebastian wants to merge 44 commits from main into inventory
7 changed files with 86 additions and 17 deletions
Showing only changes of commit db0bd14ea8 - Show all commits

View File

@ -4,7 +4,7 @@
</mat-card-header>
<mat-card-content>
<mat-accordion>
<mat-expansion-panel *ngFor="let itemgroup of item!.inheritedGroups">
<mat-expansion-panel *ngFor="let itemgroup of manuallyAndHierarchyItemgroups">
<mat-expansion-panel-header>
<mat-panel-title>{{itemgroup.componentName}}</mat-panel-title>
<mat-panel-description>{{itemgroup.componentDescription}}</mat-panel-description>

View File

@ -17,29 +17,33 @@ export class ItemEditorComponent {
@Input() gameModel: GameModel | undefined;
constructor(private dialog: MatDialog) {
}
onAddNewInheritedItemgroup() {
const itemgroups = this.item!.manuallyInheritedGroups.concat(this.item!.hierarchyInheritedGroups);
const dialogRef = this.dialog.open(ItemgroupInheritorComponent, {
data: this.gameModel!.itemgroupsAsList.filter(group => !this.item!.inheritedGroups.includes(group)),
data: this.gameModel!.itemgroupsAsList.filter(group => !itemgroups.includes(group)),
width: "400px"
})
dialogRef.afterClosed().subscribe(res => {
if(res != undefined) {
this.item!.inheritedGroups.push(res);
this.item!.addInheritedGroup(res);
}
})
}
deleteInheritedItemgroup(itemgroup: ItemGroup) {
this.item!.inheritedGroups = this.item!.inheritedGroups.filter(group => group.componentName !== itemgroup.componentName);
this.item!.deleteInheritedGroup(itemgroup);
}
get automaticallyInheritedItemgroups() {
return ItemgroupUtilities.findItemgroupPathToItem(this.item!.componentName, this.gameModel!.itemgroups);
}
get manuallyAndHierarchyItemgroups() {
return this.item!.hierarchyInheritedGroups.concat(this.item!.manuallyInheritedGroups);
}
}

View File

@ -38,7 +38,8 @@ export class ItemGroupEditorComponent implements OnInit{
addItemgroupCharacteristic() {
const itemgroupCharacteristic = new ItemGroupCharacteristic("", "", this.itemgroup!);
this.itemgroup!.itemGroupCharacteristics.push(itemgroupCharacteristic);
this.itemgroup!.addItemgroupCharacteristic(itemgroupCharacteristic);
this.itemQualityDatasource.data = this.itemgroup!.itemGroupCharacteristics;
this.editedCharacteristic = itemgroupCharacteristic;
}

View File

@ -1,4 +1,5 @@
import {ItemGroup} from "./ItemGroup";
import {ItemGroupCharacteristic} from "./ItemgroupCharacteristic";
export class AbstractItemGroup extends ItemGroup {
@ -8,4 +9,10 @@ export class AbstractItemGroup extends ItemGroup {
this.children.push(itemGroup)
itemGroup.parentGroup = this;
}
protected addCharacteristicValue(characteristic: ItemGroupCharacteristic): void {
//Do Nothing
}
}

View File

@ -1,5 +1,6 @@
import {ItemGroup} from "./ItemGroup";
import {Item} from "./Item";
import {ItemGroupCharacteristic} from "./ItemgroupCharacteristic";
export class ConcreteItemGroup extends ItemGroup {
@ -8,7 +9,7 @@ export class ConcreteItemGroup extends ItemGroup {
addItem(item: Item, parentItemgroups: ItemGroup[]) {
if(this.findItemByName(item.componentName) == undefined) {
parentItemgroups.forEach(itemgroup => {
item.inheritedGroups.push(itemgroup);
item.addInheritedHierarchyGroup(itemgroup);
})
this.items.push(item);
}
@ -17,4 +18,12 @@ export class ConcreteItemGroup extends ItemGroup {
findItemByName(itemName: string) {
return this.items.find(item => item.componentName === itemName);
}
protected addCharacteristicValue(characteristic: ItemGroupCharacteristic): void {
this.items.forEach(item => {
item.addCharacteristic(characteristic);
})
}
}

View File

@ -5,17 +5,21 @@ import {ItemGroupCharacteristic} from "./ItemgroupCharacteristic";
export class Item extends ModelComponent {
inheritedGroups: ItemGroup[] = []
manuallyInheritedGroups: ItemGroup[] = []
hierarchyInheritedGroups: ItemGroup[] = []
itemCharacteristicValues: ItemgroupCharacteristicValue[] = []
initializeItemCharacteristics() {
this.inheritedGroups.forEach(itemGroup => {
itemGroup.itemGroupCharacteristics.forEach(characteristic => {
const characteristicValue = new ItemgroupCharacteristicValue(characteristic, 0);
if(!this.isValueInitialized(characteristic)) {
this.itemCharacteristicValues.push(characteristicValue);
}
const inheritedGroups = this.manuallyInheritedGroups.concat(this.hierarchyInheritedGroups);
inheritedGroups.forEach(itemGroup => {
this.initializeItemCharacteristicsOfItemgroup(itemGroup);
})
}
initializeItemCharacteristicsOfItemgroup(itemGroup: ItemGroup) {
itemGroup.itemGroupCharacteristics.forEach(characteristic => {
this.addCharacteristic(characteristic);
})
}
@ -25,11 +29,30 @@ export class Item extends ModelComponent {
addInheritedGroup(itemgroup: ItemGroup) {
if(this.findItemgroupByName(itemgroup.componentName) == undefined) {
this.inheritedGroups.push(itemgroup);
this.manuallyInheritedGroups.push(itemgroup);
this.initializeItemCharacteristicsOfItemgroup(itemgroup);
}
}
findItemgroupByName(groupName: string) {
return this.inheritedGroups.find(group => group.componentName === groupName);
const itemgroups = this.hierarchyInheritedGroups.concat(this.manuallyInheritedGroups);
return itemgroups.find(group => group.componentName === groupName);
}
addCharacteristic(characteristic: ItemGroupCharacteristic) {
const characteristicValue = new ItemgroupCharacteristicValue(characteristic, 0);
if(!this.isValueInitialized(characteristic)) {
this.itemCharacteristicValues.push(characteristicValue);
}
}
deleteInheritedGroup(itemgroup: ItemGroup) {
this.manuallyInheritedGroups = this.manuallyInheritedGroups.filter(manually => manually.componentName !== itemgroup.componentName);
}
addInheritedHierarchyGroup(itemgroup: ItemGroup) {
this.hierarchyInheritedGroups.push(itemgroup);
this.initializeItemCharacteristicsOfItemgroup(itemgroup);
}
}

View File

@ -1,10 +1,35 @@
import {ModelComponent} from "../ModelComponent";
import {ItemGroupCharacteristic} from "./ItemgroupCharacteristic";
import {AbstractItemGroup} from "./AbstractItemGroup";
import {Item} from "./Item";
export abstract class ItemGroup extends ModelComponent {
itemGroupCharacteristics: ItemGroupCharacteristic[] = []
parentGroup: AbstractItemGroup | undefined
manuallyInheritedItems: Item[] = []
addItemgroupCharacteristic(itemgroupCharacteristic: ItemGroupCharacteristic) {
this.itemGroupCharacteristics.push(itemgroupCharacteristic);
this.addCharacteristicValueForManuallyItems(itemgroupCharacteristic);
this.addCharacteristicValue(itemgroupCharacteristic);
}
protected abstract addCharacteristicValue(characteristic: ItemGroupCharacteristic): void;
private addCharacteristicValueForManuallyItems(characteristic: ItemGroupCharacteristic) {
this.manuallyInheritedItems.forEach(item => {
item.addCharacteristic(characteristic);
})
}
inheritManualItem(item: Item) {
if(this.manuallyInheritedItems.find(inheritedItems => inheritedItems.componentName === item.componentName) == undefined) {
this.manuallyInheritedItems.push(item);
item.addInheritedGroup(this);
}
}
}