diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html index 038300d..b2d1a1f 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html @@ -1,2 +1,4 @@ - +
+ +
diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.scss b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.scss index e69de29..2739e15 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.scss +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.scss @@ -0,0 +1,3 @@ +#productStateEditor { + margin-top: 20px; +} diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html index cbe907a..e2da5c2 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html @@ -1,42 +1,54 @@ - - - - - + + + + Filter + + +
{{col.displayedName}} - {{getLeafStateByIndex(transition, i).stateLabel}} -
+ + + + - - - - - - + + + + + + - - - + + + - - + + -
{{col.displayedName}} + {{getLeafStateByIndex(transition, i).stateLabel}} + - Starting State - - Ending State - + Starting State + + Ending State +
+ + No data matching the filter "{{input.value}}" + + + + + diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.scss b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.scss index e69de29..432fb10 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.scss +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.scss @@ -0,0 +1,4 @@ +.long-form { + width: 100%; +} + diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts index c823260..f3edf0c 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts @@ -5,7 +5,7 @@ import { MatCell, MatCellDef, MatColumnDef, MatHeaderCell, - MatHeaderCellDef, MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef, + MatHeaderCellDef, MatHeaderRow, MatHeaderRowDef, MatNoDataRow, MatRow, MatRowDef, MatTable, MatTableDataSource } from "@angular/material/table"; @@ -14,6 +14,10 @@ import {NgForOf, NgIf} from "@angular/common"; import {ProductTransition} from "../../../../game-model/gamesystems/ProductTransition"; import {ProductState} from "../../../../game-model/gamesystems/ProductState"; import {MatTooltip} from "@angular/material/tooltip"; +import {MatFormField} from "@angular/material/form-field"; +import {MatInput} from "@angular/material/input"; +import {Transition} from "../../../../game-model/gamesystems/Transition"; +import {MatCard, MatCardContent, MatCardTitle} from "@angular/material/card"; class DisplayedColumnName { displayedName: string @@ -41,7 +45,13 @@ class DisplayedColumnName { MatRow, MatHeaderRowDef, MatRowDef, - MatTooltip + MatTooltip, + MatFormField, + MatInput, + MatNoDataRow, + MatCard, + MatCardContent, + MatCardTitle ], templateUrl: './product-transition-editor.component.html', styleUrl: './product-transition-editor.component.scss' @@ -51,7 +61,7 @@ export class ProductTransitionEditorComponent implements OnInit{ @Input() gamesystem: ProductGamesystem | undefined @Output() onOpenGamesystem = new EventEmitter(); - dataSource = new MatTableDataSource(); + dataSource = new MatTableDataSource(); displayedColumns: DisplayedColumnName[] = []; columns: string[] = []; numberLeafSystems: number = -1; @@ -66,6 +76,14 @@ export class ProductTransitionEditorComponent implements OnInit{ this.columns = this.displayedColumns.map(column => column.internalName) this.dataSource.data = this.gamesystem.transitions; + this.dataSource.filterPredicate = (data: ProductTransition, filter: string) => { + const leaf_starting_states = LeafGamesystemCalculator.calcLeafStates(data.startingState); + const leaf_ending_states = LeafGamesystemCalculator.calcLeafStates(data.endingState); + + const combined_leaf_states = leaf_starting_states.concat(leaf_ending_states); + + return combined_leaf_states.some((state) => state.stateLabel.toLowerCase().includes(filter)) + } } } @@ -79,8 +97,6 @@ export class ProductTransitionEditorComponent implements OnInit{ index = leafIndex - this.numberLeafSystems; } - - const leafStates = LeafGamesystemCalculator.calcLeafStates(state); console.log(leafStates) return leafStates[index]; @@ -94,4 +110,9 @@ export class ProductTransitionEditorComponent implements OnInit{ this.onOpenGamesystem.emit(leafGamesystems[leafIndex - this.numberLeafSystems]) } } + + applyFilter(event: KeyboardEvent) { + const filterValue = (event.target as HTMLInputElement).value; + this.dataSource.filter = filterValue.trim().toLowerCase(); + } } diff --git a/src/app/game-model/gamesystems/ProductState.ts b/src/app/game-model/gamesystems/ProductState.ts index f499f35..4831c3d 100644 --- a/src/app/game-model/gamesystems/ProductState.ts +++ b/src/app/game-model/gamesystems/ProductState.ts @@ -38,5 +38,16 @@ export class ProductState extends State { return true; } + existsInnerStateByLowerCaseLabel(label: string): boolean { + this.innerStates.forEach(innerState => { + if(innerState instanceof SimpleState && innerState.stateLabel.toLowerCase() === label) { + return true; + } else if(innerState instanceof ProductState) { + return innerState.existsInnerStateByLowerCaseLabel(label); + } + }) + + return false; + } } diff --git a/src/app/game-model/gamesystems/ProductTransition.ts b/src/app/game-model/gamesystems/ProductTransition.ts index 3e862ea..ebd0be5 100644 --- a/src/app/game-model/gamesystems/ProductTransition.ts +++ b/src/app/game-model/gamesystems/ProductTransition.ts @@ -3,4 +3,7 @@ import {ProductState} from "./ProductState"; export class ProductTransition extends Transition { + containsInnerStateByLabel(label: string) { + return this.startingState.existsInnerStateByLowerCaseLabel(label) || this.endingState.existsInnerStateByLowerCaseLabel(label); + } }