Delete ItemProperties of Item
All checks were successful
E2E Testing / test (push) Successful in 1m37s

This commit is contained in:
Sebastian Böckelmann 2024-04-20 08:03:25 +02:00
parent f70328e332
commit eb42ebb7e3
2 changed files with 11 additions and 6 deletions

View File

@ -18,7 +18,7 @@
<ng-container matColumnDef="property">
<th mat-header-cell *matHeaderCellDef>Characteristic</th>
<th mat-header-cell *matHeaderCellDef>Value</th>
<td mat-cell *matCellDef="let itemProperty">
<p>{{itemProperty.property}}</p>
</td>
@ -30,14 +30,14 @@
<button mat-icon-button class="icon-btn-primary" *ngIf="editedElement !== state" (click)="editState(state)" [disabled]="editedElement !== null"><mat-icon>edit</mat-icon></button>
<button mat-icon-button class="icon-btn-primary" (click)="finishEditing()" *ngIf="editedElement === state"><mat-icon>done</mat-icon></button>
</td>
</ng-container>
</ng-container>-->
<ng-container matColumnDef="delete">
<th mat-header-cell *matHeaderCellDef></th>
<td mat-cell *matCellDef="let state">
<button mat-icon-button color="warn" (click)="deleteState(state)"><mat-icon>delete</mat-icon></button>
<td mat-cell *matCellDef="let itemProperty">
<button mat-icon-button color="warn" (click)="deleteItemProperty(itemProperty)"><mat-icon>delete</mat-icon></button>
</td>
</ng-container>-->
</ng-container>
<ng-container matColumnDef="expand">
<th mat-header-cell *matHeaderCellDef aria-label="row actions">

View File

@ -22,7 +22,7 @@ export class ItemPropertyEditorComponent implements OnInit{
editedItemProperty: ItemProperty | undefined
expandedElement: ItemProperty | undefined
displayedColumns: string[] = ['name', 'property']
displayedColumns: string[] = ['name', 'property', 'delete']
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
datasource: MatTableDataSource<ItemProperty> = new MatTableDataSource<ItemProperty>();
@ -30,4 +30,9 @@ export class ItemPropertyEditorComponent implements OnInit{
ngOnInit() {
this.datasource.data = this.item!.itemProperties
}
deleteItemProperty(itemProperty: ItemProperty) {
this.item!.itemProperties = this.item!.itemProperties.filter(property => property.propertyName !== itemProperty.propertyName)
this.datasource.data = this.item!.itemProperties
}
}