Enable Disable Editing Mode in Action Editor and implement expandable rows in product-state-editor
All checks were successful
E2E Testing / test (push) Successful in 1m29s

This commit is contained in:
Sebastian Böckelmann 2024-02-18 18:22:38 +01:00
parent 5dafce8a91
commit 2e6bddc099
4 changed files with 97 additions and 5 deletions

View File

@ -4,7 +4,7 @@
<mat-label>Filter</mat-label> <mat-label>Filter</mat-label>
<input matInput (keyup)="applyFilter($event)" placeholder="Filter" #input> <input matInput (keyup)="applyFilter($event)" placeholder="Filter" #input>
</mat-form-field> </mat-form-field>
<table mat-table [dataSource]="datasource" class="mat-elevation-z8"> <table mat-table [dataSource]="datasource" class="mat-elevation-z8" multiTemplateDataRows>
<ng-container *ngFor="let col of displayedColumns; let i = index" [matColumnDef]="col"> <ng-container *ngFor="let col of displayedColumns; let i = index" [matColumnDef]="col">
<th mat-header-cell *matHeaderCellDef>{{col}}</th> <th mat-header-cell *matHeaderCellDef>{{col}}</th>
<td mat-cell *matCellDef="let state"> <td mat-cell *matCellDef="let state">
@ -15,8 +15,36 @@
</td> </td>
</ng-container> </ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <ng-container matColumnDef="expand">
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <th mat-header-cell *matHeaderCellDef aria-label="row actions">&nbsp;</th>
<td mat-cell *matCellDef="let element">
<button mat-icon-button aria-label="expand row" (click)="(expandedElement = expandedElement === element ? null : element); $event.stopPropagation()">
@if (expandedElement === element) {
<mat-icon>keyboard_arrow_up</mat-icon>
} @else {
<mat-icon>keyboard_arrow_down</mat-icon>
}
</button>
</td>
</ng-container>
<ng-container matColumnDef="expandedDetail">
<td mat-cell *matCellDef="let element" [attr.colspan]="expandedColumns.length">
<div class="example-element-detail"
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
<p>Expanded Row</p>
</div>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="expandedColumns"></tr>
<tr mat-row *matRowDef="let element; columns: expandedColumns;"
class="example-element-row"
[class.example-expanded-row]="expandedElement === element"
(click)="expandedElement = expandedElement === element ? null : element">
</tr>
<tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="example-detail-row"></tr>
</table> </table>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>

View File

@ -2,10 +2,59 @@ table {
width: 100%; width: 100%;
} }
.mat-column-Initial { .mat-column-Initial, .mat-column-expand {
width: 32px; width: 32px;
} }
.long-form { .long-form {
width: 100%; width: 100%;
} }
table {
width: 100%;
}
tr.example-detail-row {
height: 0;
}
tr.example-element-row:not(.example-expanded-row):hover {
background: #545456;
}
tr.example-element-row:not(.example-expanded-row):active {
background: #545456;
}
.example-element-row td {
border-bottom-width: 0;
}
.example-element-detail {
overflow: hidden;
display: flex;
}
.example-element-diagram {
min-width: 80px;
border: 2px solid black;
padding: 8px;
font-weight: lighter;
margin: 8px 0;
height: 104px;
}
.example-element-symbol {
font-weight: bold;
font-size: 40px;
line-height: normal;
}
.example-element-description {
padding: 16px;
}
.example-element-description-attribution {
opacity: 0.5;
}

View File

@ -9,10 +9,18 @@ import {State} from "../../../../game-model/gamesystems/states/State";
import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator";
import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition"; import {ProductTransition} from "../../../../game-model/gamesystems/transitions/ProductTransition";
import {ProductState} from "../../../../game-model/gamesystems/states/ProductState"; import {ProductState} from "../../../../game-model/gamesystems/states/ProductState";
import {animate, state, style, transition, trigger} from "@angular/animations";
@Component({ @Component({
selector: 'app-product-state-editor', selector: 'app-product-state-editor',
templateUrl: './product-state-editor.component.html', templateUrl: './product-state-editor.component.html',
animations: [
trigger('detailExpand', [
state('collapsed,void', style({height: '0px', minHeight: '0'})),
state('expanded', style({height: '*'})),
transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
]),
],
styleUrl: './product-state-editor.component.scss' styleUrl: './product-state-editor.component.scss'
}) })
export class ProductStateEditorComponent implements OnInit{ export class ProductStateEditorComponent implements OnInit{
@ -20,13 +28,16 @@ export class ProductStateEditorComponent implements OnInit{
@Input() gamesystem: ProductGamesystem | undefined @Input() gamesystem: ProductGamesystem | undefined
@Output('onOpenGamesystemEditor') openGamesystemEditorEmitter = new EventEmitter<SimpleGamesystem>(); @Output('onOpenGamesystemEditor') openGamesystemEditorEmitter = new EventEmitter<SimpleGamesystem>();
displayedColumns: string[] = []; displayedColumns: string[] = [];
expandedColumns: string[] = []
datasource = new MatTableDataSource<ProductState>(); datasource = new MatTableDataSource<ProductState>();
expandedElement: ProductState | null = null;
ngOnInit() { ngOnInit() {
this.gamesystem!.generateFromChildsystems(); this.gamesystem!.generateFromChildsystems();
this.generateColumnNamesRecursively(this.gamesystem!, ""); this.generateColumnNamesRecursively(this.gamesystem!, "");
this.displayedColumns.push('Initial'); this.displayedColumns.push('Initial');
this.expandedColumns = [...this.displayedColumns, 'expand'];
this.datasource.data = this.gamesystem!.states; this.datasource.data = this.gamesystem!.states;
this.datasource.filterPredicate = (data: ProductState, filter: string) => { this.datasource.filterPredicate = (data: ProductState, filter: string) => {
const leaf_states = LeafGamesystemCalculator.calcLeafStates(data); const leaf_states = LeafGamesystemCalculator.calcLeafStates(data);

View File

@ -12,6 +12,7 @@ import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount
export class ScriptaccountActionEditorComponent implements OnInit{ export class ScriptaccountActionEditorComponent implements OnInit{
@Input() transition: Transition<any> | undefined @Input() transition: Transition<any> | undefined
@Input() scriptAccounts: ScriptAccount[] = [] @Input() scriptAccounts: ScriptAccount[] = []
@Input() enableEditing: boolean = false;
dataSource: MatTableDataSource<ScriptAccountAction> = new MatTableDataSource(); dataSource: MatTableDataSource<ScriptAccountAction> = new MatTableDataSource();
displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete']; displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete'];
@ -21,7 +22,10 @@ export class ScriptaccountActionEditorComponent implements OnInit{
ngOnInit() { ngOnInit() {
this.dataSource.data = this.transition!.scriptAccountActions.map(action => action); this.dataSource.data = this.transition!.scriptAccountActions.map(action => action);
console.log("# ScriptAccounts", this.scriptAccounts.length)
if(!this.enableEditing) {
this.displayedColumns = this.displayedColumns.slice(0, -2);
}
} }
editAction(scriptAccountAction: ScriptAccountAction) { editAction(scriptAccountAction: ScriptAccountAction) {