issue-5-product-gamesystems #11
@ -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>
 | 
				
			||||||
 | 
					<div id="productStateEditor">
 | 
				
			||||||
  <app-product-transition-editor [gamesystem]="gamesystem" (onOpenGamesystem)="onOpenGamesystemEditor($event)"></app-product-transition-editor>
 | 
					  <app-product-transition-editor [gamesystem]="gamesystem" (onOpenGamesystem)="onOpenGamesystemEditor($event)"></app-product-transition-editor>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					#productStateEditor {
 | 
				
			||||||
 | 
					  margin-top: 20px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,3 +1,9 @@
 | 
				
			|||||||
 | 
					<mat-card>
 | 
				
			||||||
 | 
					  <mat-card-content>
 | 
				
			||||||
 | 
					    <mat-form-field class="long-form">
 | 
				
			||||||
 | 
					      <mat-label>Filter</mat-label>
 | 
				
			||||||
 | 
					      <input matInput (keyup)="applyFilter($event)" placeholder="Filter" #input>
 | 
				
			||||||
 | 
					    </mat-form-field>
 | 
				
			||||||
    <table mat-table [dataSource]="dataSource">
 | 
					    <table mat-table [dataSource]="dataSource">
 | 
				
			||||||
      <ng-container *ngFor="let col of displayedColumns; let i = index" [matColumnDef]="col.internalName">
 | 
					      <ng-container *ngFor="let col of displayedColumns; let i = index" [matColumnDef]="col.internalName">
 | 
				
			||||||
        <th mat-header-cell *matHeaderCellDef (dblclick)="openGamesystemEditor(i)">{{col.displayedName}}</th>
 | 
					        <th mat-header-cell *matHeaderCellDef (dblclick)="openGamesystemEditor(i)">{{col.displayedName}}</th>
 | 
				
			||||||
@ -39,4 +45,10 @@
 | 
				
			|||||||
      <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>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      <tr class="mat-row" *matNoDataRow>
 | 
				
			||||||
 | 
					        <td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td>
 | 
				
			||||||
 | 
					      </tr>
 | 
				
			||||||
    </table>
 | 
					    </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