feat: GroupComponent mit asynchroner Zellbearbeitung und verbessertem Template für die tabellarische Ansicht von Gruppen- und Benutzertabellen aktualisieren.

This commit is contained in:
Developer 02
2024-08-06 17:43:40 +02:00
parent 39da8bd664
commit 0b4a7b7ccd
2 changed files with 18 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
<div class="col-6">
<mat-tab-group>
<mat-tab label="Gruppen">
<app-group-table #groupTable [onSelectedRows]="groupsOnSelectedRows"></app-group-table>
<app-group-table #groupTable [onSelectedRows]="groupsOnSelectedRows" [cellEditing]="cellEditing"></app-group-table>
</mat-tab>
</mat-tab-group>
</div>

View File

@@ -2,9 +2,11 @@ import { AfterViewInit, Component, ViewChild } from '@angular/core';
import { GroupTableComponent } from '../../components/tables/group-table/group-table.component';
import { UserTableComponent } from '../../components/tables/user-table/user-table.component';
import { MatTabsModule } from '@angular/material/tabs';
import { GuiSelectedRow } from '@generic-ui/ngx-grid';
import { GuiCellEdit, GuiSelectedRow } from '@generic-ui/ngx-grid';
import { GroupFormComponent } from '../../components/forms/group-form/group-form.component';
import { BasePageComponent } from '../base-page/base-page.component';
import { Group } from '../../models/user-management.api.models';
import { firstValueFrom } from 'rxjs';
@Component({
standalone: true,
@@ -15,13 +17,24 @@ import { BasePageComponent } from '../base-page/base-page.component';
})
export class GroupComponent extends BasePageComponent implements AfterViewInit {
initWithoutData = () => { }
cellEditing: GuiCellEdit = {
enabled: true,
cellEdit: (value: any, item: Group, index: number) => {
this.updateService.setAsync("group_" + item.id!.toString(), async () => {
await firstValueFrom(this.groupTable.service.update(item))
})
return true;
}
}
private sGroupId = null;
ngAfterViewInit(): void {
this.refreshService.removeAll()
this.refreshService.add(() => {
this.groupTable.fetchData();
if(this.sGroupId)
if (this.sGroupId)
this.userTable.fetchDataByGroupId(this.sGroupId);
});
this.creationService.component = GroupFormComponent
@@ -31,9 +44,9 @@ export class GroupComponent extends BasePageComponent implements AfterViewInit {
@ViewChild("userTable") userTable!: UserTableComponent;
groupsOnSelectedRows = (rows: GuiSelectedRow[]) => {
if(rows.length > 0){
if (rows.length > 0) {
this.sGroupId = rows[0].source.id;
if(this.sGroupId)
if (this.sGroupId)
this.userTable.fetchDataByGroupId(this.sGroupId);
}
}