Filter ProductTransitions by Statelabel
Some checks failed
E2E Testing / test (push) Failing after 1m29s
Some checks failed
E2E Testing / test (push) Failing after 1m29s
This commit is contained in:
parent
18bdacb5e9
commit
9e43b3901c
@ -1,2 +1,4 @@
|
|||||||
<app-product-state-editor [gamesystem]="gamesystem" (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-state-editor>
|
<app-product-state-editor [gamesystem]="gamesystem" (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-state-editor>
|
||||||
<app-product-transition-editor [gamesystem]="gamesystem" (onOpenGamesystem)="onOpenGamesystemEditor($event)"></app-product-transition-editor>
|
<div id="productStateEditor">
|
||||||
|
<app-product-transition-editor [gamesystem]="gamesystem" (onOpenGamesystem)="onOpenGamesystemEditor($event)"></app-product-transition-editor>
|
||||||
|
</div>
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
#productStateEditor {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
@ -1,42 +1,54 @@
|
|||||||
<table mat-table [dataSource]="dataSource">
|
<mat-card>
|
||||||
<ng-container *ngFor="let col of displayedColumns; let i = index" [matColumnDef]="col.internalName">
|
<mat-card-content>
|
||||||
<th mat-header-cell *matHeaderCellDef (dblclick)="openGamesystemEditor(i)">{{col.displayedName}}</th>
|
<mat-form-field class="long-form">
|
||||||
<td mat-cell *matCellDef="let transition" [matTooltip]="getLeafStateByIndex(transition, i).stateDescription" (dblclick)="openGamesystemEditor(i)">
|
<mat-label>Filter</mat-label>
|
||||||
{{getLeafStateByIndex(transition, i).stateLabel}}
|
<input matInput (keyup)="applyFilter($event)" placeholder="Filter" #input>
|
||||||
</td>
|
</mat-form-field>
|
||||||
</ng-container>
|
<table mat-table [dataSource]="dataSource">
|
||||||
|
<ng-container *ngFor="let col of displayedColumns; let i = index" [matColumnDef]="col.internalName">
|
||||||
|
<th mat-header-cell *matHeaderCellDef (dblclick)="openGamesystemEditor(i)">{{col.displayedName}}</th>
|
||||||
|
<td mat-cell *matCellDef="let transition" [matTooltip]="getLeafStateByIndex(transition, i).stateDescription" (dblclick)="openGamesystemEditor(i)">
|
||||||
|
{{getLeafStateByIndex(transition, i).stateLabel}}
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="header-row-sec-group">
|
<ng-container matColumnDef="header-row-sec-group">
|
||||||
<th
|
<th
|
||||||
mat-header-cell
|
mat-header-cell
|
||||||
*matHeaderCellDef
|
*matHeaderCellDef
|
||||||
[style.text-align]="'center'"
|
[style.text-align]="'center'"
|
||||||
[attr.colspan]="numberLeafSystems"
|
[attr.colspan]="numberLeafSystems"
|
||||||
class="start-end-col"
|
class="start-end-col"
|
||||||
>
|
>
|
||||||
Starting State
|
Starting State
|
||||||
</th>
|
</th>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="header-row-third-group">
|
<ng-container matColumnDef="header-row-third-group">
|
||||||
<th
|
<th
|
||||||
mat-header-cell
|
mat-header-cell
|
||||||
*matHeaderCellDef
|
*matHeaderCellDef
|
||||||
[style.text-align]="'center'"
|
[style.text-align]="'center'"
|
||||||
[attr.colspan]="numberLeafSystems"
|
[attr.colspan]="numberLeafSystems"
|
||||||
>
|
>
|
||||||
Ending State
|
Ending State
|
||||||
</th>
|
</th>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngIf="displayedColumns.length">
|
<ng-container *ngIf="displayedColumns.length">
|
||||||
<tr
|
<tr
|
||||||
mat-header-row
|
mat-header-row
|
||||||
*matHeaderRowDef="['header-row-sec-group', 'header-row-third-group']"
|
*matHeaderRowDef="['header-row-sec-group', 'header-row-third-group']"
|
||||||
></tr>
|
></tr>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="columns;sticky:true"></tr>
|
<tr mat-header-row *matHeaderRowDef="columns;sticky:true"></tr>
|
||||||
<tr mat-row *matRowDef="let row; columns: columns;"></tr>
|
<tr mat-row *matRowDef="let row; columns: columns;"></tr>
|
||||||
|
|
||||||
</table>
|
<tr class="mat-row" *matNoDataRow>
|
||||||
|
<td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
.long-form {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
|||||||
MatCell, MatCellDef,
|
MatCell, MatCellDef,
|
||||||
MatColumnDef,
|
MatColumnDef,
|
||||||
MatHeaderCell,
|
MatHeaderCell,
|
||||||
MatHeaderCellDef, MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef,
|
MatHeaderCellDef, MatHeaderRow, MatHeaderRowDef, MatNoDataRow, MatRow, MatRowDef,
|
||||||
MatTable,
|
MatTable,
|
||||||
MatTableDataSource
|
MatTableDataSource
|
||||||
} from "@angular/material/table";
|
} from "@angular/material/table";
|
||||||
@ -14,6 +14,10 @@ import {NgForOf, NgIf} from "@angular/common";
|
|||||||
import {ProductTransition} from "../../../../game-model/gamesystems/ProductTransition";
|
import {ProductTransition} from "../../../../game-model/gamesystems/ProductTransition";
|
||||||
import {ProductState} from "../../../../game-model/gamesystems/ProductState";
|
import {ProductState} from "../../../../game-model/gamesystems/ProductState";
|
||||||
import {MatTooltip} from "@angular/material/tooltip";
|
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 {
|
class DisplayedColumnName {
|
||||||
displayedName: string
|
displayedName: string
|
||||||
@ -41,7 +45,13 @@ class DisplayedColumnName {
|
|||||||
MatRow,
|
MatRow,
|
||||||
MatHeaderRowDef,
|
MatHeaderRowDef,
|
||||||
MatRowDef,
|
MatRowDef,
|
||||||
MatTooltip
|
MatTooltip,
|
||||||
|
MatFormField,
|
||||||
|
MatInput,
|
||||||
|
MatNoDataRow,
|
||||||
|
MatCard,
|
||||||
|
MatCardContent,
|
||||||
|
MatCardTitle
|
||||||
],
|
],
|
||||||
templateUrl: './product-transition-editor.component.html',
|
templateUrl: './product-transition-editor.component.html',
|
||||||
styleUrl: './product-transition-editor.component.scss'
|
styleUrl: './product-transition-editor.component.scss'
|
||||||
@ -51,7 +61,7 @@ export class ProductTransitionEditorComponent implements OnInit{
|
|||||||
@Input() gamesystem: ProductGamesystem | undefined
|
@Input() gamesystem: ProductGamesystem | undefined
|
||||||
@Output() onOpenGamesystem = new EventEmitter<SimpleGamesystem>();
|
@Output() onOpenGamesystem = new EventEmitter<SimpleGamesystem>();
|
||||||
|
|
||||||
dataSource = new MatTableDataSource();
|
dataSource = new MatTableDataSource<ProductTransition>();
|
||||||
displayedColumns: DisplayedColumnName[] = [];
|
displayedColumns: DisplayedColumnName[] = [];
|
||||||
columns: string[] = [];
|
columns: string[] = [];
|
||||||
numberLeafSystems: number = -1;
|
numberLeafSystems: number = -1;
|
||||||
@ -66,6 +76,14 @@ export class ProductTransitionEditorComponent implements OnInit{
|
|||||||
this.columns = this.displayedColumns.map(column => column.internalName)
|
this.columns = this.displayedColumns.map(column => column.internalName)
|
||||||
|
|
||||||
this.dataSource.data = this.gamesystem.transitions;
|
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;
|
index = leafIndex - this.numberLeafSystems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const leafStates = LeafGamesystemCalculator.calcLeafStates(state);
|
const leafStates = LeafGamesystemCalculator.calcLeafStates(state);
|
||||||
console.log(leafStates)
|
console.log(leafStates)
|
||||||
return leafStates[index];
|
return leafStates[index];
|
||||||
@ -94,4 +110,9 @@ export class ProductTransitionEditorComponent implements OnInit{
|
|||||||
this.onOpenGamesystem.emit(leafGamesystems[leafIndex - this.numberLeafSystems])
|
this.onOpenGamesystem.emit(leafGamesystems[leafIndex - this.numberLeafSystems])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applyFilter(event: KeyboardEvent) {
|
||||||
|
const filterValue = (event.target as HTMLInputElement).value;
|
||||||
|
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,5 +38,16 @@ export class ProductState extends State<ProductTransition> {
|
|||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,7 @@ import {ProductState} from "./ProductState";
|
|||||||
|
|
||||||
export class ProductTransition extends Transition<ProductState> {
|
export class ProductTransition extends Transition<ProductState> {
|
||||||
|
|
||||||
|
containsInnerStateByLabel(label: string) {
|
||||||
|
return this.startingState.existsInnerStateByLowerCaseLabel(label) || this.endingState.existsInnerStateByLowerCaseLabel(label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user